Mercurial > hg > GearsTemplate
changeset 519:0b408dbfc85b
Add Timer for CUDAExecutor
author | innparusu |
---|---|
date | Sun, 07 Jan 2018 06:30:49 +0900 |
parents | b6be5a5c8b9f |
children | 4090950d1a79 |
files | src/parallel_execution/CUDAExecutor.cbc src/parallel_execution/context.h |
diffstat | 2 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/CUDAExecutor.cbc Fri Jan 05 18:13:04 2018 +0900 +++ b/src/parallel_execution/CUDAExecutor.cbc Sun Jan 07 06:30:49 2018 +0900 @@ -1,10 +1,12 @@ #include "../context.h" #interface "Executor.h" +#interface "Timer.h" #include <stdio.h> Executor* createCUDAExecutor(struct Context* context, CUdevice device) { struct Executor* executor = new Executor(); struct CUDAExecutor* cudaExecutor = new CUDAExecutor(); + cudaExecutor->timer = createTimerImpl(context); checkCudaErrors(cuDeviceGetAttribute(&cudaExecutor->maxThreadPerBlock, CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK, device)); executor->executor = (union Data*)cudaExecutor; executor->read = C_readCUDAExecutor; @@ -28,7 +30,8 @@ } // TODO: Implements pipeline // goto next(...); - goto meta(context, C_execCUDAExecutor); + struct Timer* timer = executor->timer; + goto timer->start(execCUDAExecutor); } int computeblockDim(int count, int maxThreadPerBlock) { @@ -55,12 +58,18 @@ } // TODO: Implements pipeline // goto next(...); - goto meta(context, C_writeCUDAExecutor); + goto writeCUDAExecutor(); } __code writeCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) { + // wait for stream + checkCudaErrors(cuCtxSynchronize()); + struct Timer* timer = executor->timer; + goto timer->end(writeCUDAExecutor1); +} + +__code writeCUDAExecutor1(struct CUDAExecutor* executor, struct Context* task, __code next(...)) { //結果を取ってくるコマンドを入力する - //コマンドの終了待ちを行う struct CUDABuffer* buffer = executor->buffer; int paramLen = buffer->inputLen + buffer->outputLen; for (int i = 0; i < paramLen; i++) { @@ -69,7 +78,5 @@ checkCudaErrors(cuMemcpyDtoH(data, deviceptr, GET_SIZE(data))); cuMemFree(deviceptr); } - // wait for stream - checkCudaErrors(cuCtxSynchronize()); goto next(...); }
--- a/src/parallel_execution/context.h Fri Jan 05 18:13:04 2018 +0900 +++ b/src/parallel_execution/context.h Sun Jan 07 06:30:49 2018 +0900 @@ -378,6 +378,7 @@ CUdeviceptr** kernelParams; struct CUDABuffer* buffer; int maxThreadPerBlock; + struct Timer* timer; } CUDAExecutor; struct CUDABuffer { int inputLen;