Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions laghos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
#include <adiak.hpp>
#endif

#if (defined(HYPRE_USING_UMPIRE) || defined(MFEM_USE_UMPIRE)) && (defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP))
#define LAGHOS_USE_DEVICE_UMPIRE
#include <umpire/Umpire.hpp>
#include <umpire/strategy/QuickPool.hpp>
#endif

using std::cout;
using std::endl;
using namespace mfem;
Expand Down Expand Up @@ -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<umpire::strategy::QuickPool>(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);
Expand Down