diff options
author | nicolas.nardino <nicolas.nardino@ens-lyon.fr> | 2021-06-15 14:44:56 +0200 |
---|---|---|
committer | nicolas.nardino <nicolas.nardino@ens-lyon.fr> | 2021-06-15 14:44:56 +0200 |
commit | 87c82b6fcf2bf825a8c60fc6a95498aac9f826d4 (patch) | |
tree | 162a8642b85de5005ef7d63e50a789e73f6d6673 | |
parent | 19464b3992eadf7670acc7231896103ab54885e5 (diff) | |
download | compcert-kvx-87c82b6fcf2bf825a8c60fc6a95498aac9f826d4.tar.gz compcert-kvx-87c82b6fcf2bf825a8c60fc6a95498aac9f826d4.zip |
kinda fixed
Spills are definitely reduced, but lots of arbitrary in there:
See previous commit: need to determine what to do if pressure is too
high but no schedulable instruction can reduce it. For now, advance
time for at most 5 cycles, if still no suitable instruction, go back
to CSP
-rw-r--r-- | scheduling/InstructionScheduler.ml | 62 | ||||
-rw-r--r-- | scheduling/RTLpathScheduleraux.ml | 20 |
2 files changed, 57 insertions, 25 deletions
diff --git a/scheduling/InstructionScheduler.ml b/scheduling/InstructionScheduler.ml index 19bfaeb0..72222022 100644 --- a/scheduling/InstructionScheduler.ml +++ b/scheduling/InstructionScheduler.ml @@ -478,6 +478,9 @@ let reg_pres_scheduler (problem : problem) : solution option = ready.(!current_time) <- InstrSet.empty)); incr current_time in + + (* ALL MENTIONS TO cnt ARE PLACEHOLDERS *) + let cnt = ref 0 in let attempt_scheduling ready usages = let result = ref (-1) in @@ -488,8 +491,11 @@ let reg_pres_scheduler (problem : problem) : solution option = print_string " "; print_int avlregs; print_newline (); + print_string "live regs: "; + print_int (Hashtbl.length live_regs); + print_newline (); flush stdout; - if avlregs <= regs_thresholds.(i) + if !cnt < 5 && avlregs <= regs_thresholds.(i) then ( let maybe = InstrSet.sched_CSR i ready usages in print_string "maybe\n"; @@ -506,8 +512,9 @@ let reg_pres_scheduler (problem : problem) : solution option = delta >= 0 then (vector_subtract usages.(maybe) current_resources; - result := maybe; - raise Exit))) available_regs; + result := maybe) + else incr cnt; + raise Exit)) available_regs; InstrSet.iter (fun i -> if vector_less_equal usages.(i) current_resources then ( @@ -516,25 +523,7 @@ let reg_pres_scheduler (problem : problem) : solution option = raise Exit)) ready; -1 with Exit -> - if !result <> -1 then - (List.iter (fun (r,b) -> - if b then - match Hashtbl.find_opt counts r with - | None -> assert false - | Some (t, n) -> - Hashtbl.remove counts r; - (if n = 1 then - available_regs.(t) - <- available_regs.(t) + 1) - else - let t = class_r r in - match Hashtbl.find_opt live_regs r with - | None -> (Hashtbl.add live_regs r t; - available_regs.(t) - <- available_regs.(t) - 1) - | Some i -> () - ) mentions.(!result)); - !result in + !result in while !current_time < max_time do @@ -545,6 +534,35 @@ let reg_pres_scheduler (problem : problem) : solution option = problem.instruction_usages with | -1 -> advance_time() | i -> (assert(times.(i) < 0); + (print_string "INSTR ISSUED: "; + print_int i; + print_newline (); + flush stdout; + cnt := 0; + List.iter (fun (r,b) -> + if b then + (match Hashtbl.find_opt counts r with + | None -> assert false + | Some (t, n) -> + Hashtbl.remove counts r; + if n = 1 then + (print_string "yaaaaaaaaaaaas "; + print_int (Camlcoq.P.to_int r); + print_newline (); + Hashtbl.remove live_regs r; + available_regs.(t) + <- available_regs.(t) + 1)) + else + let t = class_r r in + match Hashtbl.find_opt live_regs r with + | None -> (print_string "noooooooooo "; + print_int (Camlcoq.P.to_int r); + print_newline (); + Hashtbl.add live_regs r t; + available_regs.(t) + <- available_regs.(t) - 1) + | Some i -> () + ) mentions.(i)); times.(i) <- !current_time; ready.(!current_time) <- InstrSet.remove i (ready.(!current_time)); diff --git a/scheduling/RTLpathScheduleraux.ml b/scheduling/RTLpathScheduleraux.ml index 9c3ff689..8df3edbc 100644 --- a/scheduling/RTLpathScheduleraux.ml +++ b/scheduling/RTLpathScheduleraux.ml @@ -72,7 +72,7 @@ let get_superblocks code entry pm typing = lsb end -(** the useful one. Returns a hashtable with bindings of form +(** the useful one. Returns a hashtable with bindings of shape ** [(r,(t, n)], where [r] is a pseudo-register (Registers.reg), ** [t] is its class (according to [typing]), and [n] the number of ** times it's referenced as an argument in instructions of [seqa] ; @@ -85,7 +85,7 @@ let reference_counting (seqa : (instruction * Regset.t) array) let retl = Hashtbl.create 42 in let retr = Array.make (Array.length seqa) [] in (* retr.(i) : (r, b) -> (r', b') -> ... - where b = true if seen as arg, false if seen as dest + * where b = true if seen as arg, false if seen as dest *) List.iter (fun reg -> Hashtbl.add retl @@ -118,7 +118,7 @@ let reference_counting (seqa : (instruction * Regset.t) array) (dest,false)::(reg, true)::(map_true args) | _ -> (dest,false)::(map_true args)) - | Itailcall(_,fn,args) -> + | Itailcall(_,fn,args) -> List.iter (add_reg) args; retr.(i) <- (match fn with | Datatypes.Coq_inl reg -> @@ -146,6 +146,20 @@ let reference_counting (seqa : (instruction * Regset.t) array) retr.(i) <- [reg, true] | _ -> () ) seqa; + print_string "mentions\n"; + Array.iteri (fun i l -> + print_int i; + print_string ": ["; + List.iter (fun (r, b) -> + print_int (Camlcoq.P.to_int r); + print_string ":"; + print_string (if b then "a:" else "d"); + if b then print_int (snd (Hashtbl.find retl r)); + print_string ", " + ) l; + print_string "]\n"; + flush stdout; + ) retr; retl, retr |