From 1822fb0747a6062e2d0b711ce49e88e371c65373 Mon Sep 17 00:00:00 2001 From: "Kowalczuk, Jakub" Date: Tue, 30 Oct 2018 11:31:08 +0100 Subject: [PATCH] Control enabling of local memory based on OS and HW Capabilities part 2 - add EnableLocalMemory debug variable - separate OSInterface::osEnableLocalMemory for dll and unit tests Change-Id: I78a1f60364eece28b30ce3e91418e7d72ba3e0d9 --- runtime/device/device_caps.cpp | 6 +++++- runtime/dll/CMakeLists.txt | 2 ++ runtime/dll/linux/os_interface.cpp | 14 ++++++++++++++ runtime/dll/windows/os_interface.cpp | 14 ++++++++++++++ runtime/os_interface/debug_variables_base.inl | 1 + runtime/os_interface/linux/os_interface.cpp | 1 - runtime/os_interface/windows/os_interface.cpp | 1 - unit_tests/device/device_caps_tests.cpp | 8 +++++++- unit_tests/libult/CMakeLists.txt | 1 + unit_tests/libult/os_interface.cpp | 14 ++++++++++++++ unit_tests/test_files/igdrcl.config | 3 ++- 11 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 runtime/dll/linux/os_interface.cpp create mode 100644 runtime/dll/windows/os_interface.cpp create mode 100644 unit_tests/libult/os_interface.cpp diff --git a/runtime/device/device_caps.cpp b/runtime/device/device_caps.cpp index 30c88fe6ec..a7e0932290 100644 --- a/runtime/device/device_caps.cpp +++ b/runtime/device/device_caps.cpp @@ -53,7 +53,11 @@ bool Device::getEnabled64kbPages() { }; bool Device::getEnableLocalMemory() { - return OSInterface::osEnableLocalMemory && getHardwareCapabilities().localMemorySupported; + if (DebugManager.flags.EnableLocalMemory.get() == true) { + return true; + } else { + return OSInterface::osEnableLocalMemory && getHardwareCapabilities().localMemorySupported; + } }; void Device::setupFp64Flags() { diff --git a/runtime/dll/CMakeLists.txt b/runtime/dll/CMakeLists.txt index c44eb80894..5adfc04d03 100644 --- a/runtime/dll/CMakeLists.txt +++ b/runtime/dll/CMakeLists.txt @@ -34,10 +34,12 @@ set(RUNTIME_SRCS_DLL_LINUX ${CMAKE_CURRENT_SOURCE_DIR}/linux/allocator_helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/linux/drm_neo_create.cpp ${CMAKE_CURRENT_SOURCE_DIR}/linux/options.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/linux/os_interface.cpp ) set(RUNTIME_SRCS_DLL_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/windows/options.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/windows/os_interface.cpp ${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/gmm_memory.cpp ${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/page_table_mngr.cpp ${IGDRCL_SOURCE_DIR}/runtime/os_interface/windows/sys_calls.cpp diff --git a/runtime/dll/linux/os_interface.cpp b/runtime/dll/linux/os_interface.cpp new file mode 100644 index 0000000000..f293ab8190 --- /dev/null +++ b/runtime/dll/linux/os_interface.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/os_interface/linux/os_interface.h" + +namespace OCLRT { + +bool OSInterface::osEnableLocalMemory = false; + +} // namespace OCLRT \ No newline at end of file diff --git a/runtime/dll/windows/os_interface.cpp b/runtime/dll/windows/os_interface.cpp new file mode 100644 index 0000000000..5efcf96aa7 --- /dev/null +++ b/runtime/dll/windows/os_interface.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/os_interface/windows/os_interface.h" + +namespace OCLRT { + +bool OSInterface::osEnableLocalMemory = false; + +} // namespace OCLRT \ No newline at end of file diff --git a/runtime/os_interface/debug_variables_base.inl b/runtime/os_interface/debug_variables_base.inl index e0cc1abbba..c9bc956614 100644 --- a/runtime/os_interface/debug_variables_base.inl +++ b/runtime/os_interface/debug_variables_base.inl @@ -84,6 +84,7 @@ DECLARE_DEBUG_VARIABLE(bool, EnableComputeWorkSizeSquared, false, "Enables algor DECLARE_DEBUG_VARIABLE(bool, EnableVaLibCalls, true, "Enable cl-va sharing lib calls") DECLARE_DEBUG_VARIABLE(bool, AddClGlSharing, false, "Add cl-gl extension") DECLARE_DEBUG_VARIABLE(bool, EnablePassInlineData, false, "Enable passing of inline data") +DECLARE_DEBUG_VARIABLE(bool, EnableLocalMemory, false, "Allows allocating graphics memory in Local Memory") DECLARE_DEBUG_VARIABLE(int32_t, EnableStatelessToStatefulBufferOffsetOpt, -1, "-1: dont override, 0: disable, 1: enable, Enables buffer-offset improvement of the stateless to stateful optimization") DECLARE_DEBUG_VARIABLE(int32_t, CreateMultipleDevices, 0, "0: default - disable, 1+: Driver will create multiple (N) devices during initialization.") DECLARE_DEBUG_VARIABLE(int32_t, LimitAmountOfReturnedDevices, 0, "0: default - disable, 1+: Driver will limit the number of devices returned from clGetDeviceIds to N.") diff --git a/runtime/os_interface/linux/os_interface.cpp b/runtime/os_interface/linux/os_interface.cpp index b60c219386..721244aee4 100644 --- a/runtime/os_interface/linux/os_interface.cpp +++ b/runtime/os_interface/linux/os_interface.cpp @@ -10,7 +10,6 @@ namespace OCLRT { bool OSInterface::osEnabled64kbPages = false; -bool OSInterface::osEnableLocalMemory = false; OSInterface::OSInterface() { osInterfaceImpl = new OSInterfaceImpl(); diff --git a/runtime/os_interface/windows/os_interface.cpp b/runtime/os_interface/windows/os_interface.cpp index 0cae43cfea..1e80dc74c8 100644 --- a/runtime/os_interface/windows/os_interface.cpp +++ b/runtime/os_interface/windows/os_interface.cpp @@ -13,7 +13,6 @@ namespace OCLRT { bool OSInterface::osEnabled64kbPages = true; -bool OSInterface::osEnableLocalMemory = false; OSInterface::OSInterface() { osInterfaceImpl = new OSInterfaceImpl(); diff --git a/unit_tests/device/device_caps_tests.cpp b/unit_tests/device/device_caps_tests.cpp index 00daabbd0c..d36f16053f 100644 --- a/unit_tests/device/device_caps_tests.cpp +++ b/unit_tests/device/device_caps_tests.cpp @@ -768,11 +768,14 @@ TEST(Device_GetCaps, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreInitialize typedef HwHelperTest DeviceCapsWithModifiedHwInfoTest; -TEST_F(DeviceCapsWithModifiedHwInfoTest, GivenLocalMemorySupportedAndOsEnableLocalMemoryWhenSetThenGetEnableLocalMemoryReturnCorrectValue) { +TEST_F(DeviceCapsWithModifiedHwInfoTest, GivenLocalMemorySupportedAndOsEnableLocalMemoryAndEnableLocalMemoryDebugVarWhenSetThenGetEnableLocalMemoryReturnCorrectValue) { + DebugManagerStateRestore dbgRestore; VariableBackup orgOsEnableLocalMemory(&OSInterface::osEnableLocalMemory); std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); bool orgHwCapsLocalMemorySupported = device->getHardwareCapabilities().localMemorySupported; + DebugManager.flags.EnableLocalMemory.set(false); + device->setHWCapsLocalMemorySupported(false); OSInterface::osEnableLocalMemory = false; EXPECT_FALSE(device->getEnableLocalMemory()); @@ -789,6 +792,9 @@ TEST_F(DeviceCapsWithModifiedHwInfoTest, GivenLocalMemorySupportedAndOsEnableLoc OSInterface::osEnableLocalMemory = true; EXPECT_TRUE(device->getEnableLocalMemory()); + DebugManager.flags.EnableLocalMemory.set(true); + EXPECT_TRUE(device->getEnableLocalMemory()); + device->setHWCapsLocalMemorySupported(orgHwCapsLocalMemorySupported); } diff --git a/unit_tests/libult/CMakeLists.txt b/unit_tests/libult/CMakeLists.txt index ec3bccb2ce..e6fbaba0d8 100644 --- a/unit_tests/libult/CMakeLists.txt +++ b/unit_tests/libult/CMakeLists.txt @@ -32,6 +32,7 @@ set(IGDRCL_SRCS_LIB_ULT ${IGDRCL_SOURCE_DIR}/unit_tests/program/evaluate_unhandled_token_ult.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mock_gfx_family.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_gfx_family.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/os_interface.cpp ) if(SOURCE_LEVEL_DEBUGGER_HEADERS_DIR) diff --git a/unit_tests/libult/os_interface.cpp b/unit_tests/libult/os_interface.cpp new file mode 100644 index 0000000000..790b940c06 --- /dev/null +++ b/unit_tests/libult/os_interface.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/os_interface/os_interface.h" + +namespace OCLRT { + +bool OSInterface::osEnableLocalMemory = true; + +} // namespace OCLRT \ No newline at end of file diff --git a/unit_tests/test_files/igdrcl.config b/unit_tests/test_files/igdrcl.config index f9dc48faca..cf34cac1f4 100644 --- a/unit_tests/test_files/igdrcl.config +++ b/unit_tests/test_files/igdrcl.config @@ -89,4 +89,5 @@ DoNotRegisterTrimCallback = false AddClGlSharing = 0 EnablePassInlineData = false LimitAmountOfReturnedDevices = 0 -UseMallocToObtainHeap32Base = false \ No newline at end of file +UseMallocToObtainHeap32Base = false +EnableLocalMemory = false \ No newline at end of file