comparison src/parallel_execution/context.h @ 232:123b0d277b84

worker interface
author mir3636
date Sun, 22 Jan 2017 19:02:12 +0900
parents a1fb3f2d1a36
children 06133afb3b5b
comparison
equal deleted inserted replaced
231:24da4f217447 232:123b0d277b84
34 #define GET_TYPE(dseg) ({ \ 34 #define GET_TYPE(dseg) ({ \
35 struct Meta* meta = (struct Meta*)(((void*)dseg) - sizeof(struct Meta));\ 35 struct Meta* meta = (struct Meta*)(((void*)dseg) - sizeof(struct Meta));\
36 meta->type; }) 36 meta->type; })
37 37
38 #define Gearef(context, t) (&(context)->data[D_##t]->t) 38 #define Gearef(context, t) (&(context)->data[D_##t]->t)
39
40 // (struct SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack
41
42 #define GearImpl(context, intf, name) (Gearef(context, intf)->name->intf.name)
39 43
40 #include "c/enumCode.h" 44 #include "c/enumCode.h"
41 45
42 enum Relational { 46 enum Relational {
43 EQ, 47 EQ,
89 struct TaskManagerImpl { 93 struct TaskManagerImpl {
90 struct Queue* activeQueue; 94 struct Queue* activeQueue;
91 struct Queue* taskQueue; 95 struct Queue* taskQueue;
92 } TaskManagerImpl; 96 } TaskManagerImpl;
93 struct Worker { 97 struct Worker {
98 union Data* worker;
99 enum Code taskReceive;
100 enum Code shutdown;
101 enum Code next;
102 } Worker;
103 struct CPUWorker {
104 struct Context* context;
94 int id; 105 int id;
95 struct Queue* tasks; 106 struct Queue* tasks;
96 int runFlag; 107 int runFlag;
108 enum Code next;
109 } CPUWorker;
110 #ifdef USE_CUDA
111 struct CudaWorker {
97 struct Context* context; 112 struct Context* context;
98 enum Code taskReceive; 113 int id;
99 enum Code shutdown; 114 struct Queue* tasks;
100 enum Code next; 115 int runFlag;
101 } Worker; 116 enum Code next;
102 #ifdef USE_CUDA
103 struct CudaTask {
104 CUdevice device; 117 CUdevice device;
105 CUcontext cuCtx; 118 CUcontext cuCtx;
106 CUfunction code; 119 CUfunction code;
107 CUdeviceptr* deviceptr; 120 CUdeviceptr* deviceptr;
108 CUstream stream; 121 CUstream stream;
109 } Cudatask; 122 } CudaWorker;
110 #else 123 #else
111 struct CudaTask { 124 struct CudaWorker {
112 enum Code next; 125 } CudaWorker;
113 } Cudatask;
114 #endif 126 #endif
115 struct Main { 127 struct Main {
116 enum Code code; 128 enum Code code;
117 enum Code next; 129 enum Code next;
118 struct Queue* args; 130 struct Queue* args;