diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2021-11-17 14:37:58 +0100 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2021-11-17 14:38:06 +0100 |
commit | 767eb40a970f981838ea1f0263ba968ae167f91f (patch) | |
tree | 96b5a8ecfd26bc01f270efff4e539c1d12b8350f /cuda/3d/mem3d.cu | |
parent | b763f47f6fde0726041a6246e969eb22b142f4d8 (diff) | |
download | astra-767eb40a970f981838ea1f0263ba968ae167f91f.tar.gz astra-767eb40a970f981838ea1f0263ba968ae167f91f.tar.bz2 astra-767eb40a970f981838ea1f0263ba968ae167f91f.tar.xz astra-767eb40a970f981838ea1f0263ba968ae167f91f.zip |
Switch cuda memhandle checks to checkCuda
Diffstat (limited to 'cuda/3d/mem3d.cu')
-rw-r--r-- | cuda/3d/mem3d.cu | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/cuda/3d/mem3d.cu b/cuda/3d/mem3d.cu index 1aa4dd2..ad2a0f3 100644 --- a/cuda/3d/mem3d.cu +++ b/cuda/3d/mem3d.cu @@ -58,15 +58,13 @@ struct SMemHandle3D_internal int maxBlockDimension() { int dev; - cudaError_t err = cudaGetDevice(&dev); - if (err != cudaSuccess) { + if (!checkCuda(cudaGetDevice(&dev), "maxBlockDimension getDevice")) { ASTRA_WARN("Error querying device"); return 0; } cudaDeviceProp props; - err = cudaGetDeviceProperties(&props, dev); - if (err != cudaSuccess) { + if (!checkCuda(cudaGetDeviceProperties(&props, dev), "maxBlockDimension getDviceProps")) { ASTRA_WARN("Error querying device %d properties", dev); return 0; } @@ -84,10 +82,7 @@ MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Me size_t free = astraCUDA::availableGPUMemory(); - cudaError_t err; - err = cudaMalloc3D(&hnd.ptr, make_cudaExtent(sizeof(float)*x, y, z)); - - if (err != cudaSuccess) { + if (!checkCuda(cudaMalloc3D(&hnd.ptr, make_cudaExtent(sizeof(float)*x, y, z)), "allocateGPUMemory malloc3d")) { return MemHandle3D(); } @@ -98,8 +93,7 @@ MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Me if (zero == INIT_ZERO) { - err = cudaMemset3D(hnd.ptr, 0, make_cudaExtent(sizeof(float)*x, y, z)); - if (err != cudaSuccess) { + if (!checkCuda(cudaMemset3D(hnd.ptr, 0, make_cudaExtent(sizeof(float)*x, y, z)), "allocateGPUMemory memset3d")) { cudaFree(hnd.ptr.ptr); return MemHandle3D(); } @@ -116,23 +110,22 @@ bool zeroGPUMemory(MemHandle3D handle, unsigned int x, unsigned int y, unsigned { SMemHandle3D_internal& hnd = *handle.d.get(); assert(!hnd.arr); - cudaError_t err = cudaMemset3D(hnd.ptr, 0, make_cudaExtent(sizeof(float)*x, y, z)); - return err == cudaSuccess; + return checkCuda(cudaMemset3D(hnd.ptr, 0, make_cudaExtent(sizeof(float)*x, y, z)), "zeroGPUMemory"); } bool freeGPUMemory(MemHandle3D handle) { size_t free = astraCUDA::availableGPUMemory(); - cudaError_t err; + bool ok; if (handle.d->arr) - err = cudaFreeArray(handle.d->arr); + ok = checkCuda(cudaFreeArray(handle.d->arr), "freeGPUMemory array"); else - err = cudaFree(handle.d->ptr.ptr); + ok = checkCuda(cudaFree(handle.d->ptr.ptr), "freeGPUMemory"); size_t free2 = astraCUDA::availableGPUMemory(); ASTRA_DEBUG("Freeing memory. (Pre: %lu, post: %lu)", free, free2); - return err == cudaSuccess; + return ok; } bool copyToGPUMemory(const float *src, MemHandle3D dst, const SSubDimensions3D &pos) @@ -160,9 +153,7 @@ bool copyToGPUMemory(const float *src, MemHandle3D dst, const SSubDimensions3D & p.kind = cudaMemcpyHostToDevice; - cudaError_t err = cudaMemcpy3D(&p); - - return err == cudaSuccess; + return checkCuda(cudaMemcpy3D(&p), "copyToGPUMemory"); } @@ -197,10 +188,7 @@ bool copyFromGPUMemory(float *dst, MemHandle3D src, const SSubDimensions3D &pos) p.kind = cudaMemcpyDeviceToHost; - cudaError_t err = cudaMemcpy3D(&p); - - return err == cudaSuccess; - + return checkCuda(cudaMemcpy3D(&p), "copyFromGPUMemory"); } @@ -409,9 +397,7 @@ bool copyIntoArray(MemHandle3D handle, MemHandle3D subdata, const SSubDimensions p.kind = cudaMemcpyHostToDevice; - cudaError_t err = cudaMemcpy3D(&p); - - return err == cudaSuccess; + return checkCuda(cudaMemcpy3D(&p), "copyIntoArray"); } |