From 475b1746c133b0286871b7414918704557f1abcc Mon Sep 17 00:00:00 2001 From: "Daniel M. Pelt" Date: Mon, 9 Mar 2015 15:53:07 +0100 Subject: Remove old Logging code (only used in fft.cu) --- cuda/2d/astra.cu | 3 +-- cuda/2d/fft.cu | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'cuda') diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu index 0b5be06..bcc1a50 100644 --- a/cuda/2d/astra.cu +++ b/cuda/2d/astra.cu @@ -42,7 +42,6 @@ $Id$ #include #include -#include "../../include/astra/Logger.h" #include "../../include/astra/VolumeGeometry2D.h" #include "../../include/astra/ParallelProjectionGeometry2D.h" #include "../../include/astra/FanFlatProjectionGeometry2D.h" @@ -538,7 +537,7 @@ bool AstraFBP::setFilter(E_FBPFILTER _eFilter, const float * _pfHostFilter /* = int iMaxFilterIndex = iStartFilterIndex + iUsedFilterWidth; int iFilterShiftSize = _iFilterWidth / 2; - + for(int iDetectorIndex = iStartFilterIndex; iDetectorIndex < iMaxFilterIndex; iDetectorIndex++) { int iFFTInFilterIndex = (iDetectorIndex + iFFTRealDetCount - iFilterShiftSize) % iFFTRealDetCount; diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu index d105e29..5fef360 100644 --- a/cuda/2d/fft.cu +++ b/cuda/2d/fft.cu @@ -34,7 +34,6 @@ $Id$ #include #include -#include "../../include/astra/Logger.h" using namespace astra; @@ -45,7 +44,6 @@ using namespace astra; if( cudaSuccess != err) { \ fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", \ errorMessage, __FILE__, __LINE__, cudaGetErrorString( err) );\ - CLogger::writeTerminalCUDAError(__FILE__, __LINE__, cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } } while (0) @@ -54,14 +52,12 @@ using namespace astra; if( cudaSuccess != err) { \ fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \ __FILE__, __LINE__, cudaGetErrorString( err) ); \ - CLogger::writeTerminalCUDAError(__FILE__, __LINE__, cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } \ err = cudaThreadSynchronize(); \ if( cudaSuccess != err) { \ fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \ __FILE__, __LINE__, cudaGetErrorString( err) ); \ - CLogger::writeTerminalCUDAError(__FILE__, __LINE__, cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } } while (0) @@ -460,7 +456,7 @@ void genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, const float fA1 = 0.48f; const float fA2 = 0.38f; float fNMinusOne = (float)(_iFFTFourierDetectorCount) - 1.0f; - + for(int iDetectorIndex = 1; iDetectorIndex < _iFFTFourierDetectorCount; iDetectorIndex++) { float fSmallN = (float)iDetectorIndex; @@ -746,7 +742,7 @@ void testCudaFFT() { for(int iDetectorIndex = 0; iDetectorIndex < iDetectorCount; iDetectorIndex++) { -// int +// int // pfHostProj[iIndex] = (float)rand() / (float)RAND_MAX; } @@ -787,7 +783,7 @@ void testCudaFFT() float * pfHostFourProjImaginary = new float[iTotalElementCount]; convertComplexToRealImg(pHostFourProj, iTotalElementCount, pfHostFourProjReal, pfHostFourProjImaginary); - + writeToMatlabFile("proj_four_real.mat", pfHostFourProjReal, iProjectionCount, iDetectorCount); writeToMatlabFile("proj_four_imaginary.mat", pfHostFourProjImaginary, iProjectionCount, iDetectorCount); -- cgit v1.2.3 From 150951875c236f95a64fd132c26576bd19daca80 Mon Sep 17 00:00:00 2001 From: "Daniel M. Pelt" Date: Tue, 10 Mar 2015 15:11:15 +0100 Subject: Use new logging API internally instead of printf / iostream --- cuda/2d/astra.cu | 4 +++- cuda/2d/fft.cu | 31 ++++++++++++++++--------------- cuda/2d/util.cu | 8 +++++--- cuda/3d/util3d.cu | 12 +++++++----- 4 files changed, 31 insertions(+), 24 deletions(-) (limited to 'cuda') diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu index bcc1a50..71fd089 100644 --- a/cuda/2d/astra.cu +++ b/cuda/2d/astra.cu @@ -47,6 +47,8 @@ $Id$ #include "../../include/astra/FanFlatProjectionGeometry2D.h" #include "../../include/astra/FanFlatVecProjectionGeometry2D.h" +#include "../../include/astra/Logging.h" + // For fan beam FBP weighting #include "../3d/fdk.h" @@ -562,7 +564,7 @@ bool AstraFBP::setFilter(E_FBPFILTER _eFilter, const float * _pfHostFilter /* = } default: { - fprintf(stderr, "AstraFBP::setFilter: Unknown filter type requested"); + astra::CLogger::error(__FILE__,__LINE__,"AstraFBP::setFilter: Unknown filter type requested"); delete [] pHostFilter; return false; } diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu index 5fef360..468c7c2 100644 --- a/cuda/2d/fft.cu +++ b/cuda/2d/fft.cu @@ -34,6 +34,7 @@ $Id$ #include #include +#include "../../include/astra/Logging.h" using namespace astra; @@ -42,22 +43,22 @@ using namespace astra; #define CHECK_ERROR(errorMessage) do { \ cudaError_t err = cudaThreadSynchronize(); \ if( cudaSuccess != err) { \ - fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", \ - errorMessage, __FILE__, __LINE__, cudaGetErrorString( err) );\ + astra::CLogger::error(__FILE__,__LINE__,"Cuda error %s : %s", \ + errorMessage,cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } } while (0) #define SAFE_CALL( call) do { \ cudaError err = call; \ if( cudaSuccess != err) { \ - fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \ - __FILE__, __LINE__, cudaGetErrorString( err) ); \ + astra::CLogger::error(__FILE__,__LINE__,"Cuda error: %s ", \ + cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } \ err = cudaThreadSynchronize(); \ if( cudaSuccess != err) { \ - fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \ - __FILE__, __LINE__, cudaGetErrorString( err) ); \ + astra::CLogger::error(__FILE__,__LINE__,"Cuda error: %s : ", \ + cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } } while (0) @@ -136,7 +137,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount, result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_R2C, _iProjectionCount); if(result != CUFFT_SUCCESS) { - std::cerr << "Failed to plan 1d r2c fft" << std::endl; + astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d r2c fft"); return false; } @@ -145,7 +146,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount, if(result != CUFFT_SUCCESS) { - std::cerr << "Failed to exec 1d r2c fft" << std::endl; + astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d r2c fft"); return false; } @@ -162,7 +163,7 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount, result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_C2R, _iProjectionCount); if(result != CUFFT_SUCCESS) { - std::cerr << "Failed to plan 1d c2r fft" << std::endl; + astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d c2r fft"); return false; } @@ -173,7 +174,7 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount, if(result != CUFFT_SUCCESS) { - std::cerr << "Failed to exec 1d c2r fft" << std::endl; + astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d c2r fft"); return false; } @@ -629,7 +630,7 @@ void genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, } default: { - std::cerr << "Cannot serve requested filter" << std::endl; + astra::CLogger::error(__FILE__,__LINE__,"Cannot serve requested filter"); } } @@ -763,13 +764,13 @@ void testCudaFFT() result = cufftPlan1d(&plan, iDetectorCount, CUFFT_R2C, iProjectionCount); if(result != CUFFT_SUCCESS) { - cerr << "Failed to plan 1d r2c fft" << endl; + astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d r2c fft"); } result = cufftExecR2C(plan, pfDevProj, pDevFourProj); if(result != CUFFT_SUCCESS) { - cerr << "Failed to exec 1d r2c fft" << endl; + astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d r2c fft"); } cufftDestroy(plan); @@ -793,13 +794,13 @@ void testCudaFFT() result = cufftPlan1d(&plan, iDetectorCount, CUFFT_C2R, iProjectionCount); if(result != CUFFT_SUCCESS) { - cerr << "Failed to plan 1d c2r fft" << endl; + astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d c2r fft"); } result = cufftExecC2R(plan, pDevFourProj, pfDevInFourProj); if(result != CUFFT_SUCCESS) { - cerr << "Failed to exec 1d c2r fft" << endl; + astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d c2r fft"); } cufftDestroy(plan); diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu index 81e368f..6ced557 100644 --- a/cuda/2d/util.cu +++ b/cuda/2d/util.cu @@ -30,6 +30,8 @@ $Id$ #include #include "util.h" +#include "../../include/astra/Logging.h" + namespace astraCUDA { bool copyVolumeToDevice(const float* in_data, unsigned int in_pitch, @@ -91,7 +93,7 @@ bool allocateVolume(float*& ptr, unsigned int width, unsigned int height, unsign cudaError_t ret = cudaMallocPitch((void**)&ptr, &p, sizeof(float)*width, height); if (ret != cudaSuccess) { reportCudaError(ret); - fprintf(stderr, "Failed to allocate %dx%d GPU buffer\n", width, height); + astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%d GPU buffer", width, height); return false; } @@ -259,7 +261,7 @@ bool cudaTextForceKernelsCompletion() cudaError_t returnedCudaError = cudaThreadSynchronize(); if(returnedCudaError != cudaSuccess) { - fprintf(stderr, "Failed to force completion of cuda kernels: %d: %s.\n", returnedCudaError, cudaGetErrorString(returnedCudaError)); + astra::CLogger::error(__FILE__,__LINE__,"Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError)); return false; } @@ -269,7 +271,7 @@ bool cudaTextForceKernelsCompletion() void reportCudaError(cudaError_t err) { if(err != cudaSuccess) - fprintf(stderr, "CUDA error %d: %s.\n", err, cudaGetErrorString(err)); + astra::CLogger::error(__FILE__,__LINE__,"CUDA error %d: %s.", err, cudaGetErrorString(err)); } diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu index d85a928..f2d16b3 100644 --- a/cuda/3d/util3d.cu +++ b/cuda/3d/util3d.cu @@ -31,6 +31,8 @@ $Id$ #include "util3d.h" #include "../2d/util.h" +#include "../../include/astra/Logging.h" + namespace astraCUDA3d { @@ -46,7 +48,7 @@ cudaPitchedPtr allocateVolumeData(const SDimensions3D& dims) cudaError err = cudaMalloc3D(&volData, extentV); if (err != cudaSuccess) { astraCUDA::reportCudaError(err); - fprintf(stderr, "Failed to allocate %dx%dx%d GPU buffer\n", dims.iVolX, dims.iVolY, dims.iVolZ); + astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU buffer", dims.iVolX, dims.iVolY, dims.iVolZ); volData.ptr = 0; // TODO: return 0 somehow? } @@ -65,7 +67,7 @@ cudaPitchedPtr allocateProjectionData(const SDimensions3D& dims) cudaError err = cudaMalloc3D(&projData, extentP); if (err != cudaSuccess) { astraCUDA::reportCudaError(err); - fprintf(stderr, "Failed to allocate %dx%dx%d GPU buffer\n", dims.iProjU, dims.iProjAngles, dims.iProjV); + astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU buffer", dims.iProjU, dims.iProjAngles, dims.iProjV); projData.ptr = 0; // TODO: return 0 somehow? } @@ -303,7 +305,7 @@ cudaArray* allocateVolumeArray(const SDimensions3D& dims) cudaError err = cudaMalloc3DArray(&cuArray, &channelDesc, extentA); if (err != cudaSuccess) { astraCUDA::reportCudaError(err); - fprintf(stderr, "Failed to allocate %dx%dx%d GPU array\n", dims.iVolX, dims.iVolY, dims.iVolZ); + astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU array", dims.iVolX, dims.iVolY, dims.iVolZ); return 0; } @@ -321,7 +323,7 @@ cudaArray* allocateProjectionArray(const SDimensions3D& dims) if (err != cudaSuccess) { astraCUDA::reportCudaError(err); - fprintf(stderr, "Failed to allocate %dx%dx%d GPU array\n", dims.iProjU, dims.iProjAngles, dims.iProjV); + astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU array", dims.iProjU, dims.iProjAngles, dims.iProjV); return 0; } @@ -397,7 +399,7 @@ bool cudaTextForceKernelsCompletion() cudaError_t returnedCudaError = cudaThreadSynchronize(); if(returnedCudaError != cudaSuccess) { - fprintf(stderr, "Failed to force completion of cuda kernels: %d: %s.\n", returnedCudaError, cudaGetErrorString(returnedCudaError)); + astra::CLogger::error(__FILE__,__LINE__,"Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError)); return false; } -- cgit v1.2.3 From c5507b6ef2abfab169150528a374526bb348bf62 Mon Sep 17 00:00:00 2001 From: "Daniel M. Pelt" Date: Fri, 13 Mar 2015 12:18:21 +0100 Subject: Adds ASTRA_*** defines for easier logging, and changes internal calls to these defines --- cuda/2d/astra.cu | 2 +- cuda/2d/fft.cu | 24 ++++++++++++------------ cuda/2d/util.cu | 6 +++--- cuda/3d/util3d.cu | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) (limited to 'cuda') diff --git a/cuda/2d/astra.cu b/cuda/2d/astra.cu index 71fd089..2f72db0 100644 --- a/cuda/2d/astra.cu +++ b/cuda/2d/astra.cu @@ -564,7 +564,7 @@ bool AstraFBP::setFilter(E_FBPFILTER _eFilter, const float * _pfHostFilter /* = } default: { - astra::CLogger::error(__FILE__,__LINE__,"AstraFBP::setFilter: Unknown filter type requested"); + ASTRA_ERROR("AstraFBP::setFilter: Unknown filter type requested"); delete [] pHostFilter; return false; } diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu index 468c7c2..49c696c 100644 --- a/cuda/2d/fft.cu +++ b/cuda/2d/fft.cu @@ -43,7 +43,7 @@ using namespace astra; #define CHECK_ERROR(errorMessage) do { \ cudaError_t err = cudaThreadSynchronize(); \ if( cudaSuccess != err) { \ - astra::CLogger::error(__FILE__,__LINE__,"Cuda error %s : %s", \ + ASTRA_ERROR("Cuda error %s : %s", \ errorMessage,cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } } while (0) @@ -51,13 +51,13 @@ using namespace astra; #define SAFE_CALL( call) do { \ cudaError err = call; \ if( cudaSuccess != err) { \ - astra::CLogger::error(__FILE__,__LINE__,"Cuda error: %s ", \ + ASTRA_ERROR("Cuda error: %s ", \ cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } \ err = cudaThreadSynchronize(); \ if( cudaSuccess != err) { \ - astra::CLogger::error(__FILE__,__LINE__,"Cuda error: %s : ", \ + ASTRA_ERROR("Cuda error: %s : ", \ cudaGetErrorString( err)); \ exit(EXIT_FAILURE); \ } } while (0) @@ -137,7 +137,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount, result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_R2C, _iProjectionCount); if(result != CUFFT_SUCCESS) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d r2c fft"); + ASTRA_ERROR("Failed to plan 1d r2c fft"); return false; } @@ -146,7 +146,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount, if(result != CUFFT_SUCCESS) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d r2c fft"); + ASTRA_ERROR("Failed to exec 1d r2c fft"); return false; } @@ -163,7 +163,7 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount, result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_C2R, _iProjectionCount); if(result != CUFFT_SUCCESS) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d c2r fft"); + ASTRA_ERROR("Failed to plan 1d c2r fft"); return false; } @@ -174,7 +174,7 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount, if(result != CUFFT_SUCCESS) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d c2r fft"); + ASTRA_ERROR("Failed to exec 1d c2r fft"); return false; } @@ -630,7 +630,7 @@ void genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, } default: { - astra::CLogger::error(__FILE__,__LINE__,"Cannot serve requested filter"); + ASTRA_ERROR("Cannot serve requested filter"); } } @@ -764,13 +764,13 @@ void testCudaFFT() result = cufftPlan1d(&plan, iDetectorCount, CUFFT_R2C, iProjectionCount); if(result != CUFFT_SUCCESS) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d r2c fft"); + ASTRA_ERROR("Failed to plan 1d r2c fft"); } result = cufftExecR2C(plan, pfDevProj, pDevFourProj); if(result != CUFFT_SUCCESS) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d r2c fft"); + ASTRA_ERROR("Failed to exec 1d r2c fft"); } cufftDestroy(plan); @@ -794,13 +794,13 @@ void testCudaFFT() result = cufftPlan1d(&plan, iDetectorCount, CUFFT_C2R, iProjectionCount); if(result != CUFFT_SUCCESS) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to plan 1d c2r fft"); + ASTRA_ERROR("Failed to plan 1d c2r fft"); } result = cufftExecC2R(plan, pDevFourProj, pfDevInFourProj); if(result != CUFFT_SUCCESS) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to exec 1d c2r fft"); + ASTRA_ERROR("Failed to exec 1d c2r fft"); } cufftDestroy(plan); diff --git a/cuda/2d/util.cu b/cuda/2d/util.cu index 6ced557..a4f8f3e 100644 --- a/cuda/2d/util.cu +++ b/cuda/2d/util.cu @@ -93,7 +93,7 @@ bool allocateVolume(float*& ptr, unsigned int width, unsigned int height, unsign cudaError_t ret = cudaMallocPitch((void**)&ptr, &p, sizeof(float)*width, height); if (ret != cudaSuccess) { reportCudaError(ret); - astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%d GPU buffer", width, height); + ASTRA_ERROR("Failed to allocate %dx%d GPU buffer", width, height); return false; } @@ -261,7 +261,7 @@ bool cudaTextForceKernelsCompletion() cudaError_t returnedCudaError = cudaThreadSynchronize(); if(returnedCudaError != cudaSuccess) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError)); + ASTRA_ERROR("Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError)); return false; } @@ -271,7 +271,7 @@ bool cudaTextForceKernelsCompletion() void reportCudaError(cudaError_t err) { if(err != cudaSuccess) - astra::CLogger::error(__FILE__,__LINE__,"CUDA error %d: %s.", err, cudaGetErrorString(err)); + ASTRA_ERROR("CUDA error %d: %s.", err, cudaGetErrorString(err)); } diff --git a/cuda/3d/util3d.cu b/cuda/3d/util3d.cu index f2d16b3..537ed69 100644 --- a/cuda/3d/util3d.cu +++ b/cuda/3d/util3d.cu @@ -48,7 +48,7 @@ cudaPitchedPtr allocateVolumeData(const SDimensions3D& dims) cudaError err = cudaMalloc3D(&volData, extentV); if (err != cudaSuccess) { astraCUDA::reportCudaError(err); - astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU buffer", dims.iVolX, dims.iVolY, dims.iVolZ); + ASTRA_ERROR("Failed to allocate %dx%dx%d GPU buffer", dims.iVolX, dims.iVolY, dims.iVolZ); volData.ptr = 0; // TODO: return 0 somehow? } @@ -67,7 +67,7 @@ cudaPitchedPtr allocateProjectionData(const SDimensions3D& dims) cudaError err = cudaMalloc3D(&projData, extentP); if (err != cudaSuccess) { astraCUDA::reportCudaError(err); - astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU buffer", dims.iProjU, dims.iProjAngles, dims.iProjV); + ASTRA_ERROR("Failed to allocate %dx%dx%d GPU buffer", dims.iProjU, dims.iProjAngles, dims.iProjV); projData.ptr = 0; // TODO: return 0 somehow? } @@ -305,7 +305,7 @@ cudaArray* allocateVolumeArray(const SDimensions3D& dims) cudaError err = cudaMalloc3DArray(&cuArray, &channelDesc, extentA); if (err != cudaSuccess) { astraCUDA::reportCudaError(err); - astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU array", dims.iVolX, dims.iVolY, dims.iVolZ); + ASTRA_ERROR("Failed to allocate %dx%dx%d GPU array", dims.iVolX, dims.iVolY, dims.iVolZ); return 0; } @@ -323,7 +323,7 @@ cudaArray* allocateProjectionArray(const SDimensions3D& dims) if (err != cudaSuccess) { astraCUDA::reportCudaError(err); - astra::CLogger::error(__FILE__,__LINE__,"Failed to allocate %dx%dx%d GPU array", dims.iProjU, dims.iProjAngles, dims.iProjV); + ASTRA_ERROR("Failed to allocate %dx%dx%d GPU array", dims.iProjU, dims.iProjAngles, dims.iProjV); return 0; } @@ -399,7 +399,7 @@ bool cudaTextForceKernelsCompletion() cudaError_t returnedCudaError = cudaThreadSynchronize(); if(returnedCudaError != cudaSuccess) { - astra::CLogger::error(__FILE__,__LINE__,"Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError)); + ASTRA_ERROR("Failed to force completion of cuda kernels: %d: %s.", returnedCudaError, cudaGetErrorString(returnedCudaError)); return false; } -- cgit v1.2.3 From 10d35e96221675fc62299ba0cfdb0d731c9c7531 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 20 Mar 2015 14:03:44 +0100 Subject: Fix indentation --- cuda/2d/fft.cu | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'cuda') diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu index 49c696c..2bfd493 100644 --- a/cuda/2d/fft.cu +++ b/cuda/2d/fft.cu @@ -137,7 +137,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount, result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_R2C, _iProjectionCount); if(result != CUFFT_SUCCESS) { - ASTRA_ERROR("Failed to plan 1d r2c fft"); + ASTRA_ERROR("Failed to plan 1d r2c fft"); return false; } @@ -146,7 +146,7 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount, if(result != CUFFT_SUCCESS) { - ASTRA_ERROR("Failed to exec 1d r2c fft"); + ASTRA_ERROR("Failed to exec 1d r2c fft"); return false; } @@ -163,18 +163,18 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount, result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_C2R, _iProjectionCount); if(result != CUFFT_SUCCESS) { - ASTRA_ERROR("Failed to plan 1d c2r fft"); + ASTRA_ERROR("Failed to plan 1d c2r fft"); return false; } // todo: why do we have to get rid of the const qualifier? result = cufftExecC2R(plan, (cufftComplex *)_pDevSourceComplex, - (cufftReal *)_pfDevTarget); + (cufftReal *)_pfDevTarget); cufftDestroy(plan); if(result != CUFFT_SUCCESS) { - ASTRA_ERROR("Failed to exec 1d c2r fft"); + ASTRA_ERROR("Failed to exec 1d c2r fft"); return false; } @@ -254,7 +254,7 @@ bool runCudaIFFT(int _iProjectionCount, const cufftComplex* _pDevSourceComplex, } rescaleInverseFourier(_iProjectionCount, _iFFTRealDetectorCount, - pfDevRealFFTTarget); + pfDevRealFFTTarget); SAFE_CALL(cudaMemset(_pfRealTarget, 0, sizeof(float) * _iProjectionCount * _iTargetPitch)); @@ -630,7 +630,7 @@ void genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, } default: { - ASTRA_ERROR("Cannot serve requested filter"); + ASTRA_ERROR("Cannot serve requested filter"); } } @@ -764,13 +764,13 @@ void testCudaFFT() result = cufftPlan1d(&plan, iDetectorCount, CUFFT_R2C, iProjectionCount); if(result != CUFFT_SUCCESS) { - ASTRA_ERROR("Failed to plan 1d r2c fft"); + ASTRA_ERROR("Failed to plan 1d r2c fft"); } result = cufftExecR2C(plan, pfDevProj, pDevFourProj); if(result != CUFFT_SUCCESS) { - ASTRA_ERROR("Failed to exec 1d r2c fft"); + ASTRA_ERROR("Failed to exec 1d r2c fft"); } cufftDestroy(plan); @@ -794,13 +794,13 @@ void testCudaFFT() result = cufftPlan1d(&plan, iDetectorCount, CUFFT_C2R, iProjectionCount); if(result != CUFFT_SUCCESS) { - ASTRA_ERROR("Failed to plan 1d c2r fft"); + ASTRA_ERROR("Failed to plan 1d c2r fft"); } result = cufftExecC2R(plan, pDevFourProj, pfDevInFourProj); if(result != CUFFT_SUCCESS) { - ASTRA_ERROR("Failed to exec 1d c2r fft"); + ASTRA_ERROR("Failed to exec 1d c2r fft"); } cufftDestroy(plan); -- cgit v1.2.3 From 3042b1369a96eef4798ea4280dd7aa1a8be2fcca Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 30 Mar 2015 17:17:54 +0200 Subject: Initialize variables to avoid warning These variables are never used when uninitialized, but Visual Studio complains about them. --- cuda/2d/par_fp.cu | 2 +- cuda/3d/cone_fp.cu | 2 +- cuda/3d/par3d_fp.cu | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'cuda') diff --git a/cuda/2d/par_fp.cu b/cuda/2d/par_fp.cu index d0ca7ff..bb8b909 100644 --- a/cuda/2d/par_fp.cu +++ b/cuda/2d/par_fp.cu @@ -487,7 +487,7 @@ bool FP_simple_internal(float* D_volumeData, unsigned int volumePitch, unsigned int blockEnd = 0; bool blockVertical = false; for (unsigned int a = 0; a <= dims.iProjAngles; ++a) { - bool vertical; + bool vertical = false; // TODO: Having <= instead of < below causes a 5% speedup. // Maybe we should detect corner cases and put them in the optimal // group of angles. diff --git a/cuda/3d/cone_fp.cu b/cuda/3d/cone_fp.cu index bda71ba..b36d2bc 100644 --- a/cuda/3d/cone_fp.cu +++ b/cuda/3d/cone_fp.cu @@ -340,7 +340,7 @@ bool ConeFP_Array_internal(cudaPitchedPtr D_projData, // tic(t); for (unsigned int a = 0; a <= angleCount; ++a) { - int dir; + int dir = -1; if (a != angleCount) { float dX = fabsf(angles[a].fSrcX - (angles[a].fDetSX + dims.iProjU*angles[a].fDetUX*0.5f + dims.iProjV*angles[a].fDetVX*0.5f)); float dY = fabsf(angles[a].fSrcY - (angles[a].fDetSY + dims.iProjU*angles[a].fDetUY*0.5f + dims.iProjV*angles[a].fDetVY*0.5f)); diff --git a/cuda/3d/par3d_fp.cu b/cuda/3d/par3d_fp.cu index 8d44540..b14c494 100644 --- a/cuda/3d/par3d_fp.cu +++ b/cuda/3d/par3d_fp.cu @@ -440,7 +440,7 @@ bool Par3DFP_Array_internal(cudaPitchedPtr D_projData, // tic(t); for (unsigned int a = 0; a <= angleCount; ++a) { - int dir; + int dir = -1; if (a != dims.iProjAngles) { float dX = fabsf(angles[a].fRayX); float dY = fabsf(angles[a].fRayY); -- cgit v1.2.3 From 4bb0a8cfc636582daa8ad62fc2f957239556be81 Mon Sep 17 00:00:00 2001 From: Valerii Sokolov Date: Thu, 9 Apr 2015 13:14:01 +0200 Subject: Fixed a few CUDA 2D DART bugs. * Mixed width and height led to incorrect work on rectangular images. * Incorrect weight calculation in `devDartSmoothingRadius` (#47). --- cuda/2d/darthelper.cu | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'cuda') diff --git a/cuda/2d/darthelper.cu b/cuda/2d/darthelper.cu index 28ca557..1d10d49 100644 --- a/cuda/2d/darthelper.cu +++ b/cuda/2d/darthelper.cu @@ -57,7 +57,7 @@ void roiSelect(float* out, float radius, unsigned int width, unsigned int height // We abuse dims here... SDimensions dims; dims.iVolWidth = width; - dims.iVolHeight = width; + dims.iVolHeight = height; allocateVolumeData(D_data, pitch, dims); copyVolumeToDevice(out, width, dims, D_data, pitch); @@ -245,7 +245,7 @@ void dartMask(float* mask, const float* segmentation, unsigned int conn, unsigne // We abuse dims here... SDimensions dims; dims.iVolWidth = width; - dims.iVolHeight = width; + dims.iVolHeight = height; allocateVolumeData(D_segmentationData, pitch, dims); copyVolumeToDevice(segmentation, width, dims, D_segmentationData, pitch); @@ -278,7 +278,7 @@ __global__ void devDartSmoothingRadius(float* out, const float* in, float b, uns unsigned int x = threadIdx.x + 16*blockIdx.x; unsigned int y = threadIdx.y + 16*blockIdx.y; - // Sacrifice the border pixels to simplify the implementation. + // Sacrifice the border pixels to simplify the implementation. if (x > radius-1 && x < width - radius && y > radius-1 && y < height - radius) { float* d = (float*)in; @@ -286,9 +286,10 @@ __global__ void devDartSmoothingRadius(float* out, const float* in, float b, uns unsigned int o2 = y*pitch+x; int r = radius; + float count = 4*r*(r+1); float res = -d[o2]; - for (int row = -r; row < r; row++) + for (int row = -r; row <= r; row++) { unsigned int o1 = (y+row)*pitch+x; for (int col = -r; col <= r; col++) @@ -297,7 +298,7 @@ __global__ void devDartSmoothingRadius(float* out, const float* in, float b, uns } } - res *= b / 4*r*(r+1); + res *= b / count; res += (1.0f-b) * d[o2]; m[o2] = res; @@ -333,7 +334,7 @@ void dartSmoothing(float* out, const float* in, float b, unsigned int radius, un // We abuse dims here... SDimensions dims; dims.iVolWidth = width; - dims.iVolHeight = width; + dims.iVolHeight = height; allocateVolumeData(D_inData, pitch, dims); copyVolumeToDevice(in, width, dims, D_inData, pitch); -- cgit v1.2.3