From b07178618c2e1a82cf016c23170b0228f5d53d87 Mon Sep 17 00:00:00 2001 From: pghafari Date: Wed, 25 Sep 2024 19:47:00 -0400 Subject: [PATCH] SWDEV-467263 - Allow hipMalloc to use sys memory PAL supports allocating from system memory once device memory is used up or allocation is larger than the device memory. Change-Id: Iccd3377e95a6cc6d23e45d4738a17af8b9ee32d7 --- hipamd/src/hip_memory.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index 31326ba766..791ee384ed 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -314,8 +314,11 @@ hipError_t ihipMalloc(void** ptr, size_t sizeBytes, unsigned int flags) const auto& dev_info = amdContext->devices()[0]->info(); hip::getCurrentDevice()->SetActiveStatus(); - if ((!useHostDevice && (dev_info.maxMemAllocSize_ < sizeBytes)) || - (useHostDevice && (dev_info.maxPhysicalMemAllocSize_ < sizeBytes))) { + if (dev_info.maxPhysicalMemAllocSize_ < sizeBytes) { + return hipErrorOutOfMemory; + } + // PAL allocates from system memory if needed + if (IS_LINUX && !useHostDevice && (dev_info.maxMemAllocSize_ < sizeBytes)) { return hipErrorOutOfMemory; }