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/2d/util.cu | 10 +--------- cuda/3d/util3d.cu | 19 +++++-------------- include/astra/cuda/2d/util.h | 3 +-- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu index ce652cb..1c7f6f0 100644 --- a/cuda/2d/util.cu +++ b/cuda/2d/util.cu @@ -90,9 +90,7 @@ bool copySinogramToDevice(const float* in_data, unsigned int in_pitch, bool allocateVolume(float*& ptr, unsigned int width, unsigned int height, unsigned int& pitch) { size_t p; - cudaError_t ret = cudaMallocPitch((void**)&ptr, &p, sizeof(float)*width, height); - if (ret != cudaSuccess) { - reportCudaError(ret); + if (!checkCuda(cudaMallocPitch((void**)&ptr, &p, sizeof(float)*width, height), "allocateVolume")) { ASTRA_ERROR("Failed to allocate %dx%d GPU buffer", width, height); return false; } @@ -268,12 +266,6 @@ bool cudaTextForceKernelsCompletion() return true; } -void reportCudaError(cudaError_t err) -{ - if(err != cudaSuccess) - ASTRA_ERROR("CUDA error %d: %s.", err, cudaGetErrorString(err)); -} - bool checkCuda(cudaError_t err, const char *msg) { if (err != cudaSuccess) { 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; } diff --git a/include/astra/cuda/2d/util.h b/include/astra/cuda/2d/util.h index a7bba89..9eeb561 100644 --- a/include/astra/cuda/2d/util.h +++ b/include/astra/cuda/2d/util.h @@ -40,7 +40,7 @@ along with the ASTRA Toolbox. If not, see . #define M_PI 3.14159265358979323846 #endif -#define ASTRA_CUDA_ASSERT(err) do { if (err != cudaSuccess) { astraCUDA::reportCudaError(err); assert(err == cudaSuccess); } } while(0) +#define ASTRA_CUDA_ASSERT(err) do { if (!checkCuda(err, __FUNCTION__)) { assert(err == cudaSuccess); } } while(0) namespace astraCUDA { @@ -72,7 +72,6 @@ void duplicateProjectionData(float* D_dst, float* D_src, unsigned int pitch, con bool cudaTextForceKernelsCompletion(); -void reportCudaError(cudaError_t err); bool checkCuda(cudaError_t err, const char *msg); -- cgit v1.2.1