aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Monniaux <David.Monniaux@univ-grenoble-alpes.fr>2021-07-19 18:33:13 +0200
committerDavid Monniaux <David.Monniaux@univ-grenoble-alpes.fr>2021-07-19 18:33:13 +0200
commitb5c4192c73d7b02e0c90354e26b35a84ee141083 (patch)
treeb5a550c1c2ed7ed356e212a578f4a945f76970d1
parent650c134f915d0b2e799c76c87ffd2ed09c782dcc (diff)
parentee2112a9bacc246e0434a19fc93aab335fd56ddd (diff)
downloadcompcert-kvx-b5c4192c73d7b02e0c90354e26b35a84ee141083.tar.gz
compcert-kvx-b5c4192c73d7b02e0c90354e26b35a84ee141083.zip
Fix can't schedule issues
exit 1 if scheduling fails Merge remote-tracking branch 'origin/kvx-sched-w-reg-press' into kvx-work
-rw-r--r--aarch64/PrepassSchedulingOracle.ml3
-rw-r--r--driver/Clflags.ml2
-rw-r--r--scheduling/InstructionScheduler.ml98
3 files changed, 48 insertions, 55 deletions
diff --git a/aarch64/PrepassSchedulingOracle.ml b/aarch64/PrepassSchedulingOracle.ml
index e09eea13..03a9e202 100644
--- a/aarch64/PrepassSchedulingOracle.ml
+++ b/aarch64/PrepassSchedulingOracle.ml
@@ -482,7 +482,8 @@ let schedule_sequence (seqa : (instruction*Regset.t) array)
| Icond _ -> true
| _ -> false) seqa) with
| None -> Printf.printf "no solution in prepass scheduling\n";
- None
+ Stdlib.exit 1
+ (* TODO None *)
| Some solution ->
let positions = Array.init nr_instructions (fun i -> i) in
Array.sort (fun i j ->
diff --git a/driver/Clflags.ml b/driver/Clflags.ml
index 134c222f..25bd2c78 100644
--- a/driver/Clflags.ml
+++ b/driver/Clflags.ml
@@ -51,7 +51,7 @@ let option_flooprotate = ref 0 (* rotate the innermost loops to have the conditi
let option_mtune = ref ""
let option_fprepass = ref true
-let option_fprepass_sched = ref "regpres_bis"
+let option_fprepass_sched = ref "regpres"
let option_fpostpass = ref true
let option_fpostpass_sched = ref "list"
diff --git a/scheduling/InstructionScheduler.ml b/scheduling/InstructionScheduler.ml
index 5bd969ca..e3a421a5 100644
--- a/scheduling/InstructionScheduler.ml
+++ b/scheduling/InstructionScheduler.ml
@@ -349,11 +349,13 @@ let _ = fun x -> priority_list_scheduler INSTRUCTION_ORDER x;;
(* A scheduler sensitive to register pressure *)
let reg_pres_scheduler (problem : problem) : solution option =
+ (* DebugPrint.debug_flag := true; *)
let nr_instructions = get_nr_instructions problem in
if !Clflags.option_debug_compcert > 6 then
- DebugPrint.debug "SCHEDULING_SUPERBLOCK %d\n" nr_instructions;
-
+ (Printf.eprintf "\nSCHEDULING_SUPERBLOCK %d\n" nr_instructions;
+ flush stderr);
+
let successors = get_successors problem
and predecessors = get_predecessors problem
and times = Array.make (nr_instructions+1) (-1) in
@@ -493,32 +495,22 @@ let reg_pres_scheduler (problem : problem) : solution option =
let attempt_scheduling ready usages =
let result = ref (-1) in
+ DebugPrint.debug "\n\nREADY: ";
+ InstrSet.iter (fun i -> DebugPrint.debug "%d " i) ready;
+ DebugPrint.debug "\n\n";
try
Array.iteri (fun i avlregs ->
- (* print_string "avlregs: ";
- * print_int i;
- * 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)
+ DebugPrint.debug "avlregs: %d %d\nlive regs: %d\n"
+ i avlregs (Hashtbl.length live_regs);
+ if !cnt < 5 && avlregs <= regs_thresholds.(i)
then (
csr_b := true;
let maybe = InstrSet.sched_CSR i ready usages in
- (* print_string "maybe\n";
- * print_int maybe;
- * print_newline ();
- * flush stdout; *)
- (if maybe > 0 &&
+ DebugPrint.debug "maybe %d\n" maybe;
+ (if maybe >= 0 &&
let delta =
List.fold_left (fold_delta i) 0 mentions.(maybe) in
- (* print_string "delta ";
- * print_int delta;
- * print_newline ();
- * flush stdout; *)
+ DebugPrint.debug "delta %d\n" delta;
delta > 0
then
(vector_subtract usages.(maybe) current_resources;
@@ -532,7 +524,8 @@ let reg_pres_scheduler (problem : problem) : solution option =
then result := ins
) ready;
if !result <> -1 then
- vector_subtract usages.(!result) current_resources)
+ vector_subtract usages.(!result) current_resources;
+ incr cnt)
else
(incr cnt)
);
@@ -556,33 +549,31 @@ 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; *)
- if !csr_b && !Clflags.option_debug_compcert > 6 then
- DebugPrint.debug "REGPRES: high pres class %d\n" i;
- csr_b := false;
- if !Clflags.option_regpres_wait_window then
- 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
- (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 -> (Hashtbl.add live_regs r t;
- available_regs.(t)
- <- available_regs.(t) - 1)
- | Some i -> ()
- ) mentions.(i));
+ (DebugPrint.debug "INSTR ISSUED: %d\n" i;
+ if !csr_b && !Clflags.option_debug_compcert > 6 then
+ (Printf.eprintf "REGPRES: high pres class %d\n" i;
+ flush stderr);
+ csr_b := false;
+ (* if !Clflags.option_regpres_wait_window then *)
+ 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
+ (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 -> (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));
@@ -593,8 +584,8 @@ let reg_pres_scheduler (problem : problem) : solution option =
| to_time ->
((* DebugPrint.debug "TO TIME %d : %d\n" to_time
* (Array.length ready); *)
- ready.(to_time)
- <- InstrSet.add instr_to ready.(to_time))
+ ready.(to_time)
+ <- InstrSet.add instr_to ready.(to_time))
) successors.(i);
successors.(i) <- []
)
@@ -603,8 +594,7 @@ let reg_pres_scheduler (problem : problem) : solution option =
try
let final_time = ref (-1) in
for i = 0 to nr_instructions - 1 do
- (* print_int i;
- * flush stdout; *)
+ DebugPrint.debug "%d " i;
(if times.(i) < 0 then raise Exit);
(if !final_time < times.(i) + 1 then final_time := times.(i) + 1)
done;
@@ -613,9 +603,11 @@ let reg_pres_scheduler (problem : problem) : solution option =
if target_time > !final_time then
final_time := target_time) predecessors.(nr_instructions);
times.(nr_instructions) <- !final_time;
+ (* DebugPrint.debug_flag := false; *)
Some times
with Exit ->
DebugPrint.debug "reg_pres_sched failed\n";
+ (* DebugPrint.debug_flag := false; *)
None
;;