-
Notifications
You must be signed in to change notification settings - Fork 407
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
Kokkos::Serial::is_initialized always true #1184
Comments
Change this function to return a boolean which actually reflects the state of initialize/finalize calls. Also remove the calls to Profiling::initialize, because those are already handled in Kokkos::initialize. [#1184]
Huh, this is good to know. I've been simplifying how Tpetra initializes Kokkos, and due to #1060, my changes would have used the initialization status of the default execution space as a proxy for Kokkos' initialization state. Good to know that |
@ibaned I'm tempted to apply it to Trilinos first, and reply if necessary until it gets merged in to Kokkos master. Would you object to this, post review? |
@mhoemmen hopefully the Kokkos team can discuss this a bit at our noon meeting today, and come up with a plan. I'm all for applying it ASAP. If we decide we don't want to disrupt the promotion too much, we can patch it onto Trilinos using the checkin script either before or after the new Kokkos snapshot. |
The global Kokkos::is_initialized() works correctly (it is on the current develop branch waiting to be push to master with the current promotion). The individual execution space initialize/finalize are being rewritten to call the global initialize/finalize and in version 3 of Kokkos they will be move to the Kokkos::Impl namespace. The main difficulty in replacing the individual execution space initialize/finalize with the global stems from trying to reinitialize the Cuda execution space. The OpenMP, Threads, and Serial execution spaces can be safely reinitialized. I haven't tested the OpenMPTarget, Qthreads, or ROCm backends. For example consider the following code Kokkos::OpenMP::initialize(nt); // calls Kokkos::initialize(), Cuda initialized to GPU 0
Kokkos::Cuda::initialize(1); // Problematic: tries to reinitialize Cuda to GPU 1 A better way of doing this is to not call the individuals initializes at all. Kokkos::InitArguments args;
args.num_threads = nt;
args.device_id = 1;
Kokkos::initialize(args); |
@dsunder does |
The global Kokkos::is_initialized currently only checks if the global Kokkos::initialize(...) has been called. |
That works for my purposes! Thanks |
Kokkos::Serial::is_initialized always returned one, which breaks the way that libraries decide to call Kokkos::initialize and Kokkos::finalize, causing memory leaks. I am patching this in Trilinos immediately because the Kokkos promotion is taking too long. Once the Kokkos promotion is done, users are encouraged to instead call the long-awaited Kokkos::is_initialized function instead.
Looks like this broke our nightlies |
I believe what needs to happen is that kokkos initialize initializes serial always if it is configure time enabled, ie even if openmp is on |
I have a library that does
The problem is that
Kokkos::Serial::is_initialized()
is hardcoded to always return true (actually, theint
1
, which is also inconsistent with thebool
return types of other exec spaces).Until
Kokkos::is_initialized
exists (#1060), this is the only way I know to properly protect calls toKokkos::initialize
within downstream library initialize calls.Furthermore,
Kokkos::Serial
actually does manage scratch memory, so if itsfinalize
method is not called then memory is leaked and my tests fail under Valgrind.Edit: downstream*
The text was updated successfully, but these errors were encountered: