From 6ca5cb542f6cff626a38034463c27c27436b98ed Mon Sep 17 00:00:00 2001 From: "Victor A. Paludetto Magri" <50467563+victorapm@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:18:35 -0700 Subject: [PATCH] Dev allocator (#758) This PR updates hypre_device_allocator to use hypre's abstract memory model. This means that: hypre configured with unified memory support: those allocations will be on managed memory. hypre configured without unified memory support: those allocations will be on device memory. --- src/utilities/_hypre_utilities.hpp | 7 +++---- src/utilities/device_allocator.h | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/utilities/_hypre_utilities.hpp b/src/utilities/_hypre_utilities.hpp index 9be4fc020..5e7b79eca 100644 --- a/src/utilities/_hypre_utilities.hpp +++ b/src/utilities/_hypre_utilities.hpp @@ -25,8 +25,7 @@ extern "C++" { #if defined(HYPRE_USING_CUDA) || defined(HYPRE_USING_HIP) -/* C++ style memory allocator for GPU **device** memory - * Just wraps _hypre_TAlloc and _hypre_TFree */ +/* C++ style memory allocator for the device using the abstract memory model */ struct hypre_device_allocator { typedef char value_type; @@ -43,12 +42,12 @@ struct hypre_device_allocator char *allocate(std::ptrdiff_t num_bytes) { - return _hypre_TAlloc(char, num_bytes, hypre_MEMORY_DEVICE); + return hypre_TAlloc(char, num_bytes, HYPRE_MEMORY_DEVICE); } void deallocate(char *ptr, size_t n) { - _hypre_TFree(ptr, hypre_MEMORY_DEVICE); + hypre_TFree(ptr, HYPRE_MEMORY_DEVICE); } }; diff --git a/src/utilities/device_allocator.h b/src/utilities/device_allocator.h index 1b030da1a..6740d035a 100644 --- a/src/utilities/device_allocator.h +++ b/src/utilities/device_allocator.h @@ -10,8 +10,7 @@ #if defined(HYPRE_USING_CUDA) || defined(HYPRE_USING_HIP) -/* C++ style memory allocator for GPU **device** memory - * Just wraps _hypre_TAlloc and _hypre_TFree */ +/* C++ style memory allocator for the device using the abstract memory model */ struct hypre_device_allocator { typedef char value_type; @@ -28,12 +27,12 @@ struct hypre_device_allocator char *allocate(std::ptrdiff_t num_bytes) { - return _hypre_TAlloc(char, num_bytes, hypre_MEMORY_DEVICE); + return hypre_TAlloc(char, num_bytes, HYPRE_MEMORY_DEVICE); } void deallocate(char *ptr, size_t n) { - _hypre_TFree(ptr, hypre_MEMORY_DEVICE); + hypre_TFree(ptr, HYPRE_MEMORY_DEVICE); } };