diff src/parallel_execution/context.h @ 236:865179a0a56d

fix taskManager
author ikkun
date Mon, 23 Jan 2017 20:00:46 +0900
parents 47588c28f189
children 6f6cc49213c5
line wrap: on
line diff
--- a/src/parallel_execution/context.h	Mon Jan 23 17:49:36 2017 +0900
+++ b/src/parallel_execution/context.h	Mon Jan 23 20:00:46 2017 +0900
@@ -14,13 +14,15 @@
 #define ALLOC_DATA(context, dseg) ({\
     struct Meta* meta = (struct Meta*)context->heap;\
     meta->type = D_##dseg;\
+    meta->size = 1;\
     context->heap += sizeof(struct Meta);\
     context->data[D_##dseg] = context->heap; context->heap += sizeof(struct dseg); (struct dseg *)context->data[D_##dseg]; })
 
 #define ALLOC_DATA_TYPE(context, dseg, t) ({\
     struct Meta* meta = (struct Meta*)context->heap;\
     meta->type = D_##t;\
-    context->heap += sizeof(struct Meta);\
+    meta->size = 1;\
+    context->heap += sizeof(struct Meta);                               \
     context->data[D_##dseg] = context->heap; context->heap += sizeof(struct t); (struct t *)context->data[D_##dseg]; })
 
 #define ALLOCATE(context, t) ({ \
@@ -29,10 +31,20 @@
     union Data* data = context->heap; \
     context->heap += sizeof(struct t); \
     meta->type = D_##t; \
+    meta->size = 1;     \
     data; })
 
 #define ALLOC(context, t) (&ALLOCATE(context, t)->t)
 
+#define ALLOC_ARRY(context, dseg, size) ({\
+    struct Meta* meta = (struct Meta*)context->heap;\
+    context->heap += sizeof(struct Meta);\
+    union Data* data = context->heap; \
+    context->heap += sizeof(struct t)*size; \
+    meta->type = D_##dseg; \
+    meta->size = size; \
+    data; })
+
 #define GET_TYPE(dseg) ({ \
     struct Meta* meta = (struct Meta*)(((void*)dseg) - sizeof(struct Meta));\
     meta->type; })
@@ -62,14 +74,15 @@
     void* heapStart;
     void* heap;
     long heapLimit;
-    int thread_num;
     int dataNum;
+    int idgCount; //number of waiting dataGear
     union Data **data;
 };
 
 union Data {
     struct Meta {
         enum DataType type;
+        long size;
         struct Queue* wait; // tasks waiting this dataGear
     } meta;
     struct Context context;
@@ -112,8 +125,6 @@
         struct Context* context;
         int id;
         struct Queue* tasks;
-        int runFlag;
-        enum Code next;
     } CPUWorker;
 #ifdef USE_CUDA
     struct CudaWorker {