From 082c6b78304ab834cc130a1c567aebe88f3d2a2e Mon Sep 17 00:00:00 2001 From: Longlong Yao Date: Sat, 8 Feb 2025 14:34:14 +0800 Subject: [PATCH] libhsakmt: allocate va in host path Change-Id: I40a4395aca99ea8dfd8ff0ecde64eb2c3840d867 Signed-off-by: Longlong Yao [ROCm/ROCR-Runtime commit: 26f001d3cb762b6db76799d0740482823d1a8dfc] --- projects/rocr-runtime/libhsakmt/src/fmm.c | 4 ++++ projects/rocr-runtime/libhsakmt/src/memory.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/libhsakmt/src/fmm.c b/projects/rocr-runtime/libhsakmt/src/fmm.c index 6ddf363742..5fb73effa4 100644 --- a/projects/rocr-runtime/libhsakmt/src/fmm.c +++ b/projects/rocr-runtime/libhsakmt/src/fmm.c @@ -1830,6 +1830,10 @@ static void *fmm_allocate_host_gpu(uint32_t gpu_id, uint32_t node_id, void *addr if (mflags.ui32.AQLQueueMemory) size = MemorySizeInBytes * 2; + /* special case for va allocation without real memory alloc */ + if (mflags.ui32.OnlyAddress) + return fmm_allocate_va(gpu_id, address, size, aperture, alignment, mflags); + /* Paged memory is allocated as a userptr mapping, non-paged * memory is allocated from KFD */ diff --git a/projects/rocr-runtime/libhsakmt/src/memory.c b/projects/rocr-runtime/libhsakmt/src/memory.c index 7e072bd165..ba2a2175bb 100644 --- a/projects/rocr-runtime/libhsakmt/src/memory.c +++ b/projects/rocr-runtime/libhsakmt/src/memory.c @@ -176,7 +176,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemoryAlign(HSAuint32 PreferredNode, } /* GPU allocated system memory */ - if (!gpu_id || !MemFlags.ui32.NonPaged || hsakmt_zfb_support || MemFlags.ui32.GTTAccess) { + if (!gpu_id || !MemFlags.ui32.NonPaged || hsakmt_zfb_support || MemFlags.ui32.GTTAccess + || MemFlags.ui32.OnlyAddress) { /* Backwards compatibility hack: Allocate system memory if app * asks for paged memory from a GPU node. */