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