Use finegrain allocator by default (#140)

* Use FineGrained allocator for heap by default, consolidate all types of
allocators under saner cmake controls

Co-authored-by: Yiltan <ytemucin@amd.com>

* Uncached may not be only for debug

Need to include the rocshmem config otherwise produce an inconsistent
build with different allocators used in different files

* Undo this pr adding presumably useless hip_host_allocator_noncoherent

* Rename HEAP_IS_COHERENT/USE_COHERENT_HEAP to USE_HDP_FLUSH as the former
was misleading

* Remove unused __roc_inv()

---------

Co-authored-by: Yiltan <ytemucin@amd.com>
This commit is contained in:
Aurelien Bouteiller
2025-06-13 15:26:26 -04:00
committed by GitHub
parent bcc14b1a34
commit 41fd9e2d57
13 changed files with 67 additions and 66 deletions
+17 -8
View File
@@ -40,16 +40,25 @@
namespace rocshmem {
#if defined USE_MANAGED_HEAP
using HEAP_T = HeapMemory<HIPAllocatorManaged>;
#elif defined USE_COHERENT_HEAP
// Compilation error 'HEAP_T redefined' indicates that user had more than one
// USE_HEAP_* ON when configuring. Use ccmake to select only one.
#if defined USE_HEAP_DEVICE_COARSEGRAIN
using HEAP_T = HeapMemory<HIPAllocator>;
#elif defined USE_HOST_HEAP
using HEAP_T = HeapMemory<HostAllocator>;
#elif defined USE_HIP_HOST_HEAP
#endif
#if defined USE_HEAP_DEVICE_FINEGRAIN
using HEAP_T = HeapMemory<HIPAllocatorFinegrained>;
#endif
#if defined USE_HEAP_DEVICE_UNCACHED
using HEAP_T = HeapMemory<HIPAllocatorUncached>;
#endif
#if defined USE_HEAP_MANAGED
using HEAP_T = HeapMemory<HIPAllocatorManaged>;
#endif
#if defined USE_HEAP_HOST_HIP
using HEAP_T = HeapMemory<HIPHostAllocator>;
#else
using HEAP_T = HeapMemory<HIPDefaultFinegrainedAllocator>;
#endif
#if defined USE_HEAP_HOST
using HEAP_T = HeapMemory<HostAllocator>;
#endif
} // namespace rocshmem
+5 -1
View File
@@ -36,12 +36,15 @@
#include <cstdlib>
#include <limits>
#include "rocshmem_config.h" // NOLINT(build/include_subdir)
#include "memory_allocator.hpp"
// `hipDeviceMallocUncached` was introduced at ROCm 5.5
#if (HIP_VERSION_MAJOR > 5) || \
(HIP_VERSION_MAJOR == 5 && HIP_VERSION_MINOR >= 5)
#define HIP_SUPPORTS_MALLOC_UNCACHED
#elif defined USE_HEAP_DEVICE_UNCACHED
#error "USE_HEAP_DEVICE_UNCACHED unsupported in this HIP version"
#endif
namespace rocshmem {
@@ -57,13 +60,14 @@ class HIPAllocatorFinegrained : public MemoryAllocator {
hipDeviceMallocFinegrained) {}
};
#ifdef HIP_SUPPORTS_MALLOC_UNCACHED
#if defined HIP_SUPPORTS_MALLOC_UNCACHED
class HIPAllocatorUncached : public MemoryAllocator {
public:
HIPAllocatorUncached()
: MemoryAllocator(hipExtMallocWithFlags, hipFree,
hipDeviceMallocUncached) {}
};
// The default fine-grained coherence allocator is the uncached allocator
using HIPDefaultFinegrainedAllocator = HIPAllocatorUncached;
#else