annotate src/parallel_execution/CUDAtwice.cbc @ 302:8e7926f3e271

fix CUDAWorker
author ikkun
date Mon, 13 Feb 2017 17:58:04 +0900
parents src/parallel_execution/GPUtwice.cbc@06dab015a54d
children 1dbaef86593b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
1 #include <stdio.h>
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
2
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
3 #include "context.h"
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
4 #include "origin_cs.h"
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
5
257
cd3486e4ba70 fix make error of twice
mir3636
parents: 248
diff changeset
6 __code twice(struct Context* context, struct LoopCounter* loopCounter, int index, int prefix, int* array, struct Context* workerContext) {
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
7 int i = loopCounter->i;
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
8 if (i < prefix) {
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
9 array[i+index*prefix] = array[i+index*prefix]*2;
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
10 loopCounter->i++;
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
11
193
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 189
diff changeset
12 goto meta(context, C_twice);
95
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
13 }
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
14
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
15 loopCounter->i = 0;
248
1ede5390cda2 Fix segmentation fault but not multi thread running
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 247
diff changeset
16 goto meta(workerContext, workerContext->next);
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
17 }
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
18
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
19 __code twice_stub(struct Context* context) {
257
cd3486e4ba70 fix make error of twice
mir3636
parents: 248
diff changeset
20 struct Context* workerContext = context->worker->worker->CPUWorker.context;
275
06dab015a54d GPUWorker
ikkun
parents: 257
diff changeset
21 //入力のDataGearをGPUにbuffer経由で送る
06dab015a54d GPUWorker
ikkun
parents: 257
diff changeset
22 //twiceカーネルが定義されてなければそれをロードする
06dab015a54d GPUWorker
ikkun
parents: 257
diff changeset
23 //結果を取ってくるコマンドを入力する
06dab015a54d GPUWorker
ikkun
parents: 257
diff changeset
24 //コマンドの終了待ちを行う
06dab015a54d GPUWorker
ikkun
parents: 257
diff changeset
25 //continationにそってGPUworkerに戻る
248
1ede5390cda2 Fix segmentation fault but not multi thread running
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 247
diff changeset
26 goto twice(context, Gearef(context, LoopCounter), 0, 0, NULL, workerContext);
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
27 }