From a14d5c52cb1d6838facd5e5ca769e51287c87aa3 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Fri, 5 Jul 2024 14:14:50 +0000 Subject: [PATCH] fix: Extend scope of OverrideSlmSize debug key - apply key during initialization Signed-off-by: Mateusz Jablonski --- .../unit_test/device/device_caps_tests.cpp | 21 ----- .../os_interface/device_factory_tests.cpp | 60 ------------- .../debug_settings/debug_variables_base.inl | 2 +- shared/source/device/device_caps.cpp | 3 - shared/source/os_interface/device_factory.cpp | 9 ++ .../os_interface/device_factory_tests.cpp | 89 ++++++++++++++++++- 6 files changed, 98 insertions(+), 86 deletions(-) diff --git a/opencl/test/unit_test/device/device_caps_tests.cpp b/opencl/test/unit_test/device/device_caps_tests.cpp index f494ee9f69..c24d5d168b 100644 --- a/opencl/test/unit_test/device/device_caps_tests.cpp +++ b/opencl/test/unit_test/device/device_caps_tests.cpp @@ -1608,27 +1608,6 @@ TEST(Device_UseCaps, givenCapabilityTableWhenDeviceInitializeCapsThenVmeVersions } } -TEST(Device_UseCaps, givenOverrideSlmSizeWhenWhenInitializeDeviceThenSlmSizeInDeviceInfoIsCorrect) { - DebugManagerStateRestore restorer; - HardwareInfo hardwareInfo = *defaultHwInfo; - - uint32_t defaultSlmSize = hardwareInfo.capabilityTable.slmSize; - debugManager.flags.OverrideSlmSize.set(-1); - auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hardwareInfo)); - auto &deviceInfoWithoutForceSlmFlag = device->getSharedDeviceInfo(); - - EXPECT_EQ(defaultSlmSize, static_cast(deviceInfoWithoutForceSlmFlag.localMemSize / MemoryConstants::kiloByte)); - - uint32_t newSlmSize = 1; - EXPECT_NE(defaultSlmSize, newSlmSize); - - debugManager.flags.OverrideSlmSize.set(newSlmSize); - device.reset(new MockClDevice{MockDevice::createWithNewExecutionEnvironment(&hardwareInfo)}); - auto &deviceInfoWithForceSlmFlag = device->getSharedDeviceInfo(); - - EXPECT_EQ(newSlmSize, static_cast(deviceInfoWithForceSlmFlag.localMemSize / MemoryConstants::kiloByte)); -} - TEST_F(DeviceGetCapsTest, givenClDeviceWhenInitializingCapsThenUseGetQueueFamilyCapabilitiesMethod) { struct ClDeviceWithCustomQueueCaps : MockClDevice { using MockClDevice::MockClDevice; diff --git a/opencl/test/unit_test/os_interface/device_factory_tests.cpp b/opencl/test/unit_test/os_interface/device_factory_tests.cpp index 2590d95254..32b9a203ab 100644 --- a/opencl/test/unit_test/os_interface/device_factory_tests.cpp +++ b/opencl/test/unit_test/os_interface/device_factory_tests.cpp @@ -237,66 +237,6 @@ TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenPrepareDevi EXPECT_EQ(requiredDeviceCount, executionEnvironment->rootDeviceEnvironments.size()); } -TEST_F(DeviceFactoryTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsIsCalledThenOverrideGpuAddressSpace) { - DebugManagerStateRestore restore; - debugManager.flags.OverrideGpuAddressSpace.set(12); - - bool success = DeviceFactory::prepareDeviceEnvironments(*executionEnvironment); - - EXPECT_TRUE(success); - EXPECT_EQ(maxNBitValue(12), executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.gpuAddressSpace); -} - -TEST_F(DeviceFactoryTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideGpuAddressSpace) { - DebugManagerStateRestore restore; - debugManager.flags.OverrideGpuAddressSpace.set(12); - - bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(*executionEnvironment); - - EXPECT_TRUE(success); - EXPECT_EQ(maxNBitValue(12), executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.gpuAddressSpace); -} - -TEST_F(DeviceFactoryTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsIsCalledThenOverrideRevision) { - DebugManagerStateRestore restore; - debugManager.flags.OverrideRevision.set(3); - - bool success = DeviceFactory::prepareDeviceEnvironments(*executionEnvironment); - - EXPECT_TRUE(success); - EXPECT_EQ(3u, executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.usRevId); -} - -TEST_F(DeviceFactoryTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideRevision) { - DebugManagerStateRestore restore; - debugManager.flags.OverrideRevision.set(3); - - bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(*executionEnvironment); - - EXPECT_TRUE(success); - EXPECT_EQ(3u, executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.usRevId); -} - -TEST_F(DeviceFactoryTest, givenDebugFlagWithoutZeroXWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideDeviceIdToHexValue) { - DebugManagerStateRestore restore; - debugManager.flags.ForceDeviceId.set("1234"); - - bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(*executionEnvironment); - - EXPECT_TRUE(success); - EXPECT_EQ(0x1234u, executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.usDeviceID); -} - -TEST_F(DeviceFactoryTest, givenDebugFlagWithZeroXWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideDeviceIdToHexValue) { - DebugManagerStateRestore restore; - debugManager.flags.ForceDeviceId.set("0x1234"); - - bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(*executionEnvironment); - - EXPECT_TRUE(success); - EXPECT_EQ(0x1234u, executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo()->platform.usDeviceID); -} - TEST_F(DeviceFactoryTest, whenPrepareDeviceEnvironmentsIsCalledThenAllRootDeviceEnvironmentMembersAreInitialized) { DebugManagerStateRestore stateRestore; auto requiredDeviceCount = 2u; diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index d7e59441ba..eaddcc0999 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -489,7 +489,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForcePipeSupport, -1, "-1: default, 0: disabled, DECLARE_DEBUG_VARIABLE(int32_t, UseAsyncDrmExec, -1, "-1: default, 0: Disabled 1: Enabled. If enabled, pass EXEC_OBJECT_ASYNC to exec ioctl.") DECLARE_DEBUG_VARIABLE(int32_t, UseBindlessMode, -1, "Use precompiled builtins in bindless mode, -1: api dependent, 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int32_t, UseExternalAllocatorForSshAndDsh, -1, "Use 32 bit external allocator for ssh and dsh in Level Zero, -1: default, 0: disabled, 1: enabled") -DECLARE_DEBUG_VARIABLE(int32_t, OverrideSlmSize, -1, "Force different slm size than default in kB") +DECLARE_DEBUG_VARIABLE(int32_t, OverrideSlmSize, -1, "Force per subslice slm size in KB; ignore when -1") DECLARE_DEBUG_VARIABLE(int32_t, UseCyclesPerSecondTimer, 0, "0: default behavior, 0: disabled: Report L0 timer in nanosecond units, 1: enabled: Report L0 timer in cycles per second") DECLARE_DEBUG_VARIABLE(int32_t, WaitLoopCount, -1, "-1: use default, >=0: number of iterations in wait loop") DECLARE_DEBUG_VARIABLE(int32_t, EnableWaitpkg, -1, "-1: use default, 0: disable, 1: enable") diff --git a/shared/source/device/device_caps.cpp b/shared/source/device/device_caps.cpp index ec15f803ce..9fb62d7d56 100644 --- a/shared/source/device/device_caps.cpp +++ b/shared/source/device/device_caps.cpp @@ -155,9 +155,6 @@ void Device::initializeCaps() { deviceInfo.maxFrontEndThreads = gfxCoreHelper.getMaxThreadsForVfe(hwInfo); deviceInfo.localMemSize = hwInfo.capabilityTable.slmSize * MemoryConstants::kiloByte; - if (debugManager.flags.OverrideSlmSize.get() != -1) { - deviceInfo.localMemSize = debugManager.flags.OverrideSlmSize.get() * MemoryConstants::kiloByte; - } deviceInfo.imageSupport = hwInfo.capabilityTable.supportsImages; deviceInfo.image2DMaxWidth = 16384; diff --git a/shared/source/os_interface/device_factory.cpp b/shared/source/os_interface/device_factory.cpp index d383525a5d..0504fc0952 100644 --- a/shared/source/os_interface/device_factory.cpp +++ b/shared/source/os_interface/device_factory.cpp @@ -109,6 +109,10 @@ bool DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(ExecutionE if (debugManager.flags.OverrideGpuAddressSpace.get() != -1) { hardwareInfo->capabilityTable.gpuAddressSpace = maxNBitValue(static_cast(debugManager.flags.OverrideGpuAddressSpace.get())); } + if (debugManager.flags.OverrideSlmSize.get() != -1) { + hardwareInfo->capabilityTable.slmSize = debugManager.flags.OverrideSlmSize.get(); + hardwareInfo->gtSystemInfo.SLMSizeInKb = debugManager.flags.OverrideSlmSize.get(); + } [[maybe_unused]] bool result = rootDeviceEnvironment.initAilConfiguration(); DEBUG_BREAK_IF(!result); @@ -160,6 +164,11 @@ static bool initHwDeviceIdResources(ExecutionEnvironment &executionEnvironment, executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo()->platform.usRevId = static_cast(debugManager.flags.OverrideRevision.get()); } + if (debugManager.flags.OverrideSlmSize.get() != -1) { + auto hardwareInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo(); + hardwareInfo->capabilityTable.slmSize = debugManager.flags.OverrideSlmSize.get(); + hardwareInfo->gtSystemInfo.SLMSizeInKb = debugManager.flags.OverrideSlmSize.get(); + } executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->initGmm(); diff --git a/shared/test/unit_test/os_interface/device_factory_tests.cpp b/shared/test/unit_test/os_interface/device_factory_tests.cpp index 4ef4f33352..840cf9e35b 100644 --- a/shared/test/unit_test/os_interface/device_factory_tests.cpp +++ b/shared/test/unit_test/os_interface/device_factory_tests.cpp @@ -1,10 +1,11 @@ /* - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * SPDX-License-Identifier: MIT * */ +#include "shared/source/helpers/constants.h" #include "shared/source/helpers/product_config_helper.h" #include "shared/source/os_interface/device_factory.h" #include "shared/source/release_helper/release_helper.h" @@ -183,3 +184,89 @@ TEST_F(DeviceFactoryTests, givenFailedAilInitializationResultWhenPrepareDeviceEn bool res = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); EXPECT_FALSE(res); } + +struct DeviceFactoryOverrideTest : public ::testing::Test { + MockExecutionEnvironment executionEnvironment{defaultHwInfo.get()}; +}; + +TEST_F(DeviceFactoryOverrideTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsIsCalledThenOverrideGpuAddressSpace) { + DebugManagerStateRestore restore; + debugManager.flags.OverrideGpuAddressSpace.set(12); + + bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment); + + EXPECT_TRUE(success); + EXPECT_EQ(maxNBitValue(12), executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.gpuAddressSpace); +} + +TEST_F(DeviceFactoryOverrideTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideGpuAddressSpace) { + DebugManagerStateRestore restore; + debugManager.flags.OverrideGpuAddressSpace.set(12); + + bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); + + EXPECT_TRUE(success); + EXPECT_EQ(maxNBitValue(12), executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.gpuAddressSpace); +} + +TEST_F(DeviceFactoryOverrideTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsIsCalledThenOverrideRevision) { + DebugManagerStateRestore restore; + debugManager.flags.OverrideRevision.set(3); + + bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment); + + EXPECT_TRUE(success); + EXPECT_EQ(3u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->platform.usRevId); +} + +TEST_F(DeviceFactoryOverrideTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideRevision) { + DebugManagerStateRestore restore; + debugManager.flags.OverrideRevision.set(3); + + bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); + + EXPECT_TRUE(success); + EXPECT_EQ(3u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->platform.usRevId); +} + +TEST_F(DeviceFactoryOverrideTest, givenDebugFlagWithoutZeroXWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideDeviceIdToHexValue) { + DebugManagerStateRestore restore; + debugManager.flags.ForceDeviceId.set("1234"); + + bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); + + EXPECT_TRUE(success); + EXPECT_EQ(0x1234u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->platform.usDeviceID); +} + +TEST_F(DeviceFactoryOverrideTest, givenDebugFlagWithZeroXWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideDeviceIdToHexValue) { + DebugManagerStateRestore restore; + debugManager.flags.ForceDeviceId.set("0x1234"); + + bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); + + EXPECT_TRUE(success); + EXPECT_EQ(0x1234u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->platform.usDeviceID); +} + +TEST_F(DeviceFactoryOverrideTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsIsCalledThenOverrideSlmSize) { + DebugManagerStateRestore restore; + debugManager.flags.OverrideSlmSize.set(123); + + bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment); + + EXPECT_TRUE(success); + EXPECT_EQ(123u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.slmSize); + EXPECT_EQ(123u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo.SLMSizeInKb); +} + +TEST_F(DeviceFactoryOverrideTest, givenDebugFlagSetWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenOverrideSlmSize) { + DebugManagerStateRestore restore; + debugManager.flags.OverrideSlmSize.set(123); + + bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); + + EXPECT_TRUE(success); + EXPECT_EQ(123u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->capabilityTable.slmSize); + EXPECT_EQ(123u, executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo()->gtSystemInfo.SLMSizeInKb); +}