diff options
Diffstat (limited to 'mppa_k1c')
-rw-r--r-- | mppa_k1c/InstructionScheduler.ml | 41 | ||||
-rw-r--r-- | mppa_k1c/PostpassSchedulingOracle.ml | 2 |
2 files changed, 35 insertions, 8 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 |