comparison src/parallel_execution/CUDAtwice.cbc @ 310:782f4c560de4

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 14 Feb 2017 22:02:39 +0900
parents 8c2123bb577b
children 7dd5a7d52a67
comparison
equal deleted inserted replaced
309:8c2123bb577b 310:782f4c560de4
4 #include <cuda.h> 4 #include <cuda.h>
5 5
6 #include <cuda_runtime.h> 6 #include <cuda_runtime.h>
7 #include "helper_cuda.h" 7 #include "helper_cuda.h"
8 8
9 __code twice(struct Context* context, struct LoopCounter* loopCounter, int index, int prefix, int* array, struct Context* workerContext) { 9 __code CUDAtwice(struct Context* context, struct LoopCounter* loopCounter, int index, int prefix, int* array, struct Context* workerContext) {
10 int i = loopCounter->i; 10 int i = loopCounter->i;
11 if (i < prefix) { 11 if (i < prefix) {
12 array[i+index*prefix] = array[i+index*prefix]*2; 12 array[i+index*prefix] = array[i+index*prefix]*2;
13 loopCounter->i++; 13 loopCounter->i++;
14 14
17 17
18 loopCounter->i = 0; 18 loopCounter->i = 0;
19 goto meta(workerContext, workerContext->next); 19 goto meta(workerContext, workerContext->next);
20 } 20 }
21 21
22 __code twice_stub(struct Context* context) { 22 static void CUDAExec(struct Context* context, struct Array* array) {
23 // struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter;
24 struct Array* array = &context->data[context->dataNum+1]->Array;
25
26 // Worker *worker = context->worker; 23 // Worker *worker = context->worker;
27 // CUDAWorker* cudaWorker = (CUDAWorker*)worker->worker; 24 // CUDAWorker* cudaWorker = (CUDAWorker*)worker->worker;
28 // memory allocate 25 // memory allocate
29 CUdeviceptr devA; 26 CUdeviceptr devA;
30 27
48 45
49 //結果を取ってくるコマンドを入力する 46 //結果を取ってくるコマンドを入力する
50 //コマンドの終了待ちを行う 47 //コマンドの終了待ちを行う
51 checkCudaErrors(cuMemcpyDtoH(array->array, devA, array->size)); 48 checkCudaErrors(cuMemcpyDtoH(array->array, devA, array->size));
52 // wait for stream 49 // wait for stream
50 }
51
52 __code CUDAtwice_stub(struct Context* context) {
53 // struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter;
54 struct Array* array = &context->data[context->dataNum+1]->Array;
55 CUDAExec(context,array);
53 56
54 //continuationにそってGPUworkerに戻る 57 //continuationにそってGPUworkerに戻る
55 goto meta(context, context->next); 58 goto meta(context, context->next);
56 } 59 }