Mercurial > hg > Members > Moririn
changeset 309:8c2123bb577b
fix compile errors
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 14 Feb 2017 21:55:11 +0900 |
parents | aeddca686007 |
children | 782f4c560de4 |
files | src/parallel_execution/CUDAtwice.cbc src/parallel_execution/CUDAtwice.cu src/parallel_execution/context.h src/parallel_execution/helper_string.h src/parallel_execution/main.cbc |
diffstat | 5 files changed, 23 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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 <stdio.h> #include "../context.h" +#include <cuda.h> + +#include <cuda_runtime.h> +#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));
--- 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 <stdio.h> - __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; } } + }
--- 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; };
--- 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) {
--- 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);