rocr: Expose flag to allocate uncached memory (#674)

Add new flag for clients to directly request uncached memory
This commit is contained in:
David Yat Sin
2025-08-22 09:52:39 -04:00
committed by GitHub
parent 5eb4ff1ca7
commit a1597a358a
3 changed files with 13 additions and 1 deletions
@@ -241,6 +241,12 @@ KfdDriver::AllocateMemory(const core::MemoryRegion &mem_region,
? 1
: kmt_alloc_flags.ui32.Uncached);
if (kmt_alloc_flags.ui32.Uncached) {
/* Uncached overwrites CoarseGrain and ExtendedCoherent */
kmt_alloc_flags.ui32.CoarseGrain = 0;
kmt_alloc_flags.ui32.ExtendedCoherent = 0;
}
kmt_alloc_flags.ui32.ExecuteBlit =
!!(alloc_flags & core::MemoryRegion::AllocateExecutableBlitKernelObject);
@@ -881,6 +881,9 @@ hsa_status_t hsa_amd_memory_pool_allocate(hsa_amd_memory_pool_t memory_pool, siz
if (flags & HSA_AMD_MEMORY_POOL_EXECUTABLE_FLAG)
alloc_flag |= core::MemoryRegion::AllocateExecutable;
if (flags & HSA_AMD_MEMORY_POOL_UNCACHED_FLAG)
alloc_flag |= core::MemoryRegion::AllocateUncached;
#ifdef SANITIZER_AMDGPU
if (mem_region->owner()->device_type() == core::Agent::kAmdGpuDevice)
alloc_flag |= core::MemoryRegion::AllocateAsan;
@@ -1579,7 +1579,10 @@ typedef enum hsa_amd_memory_pool_flag_s {
* Allocates executable memory
*/
HSA_AMD_MEMORY_POOL_EXECUTABLE_FLAG = (1 << 2),
/**
* Allocates uncached memory
*/
HSA_AMD_MEMORY_POOL_UNCACHED_FLAG = (1 << 3),
} hsa_amd_memory_pool_flag_t;
/**