From e289ebdf20dd87dfe854e4bade502911ec9b9f19 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Thu, 16 Apr 2020 08:21:21 -0400 Subject: [PATCH] SWDEV-231691 - Problem with CL_DEVICE_GLOBAL_FREE_MEMORY_AMD query. Check if allocated memory exceeds the total size. Change-Id: Ieed8829860663bac1acfa41d21309dff4d8772c7 --- rocclr/device/pal/paldevice.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rocclr/device/pal/paldevice.cpp b/rocclr/device/pal/paldevice.cpp index 49e2398f75..d88eb7c475 100644 --- a/rocclr/device/pal/paldevice.cpp +++ b/rocclr/device/pal/paldevice.cpp @@ -1852,10 +1852,11 @@ bool Device::globalFreeMemory(size_t* freeMemory) const { Pal::gpusize local = allocedMem[Pal::GpuHeapLocal]; Pal::gpusize invisible = allocedMem[Pal::GpuHeapInvisible] - resourceCache().lclCacheSize(); + Pal::gpusize total_alloced = local + invisible; // Fill free memory info - freeMemory[TotalFreeMemory] = - static_cast((info().globalMemSize_ - (local + invisible)) / Ki); + freeMemory[TotalFreeMemory] = (total_alloced > info().globalMemSize_ ) ? 0 : + static_cast((info().globalMemSize_ - total_alloced) / Ki); if (invisible >= heaps_[Pal::GpuHeapInvisible].heapSize) { invisible = 0; } else {