From 933df7235b031ad690a605b02f1e7991b2ba5205 Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Tue, 19 Oct 2021 18:25:22 +0000 Subject: [PATCH] SWDEV-305163 - Do not limit hipHostMalloc upto max GPU memory available Change-Id: Iea934088bcbef6cbd5c3f9f97767042fcaf71062 [ROCm/clr commit: 1da4bb21b9973fae7ff6828708044b32dbec0120] --- projects/clr/hipamd/src/hip_memory.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/projects/clr/hipamd/src/hip_memory.cpp b/projects/clr/hipamd/src/hip_memory.cpp index 284a314d0e..84ddbecfc7 100644 --- a/projects/clr/hipamd/src/hip_memory.cpp +++ b/projects/clr/hipamd/src/hip_memory.cpp @@ -274,7 +274,7 @@ hipError_t ihipMalloc(void** ptr, size_t sizeBytes, unsigned int flags) return hipErrorOutOfMemory; } - if (amdContext->devices()[0]->info().maxMemAllocSize_ < sizeBytes) { + if (!useHostDevice && (amdContext->devices()[0]->info().maxMemAllocSize_ < sizeBytes)) { return hipErrorOutOfMemory; } @@ -282,9 +282,15 @@ hipError_t ihipMalloc(void** ptr, size_t sizeBytes, unsigned int flags) useHostDevice ? curDevContext->svmDevices()[0] : nullptr); if (*ptr == nullptr) { - size_t free = 0, total =0; - hipMemGetInfo(&free, &total); - LogPrintfError("Allocation failed : Device memory : required :%zu | free :%zu | total :%zu \n", sizeBytes, free, total); + if (!useHostDevice) { + size_t free = 0, total =0; + hipError_t err = hipMemGetInfo(&free, &total); + if (err == hipSuccess) { + LogPrintfError("Allocation failed : Device memory : required :%zu | free :%zu | total :%zu \n", sizeBytes, free, total); + } + } else { + LogPrintfError("Allocation failed : Pinned Memory, size :%zu \n", sizeBytes); + } return hipErrorOutOfMemory; } size_t offset = 0; //this is ignored