From c7263a6fbd494252e571fa19237ddcfc7e89758e Mon Sep 17 00:00:00 2001 From: Tom Stitt Date: Mon, 27 Oct 2025 10:54:10 -0700 Subject: [PATCH] create a single device umpire pool for hypre and mfem --- laghos.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/laghos.cpp b/laghos.cpp index 0996fa22..75ae91b1 100644 --- a/laghos.cpp +++ b/laghos.cpp @@ -68,6 +68,12 @@ #include #endif +#if (defined(HYPRE_USING_UMPIRE) || defined(MFEM_USE_UMPIRE)) && (defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)) +#define LAGHOS_USE_DEVICE_UMPIRE +#include +#include +#endif + using std::cout; using std::endl; using namespace mfem; @@ -235,6 +241,22 @@ int main(int argc, char *argv[]) adiak::jobsize(); #endif +#ifdef LAGHOS_USE_DEVICE_UMPIRE + auto &rm = umpire::ResourceManager::getInstance(); + const char * allocator_name = "laghos_device_alloc"; + rm.makeAllocator(allocator_name, rm.getAllocator("DEVICE")); + +#ifdef HYPRE_USING_UMPIRE + HYPRE_SetUmpireDevicePoolName(allocator_name); +#endif // HYPRE_USING_UMPIRE + +#ifdef MFEM_USE_UMPIRE + MemoryManager::SetUmpireDeviceAllocatorName(allocator_name); + // the umpire host memory type is slow compared to the native host memory type + Device::SetMemoryTypes(MemoryType::HOST, MemoryType::DEVICE_UMPIRE); +#endif // MFEM_USING_UMPIRE +#endif // LAGHOS_USE_DEVICE_UMPIRE + // Configure the device from the command line options Device backend; backend.Configure(device, dev);