Mercurial > hg > Game > Cerium
changeset 1921:91ada4e540f2 draft
minor change
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 29 Jan 2014 17:08:07 +0900 |
parents | 273638411ebf |
children | bbd209709ca1 |
files | TaskManager/Cuda/CudaScheduler.cc |
diffstat | 1 files changed, 16 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cuda/CudaScheduler.cc Wed Jan 29 14:49:54 2014 +0900 +++ b/TaskManager/Cuda/CudaScheduler.cc Wed Jan 29 17:08:07 2014 +0900 @@ -13,7 +13,6 @@ #include <sys/stat.h> #include <string.h> #include <cuda.h> -#include <cuda_runtime.h> TaskObject cuda_task_list[MAX_TASK_OBJECT]; @@ -30,9 +29,8 @@ } cuDeviceGet(&context, 0); ret = cuCtxCreate(&context, 0, device); - if (ret<0) { - const char* msg = convert_error_status(ret); - error(msg); + if (ret!=0) { + error(convert_error_status(ret)); } cuStreamCreate(stream, 0); } @@ -95,7 +93,7 @@ } else { ret = cuEventSynchronize(kernel_event[1-cur]); - if (ret<0) { + if (ret!=0) { error(convert_error_status(ret)); } if (taskList!=NULL) { @@ -109,7 +107,7 @@ if (memout[1-cur].size > 0) { ret = cuEventSynchronize(memout[1-cur].event); - if (ret<0) error(convert_error_status(ret)); + if (ret!=0) error(convert_error_status(ret)); release_buf_event(cur, memout); } @@ -186,21 +184,21 @@ const char *funcname = cuda_task_list[nextTask->command].name; ret = cuModuleGetFunction(kernel[cur], module, funcname); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } int param = 0; // set arg count CUdeviceptr memparam = createBuffer(&memin[cur], 0, context, sizeof(memaddr)*nextTask->param_count, &ret); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } // parameter is passed as first kernel arg ret = cuMemcpyHtoDAsync(memparam, nextTask->param(0), sizeof(memaddr)*nextTask->param_count, stream); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } ret = cuParamSetv(kernel[cur], 0, memin[cur].buf[0], sizeof(memaddr)); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } param++; @@ -208,11 +206,11 @@ ListElement *input_buf = nextTask->inData(i); if (input_buf->size==0) break; createBuffer(&memin[cur], param, context, input_buf->size, &ret); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } ret = cuMemcpyHtoDAsync(memin[cur].buf[param], input_buf->addr, input_buf->size, stream); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } ret = cuParamSetv(kernel[cur], 0, memin[cur].buf[param], sizeof(memaddr)); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } param++; } @@ -223,9 +221,9 @@ if (output_buf->size==0) break; if (!flag[cur].flip) { // flip use memin for output createBuffer(&memout[cur], i, context, CL_MEM_WRITE_ONLY, output_buf->size, &ret); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } ret = cuParamSetv(kernel[cur], 0, memout[cur].buf[i], sizeof(memout)); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue;} + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue;} // enqueue later } param++; @@ -244,7 +242,7 @@ 1, 1, 1, stream, NULL, NULL); } - if (ret<0) { cudaTaskError(cur, tasklist, ret); continue; } + if (ret!=0) { cudaTaskError(cur, tasklist, ret); continue; } for(int i=0;i<nextTask->outData_count;i++) { // read output data ListElement *output_buf = nextTask->outData(i); @@ -253,7 +251,7 @@ int i0 = flag[cur].flip ? i+1 : i ; // flip use memin buffer and memout event ret = cuMemcpyDtoHAsync(mem[cur].buf[i0], output_buf->addr, output_buf->size, stream); - if (ret<0) { cudaTaskError(cur,tasklist,ret); continue; } + if (ret!=0) { cudaTaskError(cur,tasklist,ret); continue; } } // wait kernel[1-cur] and write[1-cur] // pipeline : cur @@ -298,7 +296,7 @@ CUmodule* module = new CUmodule; ret = cuModuleLoad(module, (const char*)cuda_task_list[cmd].cudatask->module); - if(ret<0) { + if(ret!=0) { error(convert_error_status(ret)); } cuda_task_list[cmd].cudatask->module = module;