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:
parent
af5c45027f
commit
6ca5cb542f
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user