dol: initial dol commit
[jump.git] / dol / src / dol / visitor / hds / lib / dolSupport.h
diff --git a/dol/src/dol/visitor/hds/lib/dolSupport.h b/dol/src/dol/visitor/hds/lib/dolSupport.h
new file mode 100644 (file)
index 0000000..5f0505c
--- /dev/null
@@ -0,0 +1,148 @@
+#ifndef DOLSUPPORT_H\r
+#define DOLSUPPORT_H\r
+\r
+#include "dol.h"\r
+#include "Fifo.h"\r
+#include "functional_trace.h"\r
+#include "Performance_Extraction.h"\r
+\r
+#ifdef INCLUDE_PERFORMANCE\r
+#define DOL_write(port, buf, len, process) {\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->end_line = __LINE__;\\r
+    get_current_time(&((static_cast<ProcessWrapper *>(p->wptr))->\\r
+    end_time));\\r
+    performance_extraction.add_computation_performance(\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->basename(),\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->start_line,\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->end_line,\\r
+    &((static_cast<ProcessWrapper *>(p->wptr))->start_time),\\r
+    &((static_cast<ProcessWrapper *>(p->wptr))->end_time));\\r
+    write(port, buf, len, process);\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->start_line = __LINE__;\\r
+    get_current_time(&((static_cast<ProcessWrapper *>(p->wptr))->\\r
+    start_time)); }\r
+#define DOL_read(port, buf, len, process) {\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->end_line = __LINE__;\\r
+    get_current_time(&((static_cast<ProcessWrapper *>(p->wptr))->\\r
+    end_time));\\r
+    performance_extraction.add_computation_performance(\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->basename(),\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->start_line,\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->end_line,\\r
+    &((static_cast<ProcessWrapper *>(p->wptr))->start_time),\\r
+    &((static_cast<ProcessWrapper *>(p->wptr))->end_time));\\r
+    read(port, buf, len, process);\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->start_line = __LINE__;\\r
+    get_current_time(&((static_cast<ProcessWrapper *>(p->wptr))->\\r
+    start_time)); }\r
+#elif INCLUDE_TRACE\r
+#define DOL_write(port, buf, len, process) {\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->end_line = __LINE__;\\r
+    dol_functional_trace.create_computation_event(\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->basename(),\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->start_line,\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->end_line);\\r
+    write(port, buf, len, process);\\r
+    dol_functional_trace.create_write_event(\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->basename(), len,\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->channel_name);\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->start_line = __LINE__; }\r
+#define DOL_read(port, buf, len, process) {\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->end_line = __LINE__;\\r
+    dol_functional_trace.create_computation_event(\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->basename(),\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->start_line,\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->end_line);\\r
+    read(port, buf, len, process);\\r
+    dol_functional_trace.create_read_event(\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->basename(), len,\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->channel_name);\\r
+    (static_cast<ProcessWrapper *>(p->wptr))->start_line = __LINE__; }\r
+#else\r
+    #define DOL_write(port, buf, len, process) \\r
+    write(port, buf, len, process)\r
+    #define DOL_read(port, buf, len, process) \\r
+    read(port, buf, len, process)\r
+#endif\r
+\r
+#define DOL_reserve(port, buf, size, process) \\r
+    reserve(port, (void**)buf, size, process);\r
+\r
+#define DOL_release(port, process) \\r
+    release(port, process);\r
+\r
+#define DOL_capture(port, buf, size, process) \\r
+    capture(port, (void**)buf, size, process);\r
+\r
+#define DOL_consume(port, process) \\r
+    consume(port, process);\r
+\r
+#define DOL_wtest(port, len, process) wtest(port, len, process)\r
+\r
+#define DOL_rtest(port, len, process) rtest(port, len, process)\r
+\r
+void DOL_detach(DOLProcess* p);\r
+\r
+//fifo access functions\r
+unsigned write(void* fifo, void* buf, unsigned len, DOLProcess* p);\r
+unsigned read(void* fifo, void* buf, unsigned len, DOLProcess* p);\r
+int wtest(void *port, unsigned len, DOLProcess *process);\r
+int rtest(void *port, unsigned len, DOLProcess *process);\r
+\r
+//windowed fifo access functions\r
+unsigned reserve(void* fifo, void** destination, unsigned len, DOLProcess* p);\r
+void release(void* fifo, DOLProcess* p);\r
+unsigned capture(void* fifo, void** destination, unsigned len, DOLProcess* p);\r
+void consume(void* fifo, DOLProcess* p);\r
+\r
+\r
+void createPort(void **port,\r
+                void *base,\r
+                int number_of_indices,\r
+                int index0, int range0);\r
+\r
+void createPort(void **port,\r
+                void *base,\r
+                int number_of_indices,\r
+                int index0, int range0,\r
+                int index1, int range1);\r
+\r
+void createPort(void **port,\r
+                void *base,\r
+                int number_of_indices,\r
+                int index0, int range0,\r
+                int index1, int range1,\r
+                int index2, int range2);\r
+\r
+void createPort(void **port,\r
+                void *base,\r
+                int number_of_indices,\r
+                int index0, int range0,\r
+                int index1, int range1,\r
+                int index2, int range2,\r
+                int index3, int range3);\r
+\r
+#define GETINDEX(dimension) \\r
+  static_cast<ProcessWrapper *>(p->wptr)->getIndex(dimension)\r
+\r
+/**\r
+ * macro to create a variable to store a port name\r
+ *\r
+ * @param name name of the variable\r
+ */\r
+#define CREATEPORTVAR(name) Fifo *name\r
+\r
+/**\r
+ * Create the port name of an iterated port based on its basename and the\r
+ * given indices.\r
+ *\r
+ * @param port buffer where the result is stored (created using\r
+ *             CREATEPORTVAR)\r
+ * @param base basename of the port\r
+ * @param number_of_indices number of dimensions of the port\r
+ * @param index_range_pairs index and range values for each dimension\r
+ */\r
+#define CREATEPORT(port, base, number_of_indices, index_range_pairs...) \\r
+  createPort((void**)(&port), base, number_of_indices, index_range_pairs)\r
+\r
+#endif\r