aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-06-21 22:07:28 +0200
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-06-21 22:07:28 +0200
commit80295d3c7cc82c34903f7ed92a77a64870f1920f (patch)
treeaf10841d9fb63ea791830d3f1deab5d33d77f7c7
parenta52b50bf91bbb11ebb95757b818374d4507ea05d (diff)
downloadcompcert-kvx-80295d3c7cc82c34903f7ed92a77a64870f1920f.tar.gz
compcert-kvx-80295d3c7cc82c34903f7ed92a77a64870f1920f.zip
-frevlist
-rw-r--r--mppa_k1c/InstructionScheduler.ml41
-rw-r--r--mppa_k1c/PostpassSchedulingOracle.ml2
-rw-r--r--test/monniaux/rules.mk2
3 files changed, 36 insertions, 9 deletions
diff --git a/mppa_k1c/InstructionScheduler.ml b/mppa_k1c/InstructionScheduler.ml
index 2836c160..b9e362c7 100644
--- a/mppa_k1c/InstructionScheduler.ml
+++ b/mppa_k1c/InstructionScheduler.ml
@@ -427,7 +427,15 @@ let max_scheduled_time solution =
done;
!time;;
-(* DM: I think this is buggy *)
+let recompute_makespan problem solution =
+ let n = (Array.length solution) - 1 and ms = ref 0 in
+ List.iter (fun cstr ->
+ if cstr.instr_to = n
+ then ms := max !ms (solution.(cstr.instr_from) + cstr.latency)
+ ) problem.latency_constraints;
+ !ms;;
+
+(* Does not take into account latencies to exit point *)
let schedule_reversed (scheduler : problem -> solution option)
(problem : problem) =
match scheduler (reverse_problem problem) with
@@ -435,11 +443,13 @@ let schedule_reversed (scheduler : problem -> solution option)
| Some solution ->
let nr_instructions = get_nr_instructions problem
and maxi = max_scheduled_time solution in
- Some (Array.init (Array.length solution)
+ let ret = Array.init (Array.length solution)
(fun i ->
if i < nr_instructions
then maxi-solution.(nr_instructions-1-i)
- else solution.(i)));;
+ else solution.(i)) in
+ ret.(nr_instructions) <- recompute_makespan problem ret;
+ Some ret;;
(** Schedule the problem using a greedy list scheduling algorithm, from the end. *)
let reverse_list_scheduler = schedule_reversed list_scheduler;;
@@ -1109,6 +1119,17 @@ let ilp_print_problem channel problem pb_type =
mapper_final_predecessors = predecessors.(nr_instructions)
};;
+(* Guess what? Cplex sometimes outputs 11.000000004 instead of integer 11 *)
+
+let positive_float_round x = truncate (x +. 0.5)
+
+let float_round (x : float) : int =
+ if x > 0.0
+ then positive_float_round x
+ else - (positive_float_round (-. x))
+
+let rounded_int_of_string x = float_round (float_of_string x)
+
let ilp_read_solution mapper channel =
let times = Array.make
(match mapper.mapper_pb_type with
@@ -1134,9 +1155,10 @@ let ilp_read_solution mapper channel =
(if tnumber < 0 || tnumber >= (Array.length times)
then failwith (Printf.sprintf "bad ilp output: not a correct variable number: %d (%d)" tnumber (Array.length times)));
let value =
- try int_of_string (String.sub line (space+1) ((String.length line)-space-1))
+ let s = String.sub line (space+1) ((String.length line)-space-1) in
+ try rounded_int_of_string s
with Failure _ ->
- failwith "bad ilp output: not a time number"
+ failwith (Printf.sprintf "bad ilp output: not a time number (%s)" s)
in
(if value < 0
then failwith "bad ilp output: negative time");
@@ -1153,11 +1175,14 @@ let ilp_read_solution mapper channel =
times;;
let ilp_solver = ref "ilp_solver"
-
+
+let problem_nr = ref 0
+
let ilp_scheduler pb_type problem =
try
- let filename_in = "problem.lp"
- and filename_out = "problem.sol" in
+ let filename_in = Printf.sprintf "problem%05d.lp" !problem_nr
+ and filename_out = Printf.sprintf "problem%05d.sol" !problem_nr in
+ incr problem_nr;
let opb_problem = open_out filename_in in
let mapper = ilp_print_problem opb_problem problem pb_type in
close_out opb_problem;
diff --git a/mppa_k1c/PostpassSchedulingOracle.ml b/mppa_k1c/PostpassSchedulingOracle.ml
index 462e9cd0..19eec3e6 100644
--- a/mppa_k1c/PostpassSchedulingOracle.ml
+++ b/mppa_k1c/PostpassSchedulingOracle.ml
@@ -912,6 +912,8 @@ let do_schedule bb =
validated_scheduler cascaded_scheduler
else if !Clflags.option_fpostpass_sched = "list" then
validated_scheduler list_scheduler
+ else if !Clflags.option_fpostpass_sched = "revlist" then
+ validated_scheduler reverse_list_scheduler
else if !Clflags.option_fpostpass_sched = "greedy" then
greedy_scheduler else failwith ("Invalid scheduler:" ^ !Clflags.option_fpostpass_sched)) problem
in match solution with
diff --git a/test/monniaux/rules.mk b/test/monniaux/rules.mk
index 33a71a46..211feafd 100644
--- a/test/monniaux/rules.mk
+++ b/test/monniaux/rules.mk
@@ -9,7 +9,7 @@ K1C_CFLAGS = -D__K1C_COS__ -std=c99 -O3 -Wall -Wextra -Werror=implicit $(ALL_CF
K1C_CFLAGS_O1 =-std=c99 -O1 -fschedule-insns2 -Wall -Wextra -Werror=implicit $(ALL_CFLAGS)
K1C_CCOMP = ../../../ccomp
-K1C_CCOMPFLAGS=-O3 -Wall $(ALL_CCOMPFLAGS) $(ALL_CFLAGS) # -fpostpass-ilp
+K1C_CCOMPFLAGS=-O3 -Wall $(ALL_CCOMPFLAGS) $(ALL_CFLAGS) # -fpostpass= revlist
EXECUTE=k1-cluster --syscall=libstd_scalls.so --
EXECUTE_CYCLES=k1-cluster --syscall=libstd_scalls.so --cycle-based --