refactor: debug flag to override max mem alloc size

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2025-06-04 13:56:07 +00:00
committed by Compute-Runtime-Automation
parent 6331bb2ea4
commit 2399492b74
4 changed files with 16 additions and 0 deletions

View File

@@ -475,6 +475,16 @@ HWTEST_F(DeviceGetCapsTest, givenGlobalMemSizeAndStatelessNotSupportedWhenCalcul
EXPECT_EQ(caps.maxMemAllocSize, expectedSize);
}
HWTEST_F(DeviceGetCapsTest, givenDebugFlagSetWhenCreatingDeviceThenOverrideMaxMemAllocSize) {
DebugManagerStateRestore dbgRestorer;
debugManager.flags.OverrideMaxMemAllocSizeMb.set(5 * 1024);
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getSharedDeviceInfo();
EXPECT_EQ(caps.maxMemAllocSize, 5u * 1024u * MemoryConstants::megaByte);
}
TEST_F(DeviceGetCapsTest, WhenDeviceIsCreatedThenExtensionsStringEndsWithSpace) {
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getDeviceInfo();

View File

@@ -316,6 +316,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, GetSipBinaryFromExternalLib, -1, "-1: default, 0
DECLARE_DEBUG_VARIABLE(int32_t, EnablePidFdOrSocketsForIpc, -1, "-1: default, 0: disabled (default), 1: enabled. If enabled, L0 IPC handles are opaque and pidfd or sockets are used for IPC exchange")
DECLARE_DEBUG_VARIABLE(int32_t, OverrideCopyOffloadMode, -1, "-1: default, 0: disabled, >=1: if enabled, override to any value from CopyOffloadModes enum")
DECLARE_DEBUG_VARIABLE(int32_t, UseSingleListForTemporaryAllocations, -1, "-1: default, 0: disabled, 0: enabled. If enabled, use single list, instead of per CSR for tracking temporary allocations")
DECLARE_DEBUG_VARIABLE(int32_t, OverrideMaxMemAllocSizeMb, -1, "-1: default, >=0 override reported max mem alloc size in MB")
/*LOGGING FLAGS*/
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")

View File

@@ -102,6 +102,10 @@ void Device::initializeCaps() {
}
deviceInfo.maxMemAllocSize = std::min<std::uint64_t>(driverModelMaxMemAlloc, deviceInfo.maxMemAllocSize);
if (debugManager.flags.OverrideMaxMemAllocSizeMb.get() != -1) {
deviceInfo.maxMemAllocSize = static_cast<uint64_t>(debugManager.flags.OverrideMaxMemAllocSizeMb.get()) * MemoryConstants::megaByte;
}
deviceInfo.profilingTimerResolution = getProfilingTimerResolution();
if (debugManager.flags.OverrideProfilingTimerResolution.get() != -1) {
deviceInfo.profilingTimerResolution = static_cast<double>(debugManager.flags.OverrideProfilingTimerResolution.get());

View File

@@ -664,4 +664,5 @@ EnablePidFdOrSocketsForIpc = -1
ExposeSingleDevice=-1
OverrideCopyOffloadMode = -1
UseSingleListForTemporaryAllocations = -1
OverrideMaxMemAllocSizeMb = -1
# Please don't edit below this line