diff --git a/image_analysis/indexing/CUDAMemHelpers.h b/image_analysis/indexing/CUDAMemHelpers.h index 0aa741556..6d2db7ad0 100644 --- a/image_analysis/indexing/CUDAMemHelpers.h +++ b/image_analysis/indexing/CUDAMemHelpers.h @@ -128,6 +128,13 @@ public: throw JFJochException(JFJochExceptionCategory::GPUCUDAError, GPUMemoryFailure("Creating the CUFFT plan (cufftPlanMany)", 0, true, ("cuFFT error " + std::to_string(r)).c_str())); + // The plan's setup can still be queued on the NULL stream when cufftPlanMany returns, and a + // non-blocking stream (CudaStream) does not wait for it: a transform launched on one straight + // away read the plan's tables before they were there - an illegal address in 3 of 4 runs where + // a rotation pool built its FFT indexers at transform length 3072. Waiting here orders it. + if (cudaStreamSynchronize(nullptr) != cudaSuccess) + throw JFJochException(JFJochExceptionCategory::GPUCUDAError, + "Creating the CUFFT plan: setup on the NULL stream failed"); } // Convenience overload for vector input