From e42c860cff6479fce3f3778601dceb0256e474f6 Mon Sep 17 00:00:00 2001 From: David Beckingsale Date: Wed, 15 May 2019 10:06:06 -0700 Subject: [PATCH] Only create Allocators if they don't already exist --- source/SAMRAI/pdat/ArrayData.C | 2 +- source/SAMRAI/tbox/AllocatorDatabase.C | 51 ++++++++++++++++---------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/source/SAMRAI/pdat/ArrayData.C b/source/SAMRAI/pdat/ArrayData.C index 5d4bd20ec0..e03d315528 100644 --- a/source/SAMRAI/pdat/ArrayData.C +++ b/source/SAMRAI/pdat/ArrayData.C @@ -86,7 +86,7 @@ ArrayData::ArrayData( d_offset(box.size()), d_box(box) #if defined(HAVE_UMPIRE) - , d_allocator(umpire::ResourceManager::getInstance().getAllocator("SAMRAI_pool")) + , d_allocator(umpire::ResourceManager::getInstance().getAllocator("samrai::data_allocator")) , d_array(d_allocator.allocate(d_depth * d_offset * sizeof(TYPE))) #else , d_array(d_depth * d_offset) diff --git a/source/SAMRAI/tbox/AllocatorDatabase.C b/source/SAMRAI/tbox/AllocatorDatabase.C index 4e14aeb9eb..b965a244c6 100644 --- a/source/SAMRAI/tbox/AllocatorDatabase.C +++ b/source/SAMRAI/tbox/AllocatorDatabase.C @@ -67,42 +67,53 @@ AllocatorDatabase::initialize() { umpire::ResourceManager& rm = umpire::ResourceManager::getInstance(); + if (!rm.isAllocator("samrai::data_allocator")) { #if defined(HAVE_CUDA) - // Internal pool for allocations - auto main_allocator = rm.makeAllocator( - "SAMRAI_UM", - rm.getAllocator(umpire::resource::Unified), - // Set preferred location to GPU - "PREFERRED_LOCATION"); - - // Pool for memory used only in the for_all loops - auto device_allocator = rm.getAllocator(umpire::resource::Device); - - // Pool for message streams - auto stream_allocator = rm.getAllocator(umpire::resource::Pinned); + // Internal pool for allocations + auto allocator = rm.makeAllocator( + "internal::samrai::um_allocation_advisor", + rm.getAllocator(umpire::resource::Unified), + // Set preferred location to GPU + "PREFERRED_LOCATION"); #else - auto main_allocator = rm.getAllocator(umpire::resource::Host); - auto device_allocator = rm.getAllocator(umpire::resource::Host); - auto stream_allocator = rm.getAllocator(umpire::resource::Host); + auto allocator = rm.getAllocator(umpire::resource::Host); #endif - rm.makeAllocator("SAMRAI_pool", main_allocator); - rm.makeAllocator("SAMRAI_device_pool", device_allocator); - rm.makeAllocator("SAMRAI_stream_pool", stream_allocator); + rm.makeAllocator("samrai::data_allocator", allocator); + } + + if (!rm.isAllocator("samrai::stream_allocator")) { +#if defined(HAVE_CUDA) + auto allocator = rm.getAllocator(umpire::resource::Pinned); +#else + auto allocator = rm.getAllocator(umpire::resource::Host); +#endif + + rm.makeAllocator("samrai::stream_allocator", allocator); + } + + if (!rm.isAllocator("samrai::temporary_data_allocator")) { +#if defined(HAVE_CUDA) + auto allocator = rm.getAllocator(umpire::resource::Device); +#else + auto allocator = rm.getAllocator(umpire::resource::Host); +#endif + rm.makeAllocator("samrai::temporary_data_allocator", allocator); + } } umpire::Allocator AllocatorDatabase::getDevicePool() { umpire::ResourceManager& rm = umpire::ResourceManager::getInstance(); - return rm.getAllocator("SAMRAI_device_pool"); + return rm.getAllocator("samrai::temporary_data_allocator"); } umpire::TypedAllocator AllocatorDatabase::getStreamAllocator() { umpire::ResourceManager& rm = umpire::ResourceManager::getInstance(); - return umpire::TypedAllocator(rm.getAllocator("SAMRAI_stream_pool")); + return umpire::TypedAllocator(rm.getAllocator("samrai::stream_allocator")); } #endif