From 90dda27a3a0dce2fa2790011eff3ed3992154090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwena=C3=ABl=20Delaval?= Date: Thu, 26 Jul 2012 01:29:22 +0200 Subject: [PATCH] Bug correction in Schedule_interf Bug due to the fact that a variable can be "defined" and "read" (in scheduling sense) by the same equation, without being a memory: e.g., a clock defined as the result of a node application, together with another result on this same clock. Bug correction: basically removed the "assert false" on killed_vars, decr_uses; do not count as "use" the self reads. --- compiler/minils/mls_utils.ml | 2 +- .../minils/transformations/schedule_interf.ml | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/compiler/minils/mls_utils.ml b/compiler/minils/mls_utils.ml index 3af42f7..dcccee6 100644 --- a/compiler/minils/mls_utils.ml +++ b/compiler/minils/mls_utils.ml @@ -104,7 +104,7 @@ struct let def acc { eq_lhs = pat } = vars_pat acc pat let rec vars_ck acc = function - | Con(_, _, n) -> add n acc + | Con(ck, _, n) -> vars_ck (add n acc) ck | Cbase | Cvar { contents = Cindex _ } -> acc | Cvar { contents = Clink ck } -> vars_ck acc ck diff --git a/compiler/minils/transformations/schedule_interf.ml b/compiler/minils/transformations/schedule_interf.ml index 48f3479..8876025 100644 --- a/compiler/minils/transformations/schedule_interf.ml +++ b/compiler/minils/transformations/schedule_interf.ml @@ -51,7 +51,14 @@ let compute_uses eqs = else Env.add x 1 env in - List.fold_left incr_uses env (Mls_utils.Vars.read false eq) + let reads = Mls_utils.Vars.read false eq in + (* self uses not counted *) + let defs = Mls_utils.Vars.def [] eq in + let reads = + List.fold_left + (fun acc x -> if List.mem x defs then acc else (x::acc)) + [] reads in + List.fold_left incr_uses env reads in List.fold_left aux Env.empty eqs @@ -73,7 +80,8 @@ let decr_uses env x = Env.add x ((Env.find x env) - 1) env with | Not_found -> - Interference.print_debug "Cannot decrease; var not found : %a@." print_ident x; assert false + (* Self use: no decrease for x *) + env module Cost = struct @@ -92,7 +100,8 @@ struct if Env.find x env = 1 then acc + 1 else acc with | Not_found -> - Format.printf "Var not found in kill_vars: %a@." print_ident x; assert false + (* self use of x *) + acc in List.fold_left is_killed 0 (Mls_utils.Vars.read false eq) @@ -172,6 +181,7 @@ let remove_eq eq node_list = (** Main function to schedule a node. *) let schedule eq_list inputs node_list = + (* Compute number of uses of each ident *) let uses = compute_uses eq_list in let rec schedule_aux rem_eqs sched_eqs node_list ck costs = match rem_eqs with @@ -203,8 +213,11 @@ let schedule_contract contract c_inputs = c.c_controllables let node _ () f = + (* Put memory variables into Interference.World.memories *) Interference.World.init f; + (* Schedule contract *) let contract,controllables = schedule_contract f.n_contract (f.n_input@f.n_output) in + (* Build dataflow dependency graph *) let node_list, _ = DataFlowDep.build f.n_equs in (* Controllable variables are considered as inputs *) let f = { f with