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.
This commit is contained in:
Gwenaël Delaval 2012-07-26 01:29:22 +02:00
parent 5ed07e1e5a
commit 90dda27a3a
2 changed files with 17 additions and 4 deletions

View file

@ -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

View file

@ -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