Skip to content
Snippets Groups Projects
Commit 135b4989 authored by Vicente Bolea's avatar Vicente Bolea Committed by Kitware Robot
Browse files

Merge topic 'kokkos-auto-init-backport' into release-2.1


863e80a4 Automatically initialize Kokkos

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Vicente Bolea's avatarVicente Bolea <vicente.bolea@kitware.com>
Merge-request: !3289
parents 9d5c9699 863e80a4
No related branches found
No related tags found
No related merge requests found
## Automatically initialize Kokkos
Calling `vtkm::cont::Initialize()` is supposed to be optional. However, Kokkos
needs to have `Kokkos::initialize()` called before using some devices such as
HIP. To make sure that Kokkos is properly initialized, the VTK-m allocation for
the Kokkos device now checks to see if `Kokkos::is_initialized()` is true. If it
is not, then `vtkm::cont::Initialize()` is called.
......@@ -10,6 +10,8 @@
#include <vtkm/cont/kokkos/internal/KokkosAlloc.h>
#include <vtkm/cont/ErrorBadAllocation.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/cont/kokkos/internal/KokkosTypes.h>
#include <sstream>
......@@ -25,6 +27,13 @@ namespace internal
void* Allocate(std::size_t size)
{
if (!Kokkos::is_initialized())
{
VTKM_LOG_F(vtkm::cont::LogLevel::Info,
"Allocating device memory before Kokkos has been initialized. Calling "
"vtkm::cont::Initialize.");
vtkm::cont::Initialize();
}
try
{
return Kokkos::kokkos_malloc<ExecutionSpace::memory_space>(size);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment