|
1 | 1 | module application_generator_m |
2 | 2 | use application_m, only: application_t |
| 3 | + use dag_m, only : dag_t |
| 4 | + use iso_varying_string, only: varying_string, operator(//), put_line, var_str |
| 5 | + use payload_m, only: payload_t |
| 6 | + use strff, only: to_string |
| 7 | + use task_payload_map_m, only: task_payload_map_t |
| 8 | + use task_m, only: task_t |
| 9 | + use task_item_m, only: task_item_t |
| 10 | + use vertex_m, only : vertex_t |
| 11 | + |
3 | 12 | implicit none |
4 | 13 | private |
5 | 14 | public :: generate_application |
6 | 15 |
|
| 16 | + type, extends(task_t) :: compile_task_t |
| 17 | + type(varying_string) :: to_compile |
| 18 | + contains |
| 19 | + procedure :: execute => compile_task_execute |
| 20 | + end type |
7 | 21 | contains |
8 | 22 | function generate_application() result(application) |
9 | 23 | type(application_t) :: application |
10 | 24 |
|
11 | | - associate(unused => application) |
| 25 | + character(len=*), parameter :: longest_name = "app_generator_m" |
| 26 | + character(len=len(longest_name)), parameter :: names(*) = & |
| 27 | + [ character(len=len(longest_name)) :: "assert_m" & |
| 28 | + , "dag_m" & |
| 29 | + , "payload_m" & |
| 30 | + , "compile_m" & |
| 31 | + , "data_loc_map_m" & |
| 32 | + , "task_m" & |
| 33 | + , "task_item_m" & |
| 34 | + , "app_m" & |
| 35 | + , "app_generator_m" & |
| 36 | + , "image_m" & |
| 37 | + , "main" & |
| 38 | + , "task_item_s" & |
| 39 | + , "compile_s" & |
| 40 | + , "app_generator_s" & |
| 41 | + , "data_loc_map_s" & |
| 42 | + , "payload_s" & |
| 43 | + , "app_s" & |
| 44 | + , "mailbox_m" & |
| 45 | + , "image_s" & |
| 46 | + , "final_task_m" & |
| 47 | + , "final_task_s" & |
| 48 | + ] |
| 49 | + associate( & |
| 50 | + assert_m => findloc(names, "assert_m", dim=1) & |
| 51 | + , dag_m => findloc(names, "dag_m", dim=1) & |
| 52 | + , payload_m => findloc(names, "payload_m", dim=1) & |
| 53 | + , compile_m => findloc(names, "compile_m", dim=1) & |
| 54 | + , data_loc_map_m => findloc(names, "data_loc_map_m", dim=1) & |
| 55 | + , task_m => findloc(names, "task_m", dim=1) & |
| 56 | + , task_item_m => findloc(names, "task_item_m", dim=1) & |
| 57 | + , app_m => findloc(names, "app_m", dim=1) & |
| 58 | + , app_generator_m => findloc(names, "app_generator_m", dim=1) & |
| 59 | + , image_m => findloc(names, "image_m", dim=1) & |
| 60 | + , main => findloc(names, "main", dim=1) & |
| 61 | + , task_item_s => findloc(names, "task_item_s", dim=1) & |
| 62 | + , compile_s => findloc(names, "compile_s", dim=1) & |
| 63 | + , app_generator_s => findloc(names, "app_generator_s", dim=1) & |
| 64 | + , data_loc_map_s => findloc(names, "data_loc_map_s", dim=1) & |
| 65 | + , payload_s => findloc(names, "payload_s", dim=1) & |
| 66 | + , app_s => findloc(names, "app_s", dim=1) & |
| 67 | + , mailbox_m => findloc(names, "mailbox_m", dim=1) & |
| 68 | + , image_s => findloc(names, "image_s", dim=1) & |
| 69 | + , final_task_m => findloc(names, "final_task_m", dim=1) & |
| 70 | + , final_task_s => findloc(names, "final_task_s", dim=1) & |
| 71 | + ) |
| 72 | + |
| 73 | + block |
| 74 | + character(len=*), parameter :: external_ = 'shape=square,fillcolor="green",style=filled' |
| 75 | + character(len=*), parameter :: root = 'shape=circle,fillcolor="white",style=filled' |
| 76 | + character(len=*), parameter :: branch = 'shape=square,fillcolor="SlateGray1",style=filled' |
| 77 | + character(len=len(branch)), parameter :: leaf = 'shape=circle,fillcolor="cornsilk",style=filled' |
| 78 | + type(dag_t) feats |
| 79 | + integer i |
| 80 | + type(varying_string) name_string(size(names)) |
| 81 | + type(task_item_t), allocatable :: tasks(:) |
| 82 | + |
| 83 | + name_string = var_str(names) |
| 84 | + |
| 85 | + feats = & |
| 86 | + dag_t([ & |
| 87 | + vertex_t([integer::], name_string(assert_m), var_str(external_)) & |
| 88 | + , vertex_t([integer:: ], name_string(dag_m), var_str(external_)) & |
| 89 | + , vertex_t([integer::], name_string(payload_m), var_str(leaf) ) & |
| 90 | + , vertex_t([integer:: ], name_string(compile_m), var_str(leaf) ) & |
| 91 | + , vertex_t([integer::], name_string(data_loc_map_m), var_str(leaf) ) & |
| 92 | + , vertex_t([payload_m], name_string(task_m), var_str(branch) ) & |
| 93 | + , vertex_t([task_m], name_string(task_item_m), var_str(leaf) ) & |
| 94 | + , vertex_t([dag_m, task_item_m], name_string(app_m), var_str(branch) ) & |
| 95 | + , vertex_t([app_m, dag_m, task_item_m, compile_m], name_string(app_generator_m), var_str(branch) ) & |
| 96 | + , vertex_t([app_m, data_loc_map_m], name_string(image_m), var_str(branch) ) & |
| 97 | + , vertex_t([app_generator_m, image_m], name_string(main), var_str(root) ) & |
| 98 | + , vertex_t([task_item_m], name_string(task_item_s), var_str(root) ) & |
| 99 | + , vertex_t([compile_m], name_string(compile_s), var_str(branch) ) & |
| 100 | + , vertex_t([app_generator_m], name_string(app_generator_s), var_str(root) ) & |
| 101 | + , vertex_t([data_loc_map_m], name_string(data_loc_map_s), var_str(root) ) & |
| 102 | + , vertex_t([payload_m], name_string(payload_s), var_str(root) ) & |
| 103 | + , vertex_t([app_m, assert_m], name_string(app_s), var_str(root) ) & |
| 104 | + , vertex_t([payload_m], name_string(mailbox_m), var_str(branch) ) & |
| 105 | + , vertex_t([image_m, mailbox_m], name_string(image_s), var_str(root) ) & |
| 106 | + , vertex_t([data_loc_map_m, payload_m, task_m], name_string(final_task_m), var_str(branch) ) & |
| 107 | + , vertex_t([final_task_m], name_string(final_task_s), var_str(root) ) & |
| 108 | + ]) |
| 109 | + tasks = [(task_item_t(compile_task_t(name_string(i))), i = 1, size(names))] |
| 110 | + application = application_t(feats, tasks) |
| 111 | + end block |
12 | 112 | end associate |
13 | 113 | end function |
| 114 | + |
| 115 | + function compile_task_execute(self, task_number, upstream_task_results) result(output) |
| 116 | + class(compile_task_t), intent(in) :: self |
| 117 | + integer, intent(in) :: task_number |
| 118 | + type(task_payload_map_t), intent(in) :: upstream_task_results |
| 119 | + type(payload_t) :: output |
| 120 | + |
| 121 | + call put_line("Executing task number: " // to_string(task_number)) |
| 122 | + call put_line("Compiling: " // self%to_compile) |
| 123 | + end function |
14 | 124 | end module |
0 commit comments