comparison src/parallel_execution/worker.c @ 244:d1567718f12c

Fix error
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 25 Jan 2017 01:48:47 +0900
parents 9f3f8ed6ed9f
children ce262b2c1daf
comparison
equal deleted inserted replaced
242:9f3f8ed6ed9f 244:d1567718f12c
7 7
8 union Data* createCPUWorker(struct Context* context, int id, Queue* queue) { 8 union Data* createCPUWorker(struct Context* context, int id, Queue* queue) {
9 struct Worker* worker = ALLOC(context, Worker); 9 struct Worker* worker = ALLOC(context, Worker);
10 struct CPUWorker* cpuWorker = ALLOC(context, CPUWorker); 10 struct CPUWorker* cpuWorker = ALLOC(context, CPUWorker);
11 worker->worker = (union Data*)cpuWorker; 11 worker->worker = (union Data*)cpuWorker;
12 cpuWorker->tasks = queue; 12 worker->tasks = queue;
13 cpuWorker->id = id; 13 cpuWorker->id = id;
14 worker->taskReceive = C_taskReceiveWorker; 14 worker->taskReceive = C_taskReceiveWorker;
15 worker->shutdown = C_shutdownWorker; 15 worker->shutdown = C_shutdownWorker;
16 pthread_create(&worker->worker->CPUWorker.thread, NULL, (void*)&start_worker, worker); 16 pthread_create(&worker->worker->CPUWorker.thread, NULL, (void*)&start_worker, worker);
17 return (union Data*)(worker); 17 return (union Data*)(worker);
23 initContext(cpuWorker->context); 23 initContext(cpuWorker->context);
24 pthread_cond_wait(&cpuWorker->cond, &cpuWorker->mutex); 24 pthread_cond_wait(&cpuWorker->cond, &cpuWorker->mutex);
25 goto meta(cpuWorker->context, C_taskReceiveWorker); 25 goto meta(cpuWorker->context, C_taskReceiveWorker);
26 } 26 }
27 27
28 __code taskReceiveWorker(struct Context* context, CPUWorker* worker) { 28 __code taskReceiveWorker(struct Context* context, Worker* worker) {
29 Queue* queue = worker->tasks; 29 Queue* queue = worker->tasks;
30 queue->next = C_getTask1; 30 queue->next = C_getTask1;
31 goto meta(context, queue->take); 31 goto meta(context, queue->take);
32 } 32 }
33 33
34 __code taskReceiveWorker_stub(struct Context* context) { 34 __code taskReceiveWorker_stub(struct Context* context) {
35 CPUWorker* worker = (CPUWorker *)GearImpl(context, Worker, worker); 35 goto taskReceiveWorker(context, Gearef(context, Worker));
36 goto taskReceiveWorker(context,worker);
37 } 36 }
38 37
39 __code getTask1(struct Context* context, Worker* worker, struct Context* task) { 38 __code getTask1(struct Context* context, Worker* worker, struct Context* task) {
40 if (!task) 39 if (!task)
41 return; // end thread 40 return; // end thread
43 goto meta(task, task->next); 42 goto meta(task, task->next);
44 } 43 }
45 44
46 __code getTask1_stub(struct Context* context) { 45 __code getTask1_stub(struct Context* context) {
47 Worker* worker = Gearef(context,Worker); 46 Worker* worker = Gearef(context,Worker);
48 CPUWorker* cpuWorker = (CPUWorker *)GearImpl(context, Worker, worker); 47 Context* task = &worker->tasks->data->context;
49 Context* task = &cpuWorker->tasks->data->context;
50 goto getTask1(context,worker,task); 48 goto getTask1(context,worker,task);
51 } 49 }
52 50
53 #ifdef USE_CUDA 51 #ifdef USE_CUDA
54 __code twiceGpu(struct Context* context) { 52 __code twiceGpu(struct Context* context) {