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.
This commit is contained in:
Victor A. Paludetto Magri 2022-10-24 16:18:35 -07:00 committed by GitHub
parent af5c45027f
commit 6ca5cb542f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -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);
}
};

View File

@ -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);
}
};