forked from jacobwilliams/daglib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdag-to-dot.f90
91 lines (86 loc) · 5.64 KB
/
dag-to-dot.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
program dag_to_dot
!! Demonstrate the construction of a complex DAG, the generation of a Graphviz
!! .dot file suitable for conversion to Portable Document Format (PDF). The
!! DAG in this example represents the module dependencies in an early version
!! of the Framework for Exensible Asynchronous Task Scheduling (FEATS).
!! See https://github.com/sourceryinstitute/feats.
!!
!! Compile and run this program by executing the following command
!! with your present working directory set to the top-level directory
!! in the DAG source tree:
!!
!! fpm run --example dag-to-dot > feats.dot
!! dot -Tpdf -o feats.pdf feats.dot
!!
!! where the latter command produces a PDF file if Graphviz has been installed.
!!
use dag_m, only : dag_t
use vertex_m, only : vertex_t
use iso_varying_string, only : var_str, varying_string
implicit none
character(len=*), parameter :: longest_name = "app_generator_m"
character(len=len(longest_name)), parameter :: names(*) = &
[character(len=len(longest_name)) :: &
"assert_m", "dag_m", "payload_m", "compile_m", "data_loc_map_m", "task_m", "task_item_m", "app_m", "app_generator_m" &
,"image_m", "main", "task_item_s", "compile_s", "app_generator_s", "data_loc_map_s", "payload_s", "app_s", "mailbox_m" &
,"image_s", "final_task_m", "final_task_s" &
]
associate( &
assert_m => findloc(names, "assert_m", dim=1) &
,dag_m => findloc(names, "dag_m", dim=1) &
,payload_m => findloc(names, "payload_m", dim=1) &
,compile_m => findloc(names, "compile_m", dim=1) &
,data_loc_map_m => findloc(names, "data_loc_map_m", dim=1) &
,task_m => findloc(names, "task_m", dim=1) &
,task_item_m => findloc(names, "task_item_m", dim=1) &
,app_m => findloc(names, "app_m", dim=1) &
,app_generator_m => findloc(names, "app_generator_m", dim=1) &
,image_m => findloc(names, "image_m", dim=1) &
,main => findloc(names, "main", dim=1) &
,task_item_s => findloc(names, "task_item_s", dim=1) &
,compile_s => findloc(names, "compile_s", dim=1) &
,app_generator_s => findloc(names, "app_generator_s", dim=1) &
,data_loc_map_s => findloc(names, "data_loc_map_s", dim=1) &
,payload_s => findloc(names, "payload_s", dim=1) &
,app_s => findloc(names, "app_s", dim=1) &
,mailbox_m => findloc(names, "mailbox_m", dim=1) &
,image_s => findloc(names, "image_s", dim=1) &
,final_task_m => findloc(names, "final_task_m", dim=1) &
,final_task_s => findloc(names, "final_task_s", dim=1) &
)
block
character(len=*), parameter :: external_ = 'shape=square,fillcolor="green",style=filled'
character(len=*), parameter :: root = 'shape=circle,fillcolor="white",style=filled'
character(len=*), parameter :: branch = 'shape=square,fillcolor="SlateGray1",style=filled'
character(len=len(branch)), parameter :: leaf = 'shape=circle,fillcolor="cornsilk",style=filled'
type(dag_t) feats
type(varying_string) name_string(size(names))
name_string = var_str(names)
feats = &
dag_t([ &
vertex_t([integer::], name_string(assert_m), var_str(external_)) &
,vertex_t([integer:: ], name_string(dag_m), var_str(external_)) &
,vertex_t([integer::], name_string(payload_m), var_str(leaf) ) &
,vertex_t([integer:: ], name_string(compile_m), var_str(leaf) ) &
,vertex_t([integer::], name_string(data_loc_map_m), var_str(leaf) ) &
,vertex_t([payload_m], name_string(task_m), var_str(branch) ) &
,vertex_t([task_m], name_string(task_item_m), var_str(leaf) ) &
,vertex_t([dag_m, task_item_m], name_string(app_m), var_str(branch) ) &
,vertex_t([app_m, dag_m, task_item_m, compile_m], name_string(app_generator_m), var_str(branch) ) &
,vertex_t([app_m, data_loc_map_m], name_string(image_m), var_str(branch) ) &
,vertex_t([app_generator_m, image_m], name_string(main), var_str(root) ) &
,vertex_t([task_item_m], name_string(task_item_s), var_str(root) ) &
,vertex_t([compile_m], name_string(compile_s), var_str(branch) ) &
,vertex_t([app_generator_m], name_string(app_generator_s), var_str(root) ) &
,vertex_t([data_loc_map_m], name_string(data_loc_map_s), var_str(root) ) &
,vertex_t([payload_m], name_string(payload_s), var_str(root) ) &
,vertex_t([app_m, assert_m], name_string(app_s), var_str(root) ) &
,vertex_t([payload_m], name_string(mailbox_m), var_str(branch) ) &
,vertex_t([image_m, mailbox_m], name_string(image_s), var_str(root) ) &
,vertex_t([data_loc_map_m, payload_m, task_m], name_string(final_task_m), var_str(branch) ) &
,vertex_t([final_task_m], name_string(final_task_s), var_str(root) ) &
])
print *, feats%graphviz_digraph()
end block
end associate
end program