summaryrefslogtreecommitdiff
path: root/sched/scheduler.ml
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2013-11-05 18:29:27 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2013-11-05 18:29:27 +0100
commit244a51086c20dbd937dd21f1eb9c4b74acc5a3c9 (patch)
treeef79030aff1f61801f10f7407325076adc6be10a /sched/scheduler.ml
parent07b7563e0748b1aff6f4d28b0172095b2fdcdfcc (diff)
downloadSystDigit-Projet-244a51086c20dbd937dd21f1eb9c4b74acc5a3c9.tar.gz
SystDigit-Projet-244a51086c20dbd937dd21f1eb9c4b74acc5a3c9.zip
More simplifcation passes...
Diffstat (limited to 'sched/scheduler.ml')
-rw-r--r--sched/scheduler.ml23
1 files changed, 18 insertions, 5 deletions
diff --git a/sched/scheduler.ml b/sched/scheduler.ml
index 130164b..34ce3aa 100644
--- a/sched/scheduler.ml
+++ b/sched/scheduler.ml
@@ -21,11 +21,15 @@ let read_exp eq =
| Eslice(_, _, a) -> add_arg a []
| Eselect(_, a) -> add_arg a []
in
- aux eq;;
+ aux eq
-let schedule p =
+let prog_eq_map p =
+ List.fold_left
+ (fun x (vn, eqn) -> Smap.add vn eqn x)
+ Smap.empty p.p_eqs
+
+let prog_graph p eq_map =
let graph = Graph.mk_graph() in
- let eq_map = List.fold_left (fun x (vn, eqn) -> Smap.add vn eqn x) Smap.empty p.p_eqs in
(* Add variables as graph nodes *)
List.iter (fun (k, _) -> Graph.add_node graph k) p.p_eqs;
(* Add dependencies as graph edges *)
@@ -36,17 +40,26 @@ let schedule p =
p.p_eqs;
(* Verify there are no cycles *)
if Graph.has_cycle graph then raise Combinational_cycle;
+ graph
+
+let schedule p =
+ let eq_map = prog_eq_map p in
+ let graph = prog_graph p eq_map in
+
(* Topological sort of graph nodes *)
let topo_vars = Graph.topological graph in
(* Construct new program with sorted expression list *)
{
p_eqs = List.fold_right
- (fun n x -> if Smap.mem n eq_map then (n, Smap.find n eq_map)::x else x) topo_vars [];
+ (fun n x ->
+ if Smap.mem n eq_map then
+ (n, Smap.find n eq_map)::x
+ else x)
+ topo_vars [];
p_inputs = p.p_inputs;
p_outputs = p.p_outputs;
p_vars = p.p_vars;
}
- ;;