Skip to content

Commit

Permalink
WIP added warning when plan creation/destruction fails
Browse files Browse the repository at this point in the history
  • Loading branch information
FMarno committed Mar 30, 2023
1 parent e6478b4 commit f29c788
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/dft/backends/cufft/commit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,20 @@ class cufft_commit final : public dft::detail::commit_impl<prec, dom> {

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<prec, dom>& config_values) override {
cuCtxSynchronize();
// this could be a recommit
clean_plans();

Expand Down Expand Up @@ -153,6 +159,8 @@ class cufft_commit final : public dft::detail::commit_impl<prec, dom> {

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.
Expand All @@ -170,11 +178,10 @@ class cufft_commit final : public dft::detail::commit_impl<prec, dom> {
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 {
Expand Down

0 comments on commit f29c788

Please sign in to comment.