From d00c4446e9e66b18fd943e8c98fc8f18502a640d Mon Sep 17 00:00:00 2001 From: tiancyin Date: Wed, 11 Sep 2024 09:59:15 +0800 Subject: [PATCH] wsl/hsakmt: just reserve SVM virtual memory for scratch pool the allocation from InitScratchPool() does not really need VRAM Reviewed-by: Flora Cui Signed-off-by: tiancyin --- memory.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/memory.cpp b/memory.cpp index 02e28b4266..e5f3c7a1c8 100644 --- a/memory.cpp +++ b/memory.cpp @@ -141,17 +141,21 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemoryAlign(HSAuint32 PreferredNode, wsl::thunk::GpuMemoryCreateInfo create_info{}; create_info.size = SizeInBytes; + /* If initialize scratch pool of GpuAgent, treat it as SVM reserve */ + if (MemFlags.ui32.Scratch && MemFlags.ui32.HostAccess && SizeInBytes > 0x80000000) + MemFlags.ui32.OnlyAddress = 1; + if (!MemFlags.ui32.NonPaged || zfb_support || MemFlags.ui32.GTTAccess) { /* If allocate VRAM under ZFB mode */ if (zfb_support && MemFlags.ui32.NonPaged == 1) MemFlags.ui32.CoarseGrain = 1; create_info.domain = rocr_proxy::AllocDomain::kSystem; - if (!isSystemMemoryAvailable(SizeInBytes)) + if (!MemFlags.ui32.OnlyAddress && !isSystemMemoryAvailable(SizeInBytes)) return HSAKMT_STATUS_NO_MEMORY; } else { create_info.domain = rocr_proxy::AllocDomain::kLocal; - if (!isLocalMemoryAvailable(dev, SizeInBytes)) + if (!MemFlags.ui32.OnlyAddress && !isLocalMemoryAvailable(dev, SizeInBytes)) return HSAKMT_STATUS_NO_MEMORY; }