annotate src/parallel_execution/examples/twice/CUDAtwice.cbc @ 381:b81492c74d2b

Create examples directory
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 24 Jul 2017 16:52:09 +0900
parents src/parallel_execution/examples/CUDAtwice.cbc@8592a1d161b7
children 85b0ddbf458e
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>
381
b81492c74d2b Create examples directory
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 329
diff changeset
2 #include "../../../context.h"
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
3
309
8c2123bb577b fix compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 308
diff changeset
4
321
a9a6d571fa80 Update todo
innparusu
parents: 319
diff changeset
5 extern void CUDAExec(struct Context* context, Array* array, LoopCounter *loopCounter);
312
7dd5a7d52a67 USE_CUDAWorker flag only for CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 310
diff changeset
6
310
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 309
diff changeset
7 __code CUDAtwice(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
8 int i = loopCounter->i;
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
9 if (i < prefix) {
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
10 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
11 loopCounter->i++;
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
12
193
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 189
diff changeset
13 goto meta(context, C_twice);
95
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
3e28ee215c0e modify twice, use OSAtomiceCompareAndSwap
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
16 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
17 goto meta(workerContext, workerContext->next);
92
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
310
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 309
diff changeset
20 __code CUDAtwice_stub(struct Context* context) {
314
1839586f5b41 pthread CUDA test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 312
diff changeset
21 printf("CUdAtwice stub\n");
312
7dd5a7d52a67 USE_CUDAWorker flag only for CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 310
diff changeset
22 struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter;
310
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 309
diff changeset
23 struct Array* array = &context->data[context->dataNum+1]->Array;
312
7dd5a7d52a67 USE_CUDAWorker flag only for CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 310
diff changeset
24 CUDAExec(context,array,loopCounter);
303
1dbaef86593b CUDAtwice.cbc
ikkun
parents: 302
diff changeset
25
306
ae4f6aa427f5 CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 303
diff changeset
26 //continuationにそってGPUworkerに戻る
308
aeddca686007 CUDAtwice
ikkun
parents: 306
diff changeset
27 goto meta(context, context->next);
92
851da1107223 implement twice
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
28 }