From e22c9b457e34fd69c8975c868f79c03ba4d9beca Mon Sep 17 00:00:00 2001 From: "Xie, AlexBin" <54727243+AlexXAmd@users.noreply.github.com> Date: Mon, 26 Jan 2026 11:35:01 -0500 Subject: [PATCH] SWDEV-576718 - provide option to limit memory cache usage (#2810) * SWDEV-576718 - provide option to limit memory cache usage * SWDEV-576718 - Use MiB instead of MB in description --- projects/clr/rocclr/device/pal/palsettings.cpp | 3 +++ projects/clr/rocclr/utils/flags.hpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/projects/clr/rocclr/device/pal/palsettings.cpp b/projects/clr/rocclr/device/pal/palsettings.cpp index 642a5a2f6c..456bdca1a8 100644 --- a/projects/clr/rocclr/device/pal/palsettings.cpp +++ b/projects/clr/rocclr/device/pal/palsettings.cpp @@ -347,6 +347,9 @@ bool Settings::create(const Pal::DeviceProperties& palProp, #endif } + resourceCacheSize_ = std::min(resourceCacheSize_, + (uint64_t)GPU_MAX_RESOURCE_CACHE_SIZE * Mi); + // If is Rebar, override prepinned memory size. if ((heaps[Pal::GpuHeapInvisible].logicalSize == 0) && (heaps[Pal::GpuHeapLocal].logicalSize > 256 * Mi)) { diff --git a/projects/clr/rocclr/utils/flags.hpp b/projects/clr/rocclr/utils/flags.hpp index fba7e2a140..6a8f5b786b 100644 --- a/projects/clr/rocclr/utils/flags.hpp +++ b/projects/clr/rocclr/utils/flags.hpp @@ -83,7 +83,9 @@ release(size_t, GPU_PINNED_XFER_SIZE, 32, \ release(size_t, GPU_PINNED_MIN_XFER_SIZE, 128, \ "The minimal buffer size for pinned read/write transfers in MiB") \ release(size_t, GPU_RESOURCE_CACHE_SIZE, 64, \ - "The resource cache size in MB") \ + "The resource cache size in MiB") \ +release(size_t, GPU_MAX_RESOURCE_CACHE_SIZE, 16777216, \ + "The max resource cache size in MiB") \ release(size_t, GPU_MAX_SUBALLOC_SIZE, 4096, \ "The maximum size accepted for suballocations in KB") \ release(size_t, GPU_NUM_MEM_DEPENDENCY, 256, \