From f29c788c31b69ecbb60997a471cd348a8691a9e6 Mon Sep 17 00:00:00 2001 From: Finlay Marno Date: Thu, 30 Mar 2023 17:46:21 +0100 Subject: [PATCH] WIP added warning when plan creation/destruction fails --- src/dft/backends/cufft/commit.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/dft/backends/cufft/commit.cpp b/src/dft/backends/cufft/commit.cpp index e81db7528..a9f1f3654 100644 --- a/src/dft/backends/cufft/commit.cpp +++ b/src/dft/backends/cufft/commit.cpp @@ -60,14 +60,20 @@ class cufft_commit final : public dft::detail::commit_impl { void clean_plans() { if (plans) { - cufftDestroy(plans.value()[0]); - cufftDestroy(plans.value()[1]); + if (cufftDestroy(plans.value()[0]) != CUFFT_SUCCESS) { + throw mkl::exception("dft/backends/cufft", __FUNCTION__, + "Failed to destroy forward cuFFT plan."); + } + if (cufftDestroy(plans.value()[1]) != CUFFT_SUCCESS) { + throw mkl::exception("dft/backends/cufft", __FUNCTION__, + "Failed to destroy backward cuFFT plan."); + } + plans = std::nullopt; } } void commit(const dft::detail::dft_values& config_values) override { - cuCtxSynchronize(); // this could be a recommit clean_plans(); @@ -153,6 +159,8 @@ class cufft_commit final : public dft::detail::commit_impl { if (res != CUFFT_SUCCESS) { std::cout << "bad fwd\n"; + throw mkl::exception("dft/backends/cufft", __FUNCTION__, + "Failed to create forward cuFFT plan."); } // flip fwd_distance and bwd_distance because cuFFt uses input distance and output distance. @@ -170,11 +178,10 @@ class cufft_commit final : public dft::detail::commit_impl { batch // batch ); if (res != CUFFT_SUCCESS) { - std::cout << "bad bwd\n"; + throw mkl::exception("dft/backends/cufft", __FUNCTION__, + "Failed to create backward cuFFT plan."); } plans = { fwd_plan, bwd_plan }; - - cuCtxSynchronize(); } ~cufft_commit() override {