Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAII issue #197

Open
tpadioleau opened this issue Nov 9, 2024 · 0 comments · May be fixed by #208
Open

RAII issue #197

tpadioleau opened this issue Nov 9, 2024 · 0 comments · May be fixed by #208

Comments

@tpadioleau
Copy link
Member

I suspect potential memory leaks.

Consider the snippet

cufftResult cufft_rt = cufftCreate(&(*plan));
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftCreate failed");
cudaStream_t stream = exec_space.cuda_stream();
cufftSetStream((*plan), stream);
auto type = KokkosFFT::Impl::transform_type<ExecutionSpace, in_value_type,
out_value_type>::type();
auto [in_extents, out_extents, fft_extents, howmany] =
KokkosFFT::Impl::get_extents(in, out, axes, s, is_inplace);
const int nx = fft_extents.at(0);
int fft_size = std::accumulate(fft_extents.begin(), fft_extents.end(), 1,
std::multiplies<>());
cufft_rt = cufftPlan1d(&(*plan), nx, type, howmany);
KOKKOSFFT_THROW_IF(cufft_rt != CUFFT_SUCCESS, "cufftPlan1d failed");

It is called inside the Plan constructor. Let's assume the second KOKKOSFFT_THROW_IF actually throws, the backend destroy_plan_and_info function will never be called because the Plan object will never finish construction.

I think we need to adhere to the RAII so that if any exception is thrown the backend plan object gets automatically freed.

@yasahi-hpc yasahi-hpc linked a pull request Dec 3, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant