# HG changeset patch # User Shinji KONO # Date 1487076911 -32400 # Node ID 8c2123bb577b53277a6d730ab6b3b98faf5d6d10 # Parent aeddca6860075284d6ae0af196195fbea6b7803b fix compile errors diff -r aeddca686007 -r 8c2123bb577b src/parallel_execution/CUDAtwice.cbc --- a/src/parallel_execution/CUDAtwice.cbc Tue Feb 14 16:55:22 2017 +0900 +++ b/src/parallel_execution/CUDAtwice.cbc Tue Feb 14 21:55:11 2017 +0900 @@ -1,6 +1,11 @@ #include #include "../context.h" +#include + +#include +#include "helper_cuda.h" + __code twice(struct Context* context, struct LoopCounter* loopCounter, int index, int prefix, int* array, struct Context* workerContext) { int i = loopCounter->i; if (i < prefix) { @@ -15,20 +20,19 @@ } __code twice_stub(struct Context* context) { - struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter; + // struct LoopCounter* loopCounter = &context->data[context->dataNum]->LoopCounter; struct Array* array = &context->data[context->dataNum+1]->Array; - Worker *worker = context->worker; - CUDAWorker* cudaWorker = (CUDAWorker*)worker->worker; + // Worker *worker = context->worker; + // CUDAWorker* cudaWorker = (CUDAWorker*)worker->worker; // memory allocate CUdeviceptr devA; - CUdeviceptr devOut[num_exec]; checkCudaErrors(cuMemAlloc(&devA, array->size)); //twiceカーネルが定義されてなければそれをロードする checkCudaErrors(cuModuleLoad(&context->module, "CUDAtwice.ptx")); - checkCudaErrors(cuModuleGetFunction(context->&function, module, "twice")); + checkCudaErrors(cuModuleGetFunction(&context->function, context->module, "twice")); //入力のDataGearをGPUにbuffer経由で送る // Synchronous data transfer(host to device) @@ -37,7 +41,7 @@ // Asynchronous launch kernel context->num_exec = 1; void* args[] = {&devA}; - checkCudaErrors(cuLaunchKernel(function, + checkCudaErrors(cuLaunchKernel(context->function, array->prefix, 1, 1, context->num_exec, 1, 1, 0, NULL , args, NULL)); diff -r aeddca686007 -r 8c2123bb577b src/parallel_execution/CUDAtwice.cu --- a/src/parallel_execution/CUDAtwice.cu Tue Feb 14 16:55:22 2017 +0900 +++ b/src/parallel_execution/CUDAtwice.cu Tue Feb 14 21:55:11 2017 +0900 @@ -1,11 +1,14 @@ extern "C" { + #include - __global__ void twice(strct LoopCounter* loopCounter, int prefix ,int* array) { + + __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"); + 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; } } + } diff -r aeddca686007 -r 8c2123bb577b src/parallel_execution/context.h --- a/src/parallel_execution/context.h Tue Feb 14 16:55:22 2017 +0900 +++ b/src/parallel_execution/context.h Tue Feb 14 21:55:11 2017 +0900 @@ -83,7 +83,7 @@ int num_exec; CUmodule module; CUfunction function; -#endef +#endif union Data **data; }; diff -r aeddca686007 -r 8c2123bb577b src/parallel_execution/helper_string.h --- a/src/parallel_execution/helper_string.h Tue Feb 14 16:55:22 2017 +0900 +++ b/src/parallel_execution/helper_string.h Tue Feb 14 21:55:11 2017 +0900 @@ -75,6 +75,12 @@ #define EXIT_WAIVED 2 #endif +#ifndef bool +typedef int bool; +#define false 0 +#define true 1 +#endif + // CUDA Utility Helper Functions inline int stringRemoveDelimiter(char delimiter, const char *string) { diff -r aeddca686007 -r 8c2123bb577b src/parallel_execution/main.cbc --- a/src/parallel_execution/main.cbc Tue Feb 14 16:55:22 2017 +0900 +++ b/src/parallel_execution/main.cbc Tue Feb 14 21:55:11 2017 +0900 @@ -25,7 +25,7 @@ } __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) { - loopCounter->tree = createRedBlackTree(context); + // loopCounter->tree = createRedBlackTree(context); loopCounter->i = 0; taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, 0, 0); goto meta(context, C_createTask1);