From 7f5a50d5b142fe8aeea22754b9895d1fae25e662 Mon Sep 17 00:00:00 2001
From: Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>
Date: Tue, 16 Nov 2021 11:58:04 +0100
Subject: Add missing synchronize before free in FFT

---
 cuda/2d/fft.cu | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

(limited to 'cuda/2d')

diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu
index 2bb5dc3..413f3aa 100644
--- a/cuda/2d/fft.cu
+++ b/cuda/2d/fft.cu
@@ -156,8 +156,12 @@ static bool invokeCudaFFT(int _iProjectionCount, int _iDetectorCount,
 		return false;
 	}
 
-	cufftDestroy(plan);
+	if (!checkCuda(cudaDeviceSynchronize(), "invokeCudaFFT sync")) {
+		cufftDestroy(plan);
+		return false;
+	}
 
+	cufftDestroy(plan);
 	return true;
 }
 
@@ -179,8 +183,12 @@ static bool invokeCudaIFFT(int _iProjectionCount, int _iDetectorCount,
 		return false;
 	}
 
-	cufftDestroy(plan);
+	if (!checkCuda(cudaDeviceSynchronize(), "invokeCudaIFFT sync")) {
+		cufftDestroy(plan);
+		return false;
+	}
 
+	cufftDestroy(plan);
 	return true;
 }
 
-- 
cgit v1.2.3