changeset 434:b75badf42701

Define Executor to context
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 31 Oct 2017 17:55:50 +0900
parents d920f3a3f037
children af0ec811b20e
files src/parallel_execution/context.h src/parallel_execution/examples/bitonicSort/bitonicSwap.cbc
diffstat 2 files changed, 43 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/context.h	Tue Oct 17 15:47:33 2017 +0900
+++ b/src/parallel_execution/context.h	Tue Oct 31 17:55:50 2017 +0900
@@ -12,60 +12,60 @@
 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
 
 #define ALLOC_DATA(context, dseg) ({\
-    struct Meta* meta = (struct Meta*)context->heap;\
+    Meta* meta = (Meta*)context->heap;\
     meta->type = D_##dseg;\
-    meta->size = sizeof(struct dseg);\
+    meta->size = sizeof(dseg);\
     meta->len = 1;\
-    context->heap += sizeof(struct Meta);\
-    context->data[D_##dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[D_##dseg]; })
+    context->heap += sizeof(Meta);\
+    context->data[D_##dseg] = context->heap; context->heap += sizeof(dseg); (dseg *)context->data[D_##dseg]; })
 
 #define ALLOC_DATA_TYPE(context, dseg, t) ({\
-    struct Meta* meta = (struct Meta*)context->heap;\
+    Meta* meta = (Meta*)context->heap;\
     meta->type = D_##t;\
-    meta->size = sizeof(struct t);\
+    meta->size = sizeof(t);\
     meta->len = 1;\
-    context->heap += sizeof(struct Meta);\
-    context->data[D_##dseg] = context->heap; context->heap += sizeof(struct t); (struct t *)context->data[D_##dseg]; })
+    context->heap += sizeof(Meta);\
+    context->data[D_##dseg] = context->heap; context->heap += sizeof(t); (t *)context->data[D_##dseg]; })
 
 #define ALLOCATE(context, t) ({ \
-    struct Meta* meta = (struct Meta*)context->heap;\
-    context->heap += sizeof(struct Meta);\
+    Meta* meta = (Meta*)context->heap;\
+    context->heap += sizeof(Meta);\
     union Data* data = context->heap; \
-    context->heap += sizeof(struct t); \
+    context->heap += sizeof(t); \
     meta->type = D_##t; \
-    meta->size = sizeof(struct t);     \
+    meta->size = sizeof(t);     \
     meta->len = 1;\
     data; })
 
 #define ALLOCATE_ARRAY(context, t, length) ({ \
-    struct Meta* meta = (struct Meta*)context->heap;\
-    context->heap += sizeof(struct Meta);\
+    Meta* meta = (Meta*)context->heap;\
+    context->heap += sizeof(Meta);\
     union Data* data = context->heap; \
-    context->heap += sizeof(struct t)*length; \
+    context->heap += sizeof(t)*length; \
     meta->type = D_##t; \
-    meta->size = sizeof(struct t)*length; \
+    meta->size = sizeof(t)*length; \
     meta->len = length; \
     data;   })
 
 #define ALLOCATE_PTR_ARRAY(context, dseg, length) ({\
-    struct Meta* meta = (struct Meta*)context->heap;\
-    context->heap += sizeof(struct Meta);\
+    Meta* meta = (Meta*)context->heap;\
+    context->heap += sizeof(Meta);\
     union Data* data = context->heap; \
-    context->heap += sizeof(struct dseg *)*length; \
+    context->heap += sizeof(dseg *)*length; \
     meta->type = D_##dseg; \
-    meta->size = sizeof(struct dseg *)*length; \
+    meta->size = sizeof(dseg *)*length; \
     meta->len = length; \
     data; })
 
 #define ALLOCATE_DATA_GEAR(context, t) ({ \
         union Data* data = ALLOCATE(context, t); \
-        struct Meta* meta = GET_META(data); \
+        Meta* meta = GET_META(data); \
         meta->wait = createSingleLinkedQueue(context); \
         data; })
 
 #define ALLOC(context, t) (&ALLOCATE(context, t)->t)
 
-#define GET_META(dseg) ((struct Meta*)(((void*)dseg) - sizeof(struct Meta)))
+#define GET_META(dseg) ((Meta*)(((void*)dseg) - sizeof(Meta)))
 #define GET_TYPE(dseg) (GET_META(dseg)->type)
 #define GET_SIZE(dseg) (GET_META(dseg)->size)
 #define GET_LEN(dseg) (GET_META(dseg)->len)
@@ -73,7 +73,7 @@
 
 #define Gearef(context, t) (&(context)->data[D_##t]->t)
 
-// (struct SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack
+// (SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack
 
 #define GearImpl(context, intf, name) (Gearef(context, intf)->name->intf.name) 
 
@@ -345,13 +345,30 @@
         int y;
         int z;
     } MultiDim;
-    struct CudaBuffer {
+    struct Executor {
+        struct Executor* executor;
+        struct Context* task;
+        struct Buffer* buffer;
+        enum Code read;
+        enum Code exec;
+        enum Code write;
+        enum Code next;
+    } Executor;
+#ifdef USE_CUDAWorker
+    struct CudaExecutor {
         void** kernelParams;
+    } CudaExecutor;
+    CudaDevicePtr CudaDevicePtr;
+#else
+    struct CudaExecutor {
+    } CudaExecutor;
+#endif
+    struct Buffer {
         int inputLen;
         int outputLen;
         union Data** inputData;
         union Data** outputData;
-    } CudaBuffer;
+    } Buffer;
 }; // union Data end       this is necessary for context generator
 
 typedef union Data Data;
--- a/src/parallel_execution/examples/bitonicSort/bitonicSwap.cbc	Tue Oct 17 15:47:33 2017 +0900
+++ b/src/parallel_execution/examples/bitonicSort/bitonicSwap.cbc	Tue Oct 31 17:55:50 2017 +0900
@@ -1,10 +1,6 @@
 #include "../../../context.h"
 #include <stdio.h>
 
-#ifdef USE_CUDAWorker
-extern void cudaExec(struct Context* context, struct CudaBuffer* buffer, char* filename, char* function);
-#endif
-
 __code bitonicSwap(struct SortArray* inputArray, struct MultiDim* multiDim, __code next(struct SortArray* output, ...), struct LoopCounter* loopCounter) {
     struct SortArray* output = *O_output;
     int block = inputArray->block;
@@ -34,7 +30,7 @@
     if (context->gpu) {
         struct SortArray* inputSortArray  = &context->data[context->idg]->SortArray;
         struct SortArray* outputSortArray = &context->data[context->odg]->SortArray;
-        struct CudaBuffer* buffer = &ALLOCATE(context, CudaBuffer)->CudaBuffer;
+        struct Buffer* buffer = &ALLOCATE(context, Buffer)->Buffer;
         buffer->inputData = (union Data**)ALLOCATE_PTR_ARRAY(context, SortArray, 2);
         buffer->inputData[0] = (union Data*)inputSortArray->array;
         buffer->inputData[1] = (union Data*)inputSortArray;