comparison src/parallel_execution/worker.c @ 248:1ede5390cda2

Fix segmentation fault but not multi thread running
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 25 Jan 2017 16:55:53 +0900
parents ce262b2c1daf
children cd3486e4ba70
comparison
equal deleted inserted replaced
247:ce262b2c1daf 248:1ede5390cda2
20 static void start_worker(Worker* worker) { 20 static void start_worker(Worker* worker) {
21 CPUWorker* cpuWorker = (CPUWorker*)worker->worker; 21 CPUWorker* cpuWorker = (CPUWorker*)worker->worker;
22 cpuWorker->context = NEW(struct Context); 22 cpuWorker->context = NEW(struct Context);
23 initContext(cpuWorker->context); 23 initContext(cpuWorker->context);
24 Gearef(cpuWorker->context, Worker)->worker = (union Data*)worker; 24 Gearef(cpuWorker->context, Worker)->worker = (union Data*)worker;
25 pthread_cond_wait(&cpuWorker->cond, &cpuWorker->mutex);
26 goto meta(cpuWorker->context, C_taskReceiveWorker); 25 goto meta(cpuWorker->context, C_taskReceiveWorker);
27 } 26 }
28 27
29 __code taskReceiveWorker(struct Context* context, Worker* worker, Queue* queue) { 28 __code taskReceiveWorker(struct Context* context, Worker* worker, Queue* queue) {
30 queue->queue = (union Data*)worker->tasks; 29 queue->queue = (union Data*)worker->tasks;
31 queue->next = C_getTask1; 30 queue->next = C_getTask;
32 goto meta(context, queue->take); 31 goto meta(context, worker->tasks->take);
33 } 32 }
34 33
35 __code taskReceiveWorker_stub(struct Context* context) { 34 __code taskReceiveWorker_stub(struct Context* context) {
35 CPUWorker* cpuWorker = (CPUWorker *)GearImpl(context, Worker, worker);
36 pthread_cond_wait(&cpuWorker->cond, &cpuWorker->mutex);
36 goto taskReceiveWorker(context, &Gearef(context, Worker)->worker->Worker, Gearef(context, Queue)); 37 goto taskReceiveWorker(context, &Gearef(context, Worker)->worker->Worker, Gearef(context, Queue));
37 } 38 }
38 39
39 __code getTask1(struct Context* context, Worker* worker, struct Context* task) { 40 __code getTask(struct Context* context, Worker* worker, struct Context* task) {
40 if (!task) 41 if (!task)
41 return; // end thread 42 return; // end thread
42 task->worker = worker; 43 task->worker = worker;
44 context->next = C_taskReceiveWorker; // set CG after task exec
43 goto meta(task, task->next); 45 goto meta(task, task->next);
44 } 46 }
45 47
46 __code getTask1_stub(struct Context* context) { 48 __code getTask_stub(struct Context* context) {
47 Worker* worker = &Gearef(context,Worker)->worker->Worker; 49 Worker* worker = &Gearef(context,Worker)->worker->Worker;
48 Context* task = &Gearef(context, Queue)->data->context; 50 Context* task = &Gearef(context, Queue)->data->context;
49 goto getTask1(context, worker, task); 51 goto getTask(context, worker, task);
50 } 52 }
51 53
52 #ifdef USE_CUDA 54 #ifdef USE_CUDA
53 __code twiceGpu(struct Context* context) { 55 __code twiceGpu(struct Context* context) {
54 cuMemcpyHtoDAsync(context,context,context,context->stream); 56 cuMemcpyHtoDAsync(context,context,context,context->stream);