Debian Codegraph @

lib/mlrisc-lib/MLRISC/scheduling/wuhui.sml

raw
1 (*
2 * This is Wu Hui's example.
3 *)
4
5 structure WuHui =
6 struct
7
8 structure G = DirectedGraph
9
10 fun makeDag nodes edges =
11 let val dag as Graph.GRAPH G = G.graph("Test1",(),10)
12 in app (#add_node G) nodes;
13 app (#add_edge G) edges;
14 dag
15 end
16
17 val dag as Graph.GRAPH G =
18 makeDag [(1,(0,6)),
19 (2,(0,6)),
20 (3,(1,6)),
21 (4,(1,6)),
22 (5,(1,6)),
23 (6,(3,6))
24 ]
25 [(1,3,1),
26 (1,4,1),
27 (2,4,1),
28 (2,5,1),
29 (3,6,0),
30 (4,6,1),
31 (5,6,1)
32 ]
33
34 fun close dag =
35 TransitiveClosure.acyclic_transitive_closure2
36 {+ = fn(i,j) => i+j+1,
37 max = Int.max
38 } dag
39
40 fun leung (dag as Graph.GRAPH G) =
41 let val dag' as Graph.GRAPH G' = G.graph("Tmp",(),10)
42 val _ = #forall_nodes G (#add_node G')
43 val _ = #forall_edges G (#add_edge G')
44 in LeungPalemPnueli.rank
45 {dag = dag',
46 l = fn(_,_,l) => l,
47 d = fn(_,(_,d)) => d,
48 r = fn(_,(r,_)) => r,
49 m = 1
50 }
51 end
52
53 structure View = GraphViewerFn(daVinci)
54 structure L = GraphLayout
55
56 fun view dag =
57 View.view(
58 L.makeLayout{node=fn(n,(r,d))=>
59 [L.LABEL(Int.toString n^" r="^Int.toString r^
60 " d="^Int.toString d)
61 ],
62 edge=fn(i,j,l)=>[L.LABEL(Int.toString l),L.COLOR "red"],
63 graph=fn _ =>[]} dag
64 )
65
66 end