summaryrefslogtreecommitdiffstats
path: root/cuda
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2021-11-16 11:54:47 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2021-11-16 14:08:56 +0100
commit63de6635ac1e5b232f88e90afdf6492df2682a38 (patch)
tree1659dbb724102422ef1b4d98350d18f762ed86d7 /cuda
parentc6e203411abf3dad3e677aaa1186b927086f8ba7 (diff)
downloadastra-63de6635ac1e5b232f88e90afdf6492df2682a38.tar.gz
astra-63de6635ac1e5b232f88e90afdf6492df2682a38.tar.bz2
astra-63de6635ac1e5b232f88e90afdf6492df2682a38.tar.xz
astra-63de6635ac1e5b232f88e90afdf6492df2682a38.zip
Add checkCufft function
Diffstat (limited to 'cuda')
-rw-r--r--cuda/2d/fft.cu45
1 files changed, 22 insertions, 23 deletions
diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu
index 2cdb7c3..2bb5dc3 100644
--- a/cuda/2d/fft.cu
+++ b/cuda/2d/fft.cu
@@ -67,6 +67,16 @@ using namespace astra;
namespace astraCUDA {
+bool checkCufft(cufftResult err, const char *msg)
+{
+ if (err != CUFFT_SUCCESS) {
+ ASTRA_ERROR("%s: CUFFT error %d.", msg, err);
+ return false;
+ } else {
+ return true;
+ }
+}
+
__global__ static void applyFilter_kernel(int _iProjectionCount,
int _iFreqBinCount,
cufftComplex * _pSinogram,
@@ -136,24 +146,18 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount,
cufftComplex * _pDevTargetComplex)
{
cufftHandle plan;
- cufftResult result;
- result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_R2C, _iProjectionCount);
- if(result != CUFFT_SUCCESS)
- {
- ASTRA_ERROR("Failed to plan 1d r2c fft");
+ if (!checkCufft(cufftPlan1d(&plan, _iDetectorCount, CUFFT_R2C, _iProjectionCount), "invokeCudaFFT plan")) {
return false;
}
- result = cufftExecR2C(plan, (cufftReal *)_pfDevSource, _pDevTargetComplex);
- cufftDestroy(plan);
-
- if(result != CUFFT_SUCCESS)
- {
- ASTRA_ERROR("Failed to exec 1d r2c fft");
+ if (!checkCufft(cufftExecR2C(plan, (cufftReal *)_pfDevSource, _pDevTargetComplex), "invokeCudaFFT exec")) {
+ cufftDestroy(plan);
return false;
}
+ cufftDestroy(plan);
+
return true;
}
@@ -162,26 +166,21 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount,
float * _pfDevTarget)
{
cufftHandle plan;
- cufftResult result;
- result = cufftPlan1d(&plan, _iDetectorCount, CUFFT_C2R, _iProjectionCount);
- if(result != CUFFT_SUCCESS)
- {
- ASTRA_ERROR("Failed to plan 1d c2r fft");
+ if (!checkCufft(cufftPlan1d(&plan, _iDetectorCount, CUFFT_C2R, _iProjectionCount), "invokeCudaIFFT plan")) {
return false;
}
- // todo: why do we have to get rid of the const qualifier?
- result = cufftExecC2R(plan, (cufftComplex *)_pDevSourceComplex,
- (cufftReal *)_pfDevTarget);
- cufftDestroy(plan);
-
- if(result != CUFFT_SUCCESS)
+ // Getting rid of the const qualifier is due to cufft API issue?
+ if (!checkCufft(cufftExecC2R(plan, (cufftComplex *)_pDevSourceComplex,
+ (cufftReal *)_pfDevTarget), "invokeCudaIFFT exec"))
{
- ASTRA_ERROR("Failed to exec 1d c2r fft");
+ cufftDestroy(plan);
return false;
}
+ cufftDestroy(plan);
+
return true;
}