dol: initial dol commit
[jump.git] / dol / src / dol / visitor / hds / lib / dolSupport.h
1 #ifndef DOLSUPPORT_H\r
2 #define DOLSUPPORT_H\r
3 \r
4 #include "dol.h"\r
5 #include "Fifo.h"\r
6 #include "functional_trace.h"\r
7 #include "Performance_Extraction.h"\r
8 \r
9 #ifdef INCLUDE_PERFORMANCE\r
10 #define DOL_write(port, buf, len, process) {\\r
11     (static_cast<ProcessWrapper *>(p->wptr))->end_line = __LINE__;\\r
12     get_current_time(&((static_cast<ProcessWrapper *>(p->wptr))->\\r
13     end_time));\\r
14     performance_extraction.add_computation_performance(\\r
15     (static_cast<ProcessWrapper *>(p->wptr))->basename(),\\r
16     (static_cast<ProcessWrapper *>(p->wptr))->start_line,\\r
17     (static_cast<ProcessWrapper *>(p->wptr))->end_line,\\r
18     &((static_cast<ProcessWrapper *>(p->wptr))->start_time),\\r
19     &((static_cast<ProcessWrapper *>(p->wptr))->end_time));\\r
20     write(port, buf, len, process);\\r
21     (static_cast<ProcessWrapper *>(p->wptr))->start_line = __LINE__;\\r
22     get_current_time(&((static_cast<ProcessWrapper *>(p->wptr))->\\r
23     start_time)); }\r
24 #define DOL_read(port, buf, len, process) {\\r
25     (static_cast<ProcessWrapper *>(p->wptr))->end_line = __LINE__;\\r
26     get_current_time(&((static_cast<ProcessWrapper *>(p->wptr))->\\r
27     end_time));\\r
28     performance_extraction.add_computation_performance(\\r
29     (static_cast<ProcessWrapper *>(p->wptr))->basename(),\\r
30     (static_cast<ProcessWrapper *>(p->wptr))->start_line,\\r
31     (static_cast<ProcessWrapper *>(p->wptr))->end_line,\\r
32     &((static_cast<ProcessWrapper *>(p->wptr))->start_time),\\r
33     &((static_cast<ProcessWrapper *>(p->wptr))->end_time));\\r
34     read(port, buf, len, process);\\r
35     (static_cast<ProcessWrapper *>(p->wptr))->start_line = __LINE__;\\r
36     get_current_time(&((static_cast<ProcessWrapper *>(p->wptr))->\\r
37     start_time)); }\r
38 #elif INCLUDE_TRACE\r
39 #define DOL_write(port, buf, len, process) {\\r
40     (static_cast<ProcessWrapper *>(p->wptr))->end_line = __LINE__;\\r
41     dol_functional_trace.create_computation_event(\\r
42     (static_cast<ProcessWrapper *>(p->wptr))->basename(),\\r
43     (static_cast<ProcessWrapper *>(p->wptr))->start_line,\\r
44     (static_cast<ProcessWrapper *>(p->wptr))->end_line);\\r
45     write(port, buf, len, process);\\r
46     dol_functional_trace.create_write_event(\\r
47     (static_cast<ProcessWrapper *>(p->wptr))->basename(), len,\\r
48     (static_cast<ProcessWrapper *>(p->wptr))->channel_name);\\r
49     (static_cast<ProcessWrapper *>(p->wptr))->start_line = __LINE__; }\r
50 #define DOL_read(port, buf, len, process) {\\r
51     (static_cast<ProcessWrapper *>(p->wptr))->end_line = __LINE__;\\r
52     dol_functional_trace.create_computation_event(\\r
53     (static_cast<ProcessWrapper *>(p->wptr))->basename(),\\r
54     (static_cast<ProcessWrapper *>(p->wptr))->start_line,\\r
55     (static_cast<ProcessWrapper *>(p->wptr))->end_line);\\r
56     read(port, buf, len, process);\\r
57     dol_functional_trace.create_read_event(\\r
58     (static_cast<ProcessWrapper *>(p->wptr))->basename(), len,\\r
59     (static_cast<ProcessWrapper *>(p->wptr))->channel_name);\\r
60     (static_cast<ProcessWrapper *>(p->wptr))->start_line = __LINE__; }\r
61 #else\r
62     #define DOL_write(port, buf, len, process) \\r
63     write(port, buf, len, process)\r
64     #define DOL_read(port, buf, len, process) \\r
65     read(port, buf, len, process)\r
66 #endif\r
67 \r
68 #define DOL_reserve(port, buf, size, process) \\r
69     reserve(port, (void**)buf, size, process);\r
70 \r
71 #define DOL_release(port, process) \\r
72     release(port, process);\r
73 \r
74 #define DOL_capture(port, buf, size, process) \\r
75     capture(port, (void**)buf, size, process);\r
76 \r
77 #define DOL_consume(port, process) \\r
78     consume(port, process);\r
79 \r
80 #define DOL_wtest(port, len, process) wtest(port, len, process)\r
81 \r
82 #define DOL_rtest(port, len, process) rtest(port, len, process)\r
83 \r
84 void DOL_detach(DOLProcess* p);\r
85 \r
86 //fifo access functions\r
87 unsigned write(void* fifo, void* buf, unsigned len, DOLProcess* p);\r
88 unsigned read(void* fifo, void* buf, unsigned len, DOLProcess* p);\r
89 int wtest(void *port, unsigned len, DOLProcess *process);\r
90 int rtest(void *port, unsigned len, DOLProcess *process);\r
91 \r
92 //windowed fifo access functions\r
93 unsigned reserve(void* fifo, void** destination, unsigned len, DOLProcess* p);\r
94 void release(void* fifo, DOLProcess* p);\r
95 unsigned capture(void* fifo, void** destination, unsigned len, DOLProcess* p);\r
96 void consume(void* fifo, DOLProcess* p);\r
97 \r
98 \r
99 void createPort(void **port,\r
100                 void *base,\r
101                 int number_of_indices,\r
102                 int index0, int range0);\r
103 \r
104 void createPort(void **port,\r
105                 void *base,\r
106                 int number_of_indices,\r
107                 int index0, int range0,\r
108                 int index1, int range1);\r
109 \r
110 void createPort(void **port,\r
111                 void *base,\r
112                 int number_of_indices,\r
113                 int index0, int range0,\r
114                 int index1, int range1,\r
115                 int index2, int range2);\r
116 \r
117 void createPort(void **port,\r
118                 void *base,\r
119                 int number_of_indices,\r
120                 int index0, int range0,\r
121                 int index1, int range1,\r
122                 int index2, int range2,\r
123                 int index3, int range3);\r
124 \r
125 #define GETINDEX(dimension) \\r
126   static_cast<ProcessWrapper *>(p->wptr)->getIndex(dimension)\r
127 \r
128 /**\r
129  * macro to create a variable to store a port name\r
130  *\r
131  * @param name name of the variable\r
132  */\r
133 #define CREATEPORTVAR(name) Fifo *name\r
134 \r
135 /**\r
136  * Create the port name of an iterated port based on its basename and the\r
137  * given indices.\r
138  *\r
139  * @param port buffer where the result is stored (created using\r
140  *             CREATEPORTVAR)\r
141  * @param base basename of the port\r
142  * @param number_of_indices number of dimensions of the port\r
143  * @param index_range_pairs index and range values for each dimension\r
144  */\r
145 #define CREATEPORT(port, base, number_of_indices, index_range_pairs...) \\r
146   createPort((void**)(&port), base, number_of_indices, index_range_pairs)\r
147 \r
148 #endif\r