-
Notifications
You must be signed in to change notification settings - Fork 6
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
Introduce global setup/cleanup in APIs #220
base: main
Are you sure you want to change the base?
Introduce global setup/cleanup in APIs #220
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider leveraging Kokkos::push_finalize_hook()
instead?
Thank you, that is interesting. At least, I can use However, we also need to call |
I overlooked that you actually acquire resources as well. You are correct, I would encourage seriously looking at alternatives. I see the introduction of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fft/src/CMakeLists.txt
Outdated
@@ -2,15 +2,15 @@ | |||
# | |||
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception | |||
|
|||
add_library(fft INTERFACE) | |||
add_library(fft STATIC KokkosFFT_Core.cpp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_library(fft STATIC KokkosFFT_Core.cpp) | |
add_library(fft KokkosFFT_Core.cpp) |
I would not force it to be STATIC
to allow people to use BUILD_SHARED_LIBS
, https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html.
fft/src/KokkosFFT_Core.cpp
Outdated
[[nodiscard]] bool KokkosFFT::is_finalized() noexcept { return g_is_finalized; } | ||
|
||
void KokkosFFT::initialize() { | ||
if (!(Kokkos::is_initialized() || Kokkos::is_finalized())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!(Kokkos::is_initialized() || Kokkos::is_finalized())) { | |
if (!Kokkos::is_initialized()) { |
Do we need to test is_finalized
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to exclude the situation after finalization, where Kokkos::is_initialized()
returns false and Kokkos::is_finalized()
returns true. Accordingly, if we just check Kokkos::is_initialized()
, we do not know whether Kokkos is before initialization or after finalization.
Oh really why ? Are both functions a problem or only |
Makes sense. The alternative solution I have in mind is to rely on static local object which is called at the first time when |
This reverts commit 19bd963.
@tpadioleau @dalg24 |
Fixes #217
This PR aims at addingKokkosFFT::initialize
andKokkosFFT::finalize
in order to correctly handle setup functions which cannot be called more than once.call setup functions offftw
androcfft
inKokkosFFT::initialize
call cleanup functions offftw
androcfft
inKokkosFFT::finalize
Add tests to ensure thatKokkosFFT::initialize
andKokkosFFT::finalize
can only be called when Kokkos is availableAddKokkosFFT::initialize
andKokkosFFT::finalize
in examplesEdited 15/Jan, after discussions we have changed the implementation.
fftw
androcfft
setup function in static local lambda function which is supposed to be called at the first time of API callfftw
androcfft
cleanup function in static local lambda function with Kokkos::push_finalize_hook()