annotate src/parallel_execution/worker.c @ 227:991f3d1ce072

fix worker
author ikkun
date Fri, 20 Jan 2017 19:12:29 +0900
parents 77faa28128b4
children a1fb3f2d1a36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <libkern/OSAtomic.h>
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "context.h"
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "origin_cs.h"
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
183
mir3636
parents: 175
diff changeset
6 union Data* createWorker(struct Context* context) {
mir3636
parents: 175
diff changeset
7 struct Worker* worker = &ALLOCATE(context, Worker)->Worker;
222
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
8 worker->execute = C_executeWorker;
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
9 worker->taskSend = C_taskSendWorker;
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
10 worker->taskReceive = C_taskReceiveWorker;
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
11 worker->shutdown = C_shutdownWorker;
183
mir3636
parents: 175
diff changeset
12 return (union Data*)(worker);
mir3636
parents: 175
diff changeset
13 }
mir3636
parents: 175
diff changeset
14
227
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
15 __code taskSendWorker(struct Context* context) {
222
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
16 }
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
17
227
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
18 __code taskSendWorker_stub(struct Context* context) {
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
19 goto taskSendWorker(context);
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
20 }
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
21
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
22 __code executeWorker(struct Context* context, Worker* worker) {
222
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
23 worker->next = worker->taskReceive;
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
24 goto meta(context, task->code);
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
25 }
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
26
227
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
27 __code executeWorker_stub(struct Context* context) {
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
28 Worker* worker = &Gearef(context,Worker);
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
29 goto extcuteWorker(context,worker);
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
30 }
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
31
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
32 __code taskReceiveWorker(struct Context* context, Worker* worker) {
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
33 Queue* queue = &Gearef(context,queue);
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
34 queue->queue = worker->tasks;
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
35 queue->next = C_getTask1;
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
36 goto meta(context, queue->take);
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
37 }
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
38
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
39 __code taskReceiveWorker_stub(struct Context* context) {
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
40 Worker* worker = Gearef(context,Worker).worker;
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
41 goto taskReceiveWorker(context,queue);
222
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
42 }
77faa28128b4 Add taskSend for TaskManager
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 217
diff changeset
43
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
44 __code getTask1(struct Context* context, struct Queue* queue) {
173
8260b230dc2f fix RedBlackTree.c
ikkun
parents: 170
diff changeset
45 queue->next = C_getTask2;
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
46 goto meta(context, queue->take);
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
47 }
109
059b26a250cc Change put_queue process
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 103
diff changeset
48
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
49 __code getTask1_stub(struct Context* context) {
189
mir3636
parents: 185
diff changeset
50 goto getTask1(context,/* &context->data[D_ActiveQueue]->Queue*/ NULL);
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 }
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
53 __code getTask2(struct Context* context, struct Task* task, struct Node* node) {
173
8260b230dc2f fix RedBlackTree.c
ikkun
parents: 170
diff changeset
54 context->next = C_getTask1;
189
mir3636
parents: 185
diff changeset
55 goto meta(context, C_getTask2);
169
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
56 }
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
57
ea7b11f3e717 Using Queue Interface
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 149
diff changeset
58 __code getTask2_stub(struct Context* context) {
217
c34e6aa10967 Fix DataGear access name
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 189
diff changeset
59 goto getTask2(context, /*&(context->data[D_ActiveQueue]->Queue.data->Task)*/ NULL, &context->data[D_Node]->Node);
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 }
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
61
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
62 #ifdef USE_CUDA
98
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
63 __code twiceGpu(struct Context* context) {
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
64 cuMemcpyHtoDAsync(context,context,context,context->stream);
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
65 cuLaunchkanel();
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
66 cuMemcpyDtoHAsync();
d400948dbbab add Cuda infomation to context
ikkun
parents: 95
diff changeset
67 }
101
8987cf13d5bb Add Allocate macro
innparusu
parents: 98
diff changeset
68 #endif
227
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
69
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
70 __code shutdownWorker(struct Context* context) {
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
71
991f3d1ce072 fix worker
ikkun
parents: 222
diff changeset
72 }