Skip to content

Commit 31eb58b

Browse files
authored
Merge pull request kokkos#5390 from crtrott/fix-atexit-isse
[3.7] Force creation of the cuda_deep_space instance during init
2 parents f97e700 + 7b1684d commit 31eb58b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/src/Cuda/Kokkos_Cuda_Instance.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,14 @@ int Cuda::impl_is_initialized() {
861861

862862
void Cuda::impl_initialize(InitializationSettings const &settings) {
863863
Impl::CudaInternal::singleton().initialize(Impl::get_gpu(settings));
864+
865+
// In order to support setting an atexit hook for Kokkos::finalize
866+
// We need to ensure that the Cuda deep_copy instance is not destroyed
867+
// before that atexit hook is getting called.
868+
// Thus we create the static instance here, so that it will be deallocated
869+
// after the potential atexit call.
870+
// This is neccessary since we will access that instance in Kokkos::finalize
871+
(void)::Kokkos::Impl::cuda_get_deep_copy_space(true);
864872
}
865873

866874
std::vector<unsigned> Cuda::detect_device_arch() {

0 commit comments

Comments
 (0)