From b9a811c635478e1998fa83bd38a50fba5b6bf33e Mon Sep 17 00:00:00 2001 From: Ana Gainaru Date: Tue, 2 May 2023 16:28:55 -0400 Subject: [PATCH 1/2] Adding functionality to check where a buffer is allocated for HIP memory space --- source/adios2/helper/adiosKokkos.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/adios2/helper/adiosKokkos.cpp b/source/adios2/helper/adiosKokkos.cpp index 4916f079cb..763903a582 100644 --- a/source/adios2/helper/adiosKokkos.cpp +++ b/source/adios2/helper/adiosKokkos.cpp @@ -89,6 +89,15 @@ bool IsGPUbuffer(const void *ptr) { return true; } +#endif +#ifdef ADIOS2_HAVE_KOKKOS_HIP + hipError_t ret; + hipPointerAttribute_t attr; + ret = hipPointerGetAttributes(&attr, ptr); + if (ret == hipSuccess && attr.memoryType == hipMemoryTypeDevice) + { + return true; + } #endif return false; } From a17eda294ca5a3d30de65a4698ea29859dc8aba4 Mon Sep 17 00:00:00 2001 From: Ana Gainaru Date: Tue, 2 May 2023 16:33:35 -0400 Subject: [PATCH 2/2] Adding functionality to set the device id for HIP memory space --- source/adios2/helper/adiosKokkos.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/adios2/helper/adiosKokkos.cpp b/source/adios2/helper/adiosKokkos.cpp index 763903a582..7a9f53c66b 100644 --- a/source/adios2/helper/adiosKokkos.cpp +++ b/source/adios2/helper/adiosKokkos.cpp @@ -111,6 +111,15 @@ void KokkosInit() int device_id; cudaGetDevice(&device_id); settings.set_device_id(device_id); +#endif +#ifdef ADIOS2_HAVE_KOKKOS_HIP + int device_id; + hipError_t ret; + ret = hipGetDevice(&device_id); + if (ret == hipSuccess) + { + settings.set_device_id(device_id); + } #endif Kokkos::initialize(settings); }