Mercurial > hg > Members > Moririn
comparison src/parallel_execution/CUDAtwice.cbc @ 314:1839586f5b41
pthread CUDA test
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 15 Feb 2017 12:34:19 +0900 |
parents | 7dd5a7d52a67 |
children | 54d203daf06b |
comparison
equal
deleted
inserted
replaced
313:4addbc7469ee | 314:1839586f5b41 |
---|---|
10 // Worker *worker = context->worker; | 10 // Worker *worker = context->worker; |
11 // CUDAWorker* cudaWorker = (CUDAWorker*)worker->worker; | 11 // CUDAWorker* cudaWorker = (CUDAWorker*)worker->worker; |
12 // memory allocate | 12 // memory allocate |
13 CUdeviceptr devA; | 13 CUdeviceptr devA; |
14 CUdeviceptr devLoopCounter; | 14 CUdeviceptr devLoopCounter; |
15 printf("CUdA Exe 1\n"); | |
15 | 16 |
16 checkCudaErrors(cuMemAlloc(&devA, array->size)); | 17 checkCudaErrors(cuMemAlloc(&devA, array->size)); |
17 checkCudaErrors(cuMemAlloc(&devLoopCounter, sizeof(LoopCounter))); | 18 checkCudaErrors(cuMemAlloc(&devLoopCounter, sizeof(LoopCounter))); |
18 | 19 |
19 //twiceカーネルが定義されてなければそれをロードする | 20 //twiceカーネルが定義されてなければそれをロードする |
20 checkCudaErrors(cuModuleLoad(&context->module, "CUDAtwice.ptx")); | 21 checkCudaErrors(cuModuleLoad(&context->module, "CUDAtwice.ptx")); |
21 checkCudaErrors(cuModuleGetFunction(&context->function, context->module, "twice")); | 22 checkCudaErrors(cuModuleGetFunction(&context->function, context->module, "twice")); |
23 printf("CUdA Exe 2\n"); | |
22 | 24 |
23 //入力のDataGearをGPUにbuffer経由で送る | 25 //入力のDataGearをGPUにbuffer経由で送る |
24 // Synchronous data transfer(host to device) | 26 // Synchronous data transfer(host to device) |
25 checkCudaErrors(cuMemcpyHtoD(devLoopCounter, loopCounter, sizeof(LoopCounter))); | 27 checkCudaErrors(cuMemcpyHtoD(devLoopCounter, loopCounter, sizeof(LoopCounter))); |
26 checkCudaErrors(cuMemcpyHtoD(devA, array->array, array->size)); | 28 checkCudaErrors(cuMemcpyHtoD(devA, array->array, array->size)); |
51 loopCounter->i = 0; | 53 loopCounter->i = 0; |
52 goto meta(workerContext, workerContext->next); | 54 goto meta(workerContext, workerContext->next); |
53 } | 55 } |
54 | 56 |
55 __code CUDAtwice_stub(struct Context* context) { | 57 __code CUDAtwice_stub(struct Context* context) { |
58 printf("CUdAtwice stub\n"); | |
56 struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter; | 59 struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter; |
57 struct Array* array = &context->data[context->dataNum+1]->Array; | 60 struct Array* array = &context->data[context->dataNum+1]->Array; |
58 CUDAExec(context,array,loopCounter); | 61 CUDAExec(context,array,loopCounter); |
59 | 62 |
60 //continuationにそってGPUworkerに戻る | 63 //continuationにそってGPUworkerに戻る |