Mercurial > hg > Gears > GearsAgda
changeset 329:8592a1d161b7 examples_directory
Move CUDAtwice example to examples directory
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 18 Apr 2017 06:04:22 +0900 |
parents | 48c2b5bcab79 |
children | a258505bf9fd |
files | src/parallel_execution/CMakeLists.txt src/parallel_execution/CUDAtwice.cbc src/parallel_execution/CUDAtwice.cu src/parallel_execution/examples/CUDAtwice.cbc src/parallel_execution/examples/CUDAtwice.cu |
diffstat | 5 files changed, 62 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt Tue Apr 18 06:00:45 2017 +0900 +++ b/src/parallel_execution/CMakeLists.txt Tue Apr 18 06:04:22 2017 +0900 @@ -75,7 +75,7 @@ TARGET CUDAtwice SOURCES - main.cbc RedBlackTree.cbc compare.c SingleLinkedStack.cbc CPUWorker.cbc time.cbc twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc CUDAWorker.cbc CUDAtwice.cbc CUDAtwice.cu cuda.c + main.cbc RedBlackTree.cbc compare.c SingleLinkedStack.cbc CPUWorker.cbc time.cbc twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc CUDAWorker.cbc examples/CUDAtwice.cbc examples/CUDAtwice.cu cuda.c ) set_target_properties(CUDAtwice PROPERTIES COMPILE_FLAGS "-Wall -g -DUSE_CUDAWorker=1 -DUSE_CUDA_MAIN_THREAD") endif()
--- a/src/parallel_execution/CUDAtwice.cbc Tue Apr 18 06:00:45 2017 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#include <stdio.h> -#include "../context.h" - - -extern void CUDAExec(struct Context* context, Array* array, LoopCounter *loopCounter); - -__code CUDAtwice(struct Context* context, struct LoopCounter* loopCounter, int index, int prefix, int* array, struct Context* workerContext) { - int i = loopCounter->i; - if (i < prefix) { - array[i+index*prefix] = array[i+index*prefix]*2; - loopCounter->i++; - - goto meta(context, C_twice); - } - - loopCounter->i = 0; - goto meta(workerContext, workerContext->next); -} - -__code CUDAtwice_stub(struct Context* context) { -printf("CUdAtwice stub\n"); - struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter; - struct Array* array = &context->data[context->dataNum+1]->Array; - CUDAExec(context,array,loopCounter); - - //continuationにそってGPUworkerに戻る - goto meta(context, context->next); -}
--- a/src/parallel_execution/CUDAtwice.cu Tue Apr 18 06:00:45 2017 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -extern "C" { - -#include <stdio.h> - -// __global__ void twice(struct LoopCounter* loopCounter, int prefix ,int* array) { -// int index = blockIdx.x * blockDim.x + threadIdx.x; -// printf("array %p, blockIdx.x = %d, blockDim.x = %d, threadIdx.x = %d\n"); -// int i = 0; -// while (i < prefix) { -// array[i+index*prefix] = array[i+index*prefix]*2; -// } -// } - - struct LoopCounter { - int i; - } LoopCounter; - - __global__ void twice(struct LoopCounter* loopCounter, int index, int prefix, int* array) { - printf("array %p, index = %d, prefix = %d loopCounter->i %d\n",array,index,prefix,loopCounter->i); -C_twice: - int i = loopCounter->i; - if (i < prefix) { - array[i+index*prefix] = array[i+index*prefix]*2; - loopCounter->i++; - - goto C_twice; - } - - loopCounter->i = 0; - } - - -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/examples/CUDAtwice.cbc Tue Apr 18 06:04:22 2017 +0900 @@ -0,0 +1,28 @@ +#include <stdio.h> +#include "../../context.h" + + +extern void CUDAExec(struct Context* context, Array* array, LoopCounter *loopCounter); + +__code CUDAtwice(struct Context* context, struct LoopCounter* loopCounter, int index, int prefix, int* array, struct Context* workerContext) { + int i = loopCounter->i; + if (i < prefix) { + array[i+index*prefix] = array[i+index*prefix]*2; + loopCounter->i++; + + goto meta(context, C_twice); + } + + loopCounter->i = 0; + goto meta(workerContext, workerContext->next); +} + +__code CUDAtwice_stub(struct Context* context) { +printf("CUdAtwice stub\n"); + struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter; + struct Array* array = &context->data[context->dataNum+1]->Array; + CUDAExec(context,array,loopCounter); + + //continuationにそってGPUworkerに戻る + goto meta(context, context->next); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parallel_execution/examples/CUDAtwice.cu Tue Apr 18 06:04:22 2017 +0900 @@ -0,0 +1,33 @@ +extern "C" { + +#include <stdio.h> + +// __global__ void twice(struct LoopCounter* loopCounter, int prefix ,int* array) { +// int index = blockIdx.x * blockDim.x + threadIdx.x; +// printf("array %p, blockIdx.x = %d, blockDim.x = %d, threadIdx.x = %d\n"); +// int i = 0; +// while (i < prefix) { +// array[i+index*prefix] = array[i+index*prefix]*2; +// } +// } + + struct LoopCounter { + int i; + } LoopCounter; + + __global__ void twice(struct LoopCounter* loopCounter, int index, int prefix, int* array) { + printf("array %p, index = %d, prefix = %d loopCounter->i %d\n",array,index,prefix,loopCounter->i); +C_twice: + int i = loopCounter->i; + if (i < prefix) { + array[i+index*prefix] = array[i+index*prefix]*2; + loopCounter->i++; + + goto C_twice; + } + + loopCounter->i = 0; + } + + +}