Skip to content

Commit 3581bdb

Browse files
Add capability to enable/disable local memory via debug flags.
Change-Id: Ica388751f4be3afbd2c78a0f169576d2654e1a0f
1 parent 0ca8ee7 commit 3581bdb

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

runtime/device/device_caps.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ bool Device::getEnabled64kbPages() {
5353
};
5454

5555
bool Device::getEnableLocalMemory() {
56-
if (DebugManager.flags.EnableLocalMemory.get() == true) {
57-
return true;
58-
} else {
59-
return OSInterface::osEnableLocalMemory && getHardwareCapabilities().localMemorySupported;
56+
if (DebugManager.flags.EnableLocalMemory.get() != -1) {
57+
return DebugManager.flags.EnableLocalMemory.get();
6058
}
59+
60+
return OSInterface::osEnableLocalMemory && getHardwareCapabilities().localMemorySupported;
6161
};
6262

6363
void Device::setupFp64Flags() {

runtime/os_interface/debug_variables_base.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ DECLARE_DEBUG_VARIABLE(bool, EnableComputeWorkSizeSquared, false, "Enables algor
8888
DECLARE_DEBUG_VARIABLE(bool, EnableVaLibCalls, true, "Enable cl-va sharing lib calls")
8989
DECLARE_DEBUG_VARIABLE(bool, AddClGlSharing, false, "Add cl-gl extension")
9090
DECLARE_DEBUG_VARIABLE(bool, EnablePassInlineData, false, "Enable passing of inline data")
91-
DECLARE_DEBUG_VARIABLE(bool, EnableLocalMemory, false, "Allows allocating graphics memory in Local Memory")
91+
DECLARE_DEBUG_VARIABLE(int32_t, EnableLocalMemory, -1, "-1: default behavior, 0: disabled, 1: enabled, Allows allocating graphics memory in Local Memory")
9292
DECLARE_DEBUG_VARIABLE(int32_t, EnableStatelessToStatefulBufferOffsetOpt, -1, "-1: dont override, 0: disable, 1: enable, Enables buffer-offset improvement of the stateless to stateful optimization")
9393
DECLARE_DEBUG_VARIABLE(int32_t, CreateMultipleDevices, 0, "0: default - disable, 1+: Driver will create multiple (N) devices during initialization.")
9494
DECLARE_DEBUG_VARIABLE(int32_t, LimitAmountOfReturnedDevices, 0, "0: default - disable, 1+: Driver will limit the number of devices returned from clGetDeviceIds to N.")

unit_tests/device/device_caps_tests.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ TEST_F(DeviceCapsWithModifiedHwInfoTest, GivenLocalMemorySupportedAndOsEnableLoc
863863
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfoHelper.hwInfo));
864864
bool orgHwCapsLocalMemorySupported = device->getHardwareCapabilities().localMemorySupported;
865865

866-
DebugManager.flags.EnableLocalMemory.set(false);
866+
DebugManager.flags.EnableLocalMemory.set(0);
867867

868868
device->setHWCapsLocalMemorySupported(false);
869869
OSInterface::osEnableLocalMemory = false;
@@ -879,9 +879,21 @@ TEST_F(DeviceCapsWithModifiedHwInfoTest, GivenLocalMemorySupportedAndOsEnableLoc
879879

880880
device->setHWCapsLocalMemorySupported(true);
881881
OSInterface::osEnableLocalMemory = true;
882+
EXPECT_FALSE(device->getEnableLocalMemory());
883+
884+
DebugManager.flags.EnableLocalMemory.set(-1);
882885
EXPECT_TRUE(device->getEnableLocalMemory());
883886

884-
DebugManager.flags.EnableLocalMemory.set(true);
887+
OSInterface::osEnableLocalMemory = false;
888+
EXPECT_FALSE(device->getEnableLocalMemory());
889+
890+
device->setHWCapsLocalMemorySupported(false);
891+
EXPECT_FALSE(device->getEnableLocalMemory());
892+
893+
DebugManager.flags.EnableLocalMemory.set(1);
894+
device->setHWCapsLocalMemorySupported(false);
895+
OSInterface::osEnableLocalMemory = false;
896+
885897
EXPECT_TRUE(device->getEnableLocalMemory());
886898

887899
device->setHWCapsLocalMemorySupported(orgHwCapsLocalMemorySupported);

unit_tests/test_files/igdrcl.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ AddClGlSharing = 0
9090
EnablePassInlineData = false
9191
LimitAmountOfReturnedDevices = 0
9292
UseMallocToObtainHeap32Base = false
93-
EnableLocalMemory = false
93+
EnableLocalMemory = -1
9494
UseAubStream = true
9595
AubDumpOverrideMmioRegister = 0
9696
AubDumpOverrideMmioRegisterValue = 0

0 commit comments

Comments
 (0)