aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scheduling/InstructionScheduler.mli6
-rw-r--r--scheduling/PrepassSchedulingOracle.ml31
2 files changed, 36 insertions, 1 deletions
diff --git a/scheduling/InstructionScheduler.mli b/scheduling/InstructionScheduler.mli
index 85e2a5c6..fb7af3f6 100644
--- a/scheduling/InstructionScheduler.mli
+++ b/scheduling/InstructionScheduler.mli
@@ -33,6 +33,12 @@ type problem = {
(** Print problem for human readability. *)
val print_problem : out_channel -> problem -> unit;;
+(** Get the number of instructions in a problem *)
+val get_nr_instructions : problem -> int;;
+
+(** Get the number of resources in a problem *)
+val get_nr_resources : problem -> int;;
+
(** Scheduling solution. For {i n} instructions to schedule, and 0≤{i i}<{i n}, position {i i} contains the time to which instruction {i i} should be scheduled. Position {i n} contains the final output latency. *)
type solution = int array
diff --git a/scheduling/PrepassSchedulingOracle.ml b/scheduling/PrepassSchedulingOracle.ml
index 78961310..7b7b7233 100644
--- a/scheduling/PrepassSchedulingOracle.ml
+++ b/scheduling/PrepassSchedulingOracle.ml
@@ -403,6 +403,29 @@ let define_problem seqa =
then (get_alias_dependencies seqa) @ simple_deps
else *) simple_deps };;
+let zigzag_scheduler problem early_ones =
+ let nr_instructions = get_nr_instructions problem in
+ assert(nr_instructions = (Array.length early_ones));
+ match list_scheduler problem with
+ | Some fwd_schedule ->
+ let fwd_makespan = fwd_schedule.((Array.length fwd_schedule) - 1) in
+ let constraints' = ref problem.latency_constraints in
+ Array.iteri (fun i is_early ->
+ if is_early then
+ constraints' := {
+ instr_from = i;
+ instr_to = nr_instructions ;
+ latency = fwd_makespan - fwd_schedule.(i) } ::!constraints' )
+ early_ones;
+ validated_scheduler reverse_list_scheduler
+ { problem with latency_constraints = !constraints' }
+ | None -> None;;
+
+let prepass_scheduler_by_name name problem early_ones =
+ match name with
+ | "zigzag" -> zigzag_scheduler problem early_ones
+ | _ -> scheduler_by_name name problem
+
let schedule_sequence (seqa : (instruction*Regset.t) array) =
try
if (Array.length seqa) <= 1
@@ -414,7 +437,13 @@ let schedule_sequence (seqa : (instruction*Regset.t) array) =
let problem = define_problem seqa in
print_sequence stdout (Array.map fst seqa);
print_problem stdout problem;
- match scheduler_by_name (!Clflags.option_fprepass_sched) problem with
+ match prepass_scheduler_by_name
+ (!Clflags.option_fprepass_sched)
+ problem
+ (Array.map (fun (ins, _) ->
+ match ins with
+ | Icond _ -> true
+ | _ -> false) seqa) with
| None -> Printf.printf "no solution in prepass scheduling\n";
None
| Some solution ->