Debian Codegraph @

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

raw
1 (*
2 * This is the example I used in the PACT '98 paper
3 *)
4
5 structure Test2 =
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 = makeDag [(1,(0,2)),
18 (2,(1,2)),
19 (3,(0,9)),
20 (4,(0,9)),
21 (5,(0,7)),
22 (6,(0,9)),
23 (7,(6,9)),
24 (8,(6,8))
25 ]
26 [(1,2,0),
27 (1,4,0),
28 (2,3,0),
29 (2,5,0),
30 (4,3,1),
31 (4,5,1),
32 (3,6,1),
33 (7,6,0)
34 ]
35
36 fun close dag =
37 TransitiveClosure.acyclic_transitive_closure2
38 {+ = fn(i,j) => i+j+1,
39 max = Int.max
40 } dag
41
42 fun leung (dag as Graph.GRAPH G) =
43 let val dag' as Graph.GRAPH G' = G.graph("Tmp",(),10)
44 val _ = #forall_nodes G (#add_node G')
45 val _ = #forall_edges G (#add_edge G')
46 in LeungPalemPnueli.rank
47 {dag = dag',
48 l = fn(_,_,l) => l,
49 d = fn(_,(_,d)) => d,
50 r = fn(_,(r,_)) => r,
51 m = 1
52 }
53 end
54
55 structure View = GraphViewerFn(daVinci)
56 structure L = GraphLayout
57
58 fun view dag =
59 View.view(
60 L.makeLayout{node=fn(n,(r,d))=>
61 [L.LABEL(Int.toString n^" r="^Int.toString r^
62 " d="^Int.toString d)
63 ],
64 edge=fn(i,j,l)=>[L.LABEL(Int.toString l),L.COLOR "red"],
65 graph=fn _ =>[]} dag
66 )
67
68 end