From 1875e824a0358a7e7510b31f5e87708b304652bc Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 16 Nov 2021 11:38:02 +0100 Subject: Remove reportCudaError function --- cuda/3d/util3d.cu | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'cuda/3d/util3d.cu') diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu index 844b880..8b66432 100644 --- a/cuda/3d/util3d.cu +++ b/cuda/3d/util3d.cu @@ -46,12 +46,9 @@ cudaPitchedPtr allocateVolumeData(const SDimensions3D& dims) cudaPitchedPtr volData; - cudaError err = cudaMalloc3D(&volData, extentV); - if (err != cudaSuccess) { - astraCUDA::reportCudaError(err); + if (!checkCuda(cudaMalloc3D(&volData, extentV), "allocateVolumeData 3D")) { ASTRA_ERROR("Failed to allocate %dx%dx%d GPU buffer", dims.iVolX, dims.iVolY, dims.iVolZ); volData.ptr = 0; - // TODO: return 0 somehow? } return volData; @@ -65,12 +62,9 @@ cudaPitchedPtr allocateProjectionData(const SDimensions3D& dims) cudaPitchedPtr projData; - cudaError err = cudaMalloc3D(&projData, extentP); - if (err != cudaSuccess) { - astraCUDA::reportCudaError(err); + if (!checkCuda(cudaMalloc3D(&projData, extentP), "allocateProjectionData 3D")) { ASTRA_ERROR("Failed to allocate %dx%dx%d GPU buffer", dims.iProjU, dims.iProjAngles, dims.iProjV); projData.ptr = 0; - // TODO: return 0 somehow? } return projData; @@ -303,9 +297,8 @@ cudaArray* allocateVolumeArray(const SDimensions3D& dims) extentA.width = dims.iVolX; extentA.height = dims.iVolY; extentA.depth = dims.iVolZ; - cudaError err = cudaMalloc3DArray(&cuArray, &channelDesc, extentA); - if (err != cudaSuccess) { - astraCUDA::reportCudaError(err); + + if (!checkCuda(cudaMalloc3DArray(&cuArray, &channelDesc, extentA), "allocateVolumeArray 3D")) { ASTRA_ERROR("Failed to allocate %dx%dx%d GPU array", dims.iVolX, dims.iVolY, dims.iVolZ); return 0; } @@ -320,10 +313,8 @@ cudaArray* allocateProjectionArray(const SDimensions3D& dims) extentA.width = dims.iProjU; extentA.height = dims.iProjAngles; extentA.depth = dims.iProjV; - cudaError err = cudaMalloc3DArray(&cuArray, &channelDesc, extentA); - if (err != cudaSuccess) { - astraCUDA::reportCudaError(err); + if (!checkCuda(cudaMalloc3DArray(&cuArray, &channelDesc, extentA), "allocateProjectionArray 3D")) { ASTRA_ERROR("Failed to allocate %dx%dx%d GPU array", dims.iProjU, dims.iProjAngles, dims.iProjV); return 0; } -- cgit v1.2.3 From b492e3d049e300132d2f22eee7922ff308342a84 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 16 Nov 2021 11:46:17 +0100 Subject: Remove ASTRA_CUDA_ASSERT --- cuda/3d/util3d.cu | 72 +++++++++++++++---------------------------------------- 1 file changed, 19 insertions(+), 53 deletions(-) (limited to 'cuda/3d/util3d.cu') diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu index 8b66432..4f5d134 100644 --- a/cuda/3d/util3d.cu +++ b/cuda/3d/util3d.cu @@ -72,11 +72,11 @@ cudaPitchedPtr allocateProjectionData(const SDimensions3D& dims) bool zeroVolumeData(cudaPitchedPtr& D_data, const SDimensions3D& dims) { char* t = (char*)D_data.ptr; - cudaError err; for (unsigned int z = 0; z < dims.iVolZ; ++z) { - err = cudaMemset2D(t, D_data.pitch, 0, dims.iVolX*sizeof(float), dims.iVolY); - ASTRA_CUDA_ASSERT(err); + if (!checkCuda(cudaMemset2D(t, D_data.pitch, 0, dims.iVolX*sizeof(float), dims.iVolY), "zeroVolumeData 3D")) { + return false; + } t += D_data.pitch * dims.iVolY; } return true; @@ -84,11 +84,11 @@ bool zeroVolumeData(cudaPitchedPtr& D_data, const SDimensions3D& dims) bool zeroProjectionData(cudaPitchedPtr& D_data, const SDimensions3D& dims) { char* t = (char*)D_data.ptr; - cudaError err; for (unsigned int z = 0; z < dims.iProjV; ++z) { - err = cudaMemset2D(t, D_data.pitch, 0, dims.iProjU*sizeof(float), dims.iProjAngles); - ASTRA_CUDA_ASSERT(err); + if (!checkCuda(cudaMemset2D(t, D_data.pitch, 0, dims.iProjU*sizeof(float), dims.iProjAngles), "zeroProjectionData 3D")) { + return false; + } t += D_data.pitch * dims.iProjAngles; } @@ -122,11 +122,7 @@ bool copyVolumeToDevice(const float* data, cudaPitchedPtr& D_data, const SDimens p.extent = extentV; p.kind = cudaMemcpyHostToDevice; - cudaError err; - err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - - return err == cudaSuccess; + return checkCuda(cudaMemcpy3D(&p), "copyVolumeToDevice 3D"); } bool copyProjectionsToDevice(const float* data, cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch) @@ -157,11 +153,7 @@ bool copyProjectionsToDevice(const float* data, cudaPitchedPtr& D_data, const SD p.extent = extentV; p.kind = cudaMemcpyHostToDevice; - cudaError err; - err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - - return err == cudaSuccess; + return checkCuda(cudaMemcpy3D(&p), "copyProjectionsToDevice 3D"); } bool copyVolumeFromDevice(float* data, const cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch) @@ -192,12 +184,9 @@ bool copyVolumeFromDevice(float* data, const cudaPitchedPtr& D_data, const SDime p.extent = extentV; p.kind = cudaMemcpyDeviceToHost; - cudaError err; - err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - - return err == cudaSuccess; + return checkCuda(cudaMemcpy3D(&p), "copyVolumeFromDevice 3D"); } + bool copyProjectionsFromDevice(float* data, const cudaPitchedPtr& D_data, const SDimensions3D& dims, unsigned int pitch) { if (!pitch) @@ -226,11 +215,7 @@ bool copyProjectionsFromDevice(float* data, const cudaPitchedPtr& D_data, const p.extent = extentV; p.kind = cudaMemcpyDeviceToHost; - cudaError err; - err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - - return err == cudaSuccess; + return checkCuda(cudaMemcpy3D(&p), "copyProjectionsFromDevice 3D"); } bool duplicateVolumeData(cudaPitchedPtr& D_dst, const cudaPitchedPtr& D_src, const SDimensions3D& dims) @@ -252,12 +237,9 @@ bool duplicateVolumeData(cudaPitchedPtr& D_dst, const cudaPitchedPtr& D_src, con p.extent = extentV; p.kind = cudaMemcpyDeviceToDevice; - cudaError err; - err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - - return err == cudaSuccess; + return checkCuda(cudaMemcpy3D(&p), "duplicateVolumeData 3D"); } + bool duplicateProjectionData(cudaPitchedPtr& D_dst, const cudaPitchedPtr& D_src, const SDimensions3D& dims) { cudaExtent extentV; @@ -277,11 +259,7 @@ bool duplicateProjectionData(cudaPitchedPtr& D_dst, const cudaPitchedPtr& D_src, p.extent = extentV; p.kind = cudaMemcpyDeviceToDevice; - cudaError err; - err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - - return err == cudaSuccess; + return checkCuda(cudaMemcpy3D(&p), "duplicateProjectionData 3D"); } @@ -343,12 +321,9 @@ bool transferVolumeToArray(cudaPitchedPtr D_volumeData, cudaArray* array, const p.extent = extentA; p.kind = cudaMemcpyDeviceToDevice; - cudaError err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - // TODO: check errors - - return true; + return checkCuda(cudaMemcpy3D(&p), "transferVolumeToArray 3D"); } + bool transferProjectionsToArray(cudaPitchedPtr D_projData, cudaArray* array, const SDimensions3D& dims) { cudaExtent extentA; @@ -370,13 +345,9 @@ bool transferProjectionsToArray(cudaPitchedPtr D_projData, cudaArray* array, con p.extent = extentA; p.kind = cudaMemcpyDeviceToDevice; - cudaError err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - - // TODO: check errors - - return true; + return checkCuda(cudaMemcpy3D(&p), "transferProjectionsToArray 3D"); } + bool transferHostProjectionsToArray(const float *projData, cudaArray* array, const SDimensions3D& dims) { cudaExtent extentA; @@ -404,12 +375,7 @@ bool transferHostProjectionsToArray(const float *projData, cudaArray* array, con p.extent = extentA; p.kind = cudaMemcpyHostToDevice; - cudaError err = cudaMemcpy3D(&p); - ASTRA_CUDA_ASSERT(err); - - // TODO: check errors - - return true; + return checkCuda(cudaMemcpy3D(&p), "transferHostProjectionsToArray 3D"); } -- cgit v1.2.3 From 39582115bc93b5435d25e56891815ae7cb1898fd Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 16 Nov 2021 13:44:13 +0100 Subject: Remove cudaTextForceKernelsCompletion --- cuda/3d/util3d.cu | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'cuda/3d/util3d.cu') diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu index 4f5d134..71b5668 100644 --- a/cuda/3d/util3d.cu +++ b/cuda/3d/util3d.cu @@ -387,18 +387,6 @@ float dotProduct3D(cudaPitchedPtr data, unsigned int x, unsigned int y, } -bool cudaTextForceKernelsCompletion() -{ - cudaError_t returnedCudaError = cudaThreadSynchronize(); - - if(returnedCudaError != cudaSuccess) { - ASTRA_ERROR("Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError)); - return false; - } - - return true; -} - int calcNextPowerOfTwo(int _iValue) { int iOutput = 1; -- cgit v1.2.3