From 86edfea3bf439b147e07fba105620b9b7c705998 Mon Sep 17 00:00:00 2001 From: "Jobczyk, Lukasz" Date: Mon, 2 Sep 2019 12:04:22 +0200 Subject: [PATCH] Fix OCL specific registry path in a core dir Change-Id: I5b7792582e6c77a29ffb42b8fe024bc826ae1867 Signed-off-by: Jobczyk, Lukasz --- core/os_interface/linux/debug_env_reader.cpp | 5 +---- core/os_interface/windows/debug_registry_reader.cpp | 13 ++++--------- core/os_interface/windows/debug_registry_reader.h | 9 ++++----- core/utilities/debug_settings_reader.h | 7 +++---- core/utilities/debug_settings_reader_creator.cpp | 4 ++-- core/utilities/debug_settings_reader_creator.h | 2 +- runtime/command_stream/aub_subcapture.cpp | 3 ++- runtime/compiler_interface/binary_cache.cpp | 6 ++++-- runtime/os_interface/CMakeLists.txt | 1 + runtime/os_interface/debug_settings_manager.cpp | 3 ++- runtime/os_interface/linux/CMakeLists.txt | 1 + runtime/os_interface/linux/ocl_reg_path.cpp | 12 ++++++++++++ runtime/os_interface/ocl_reg_path.h | 11 +++++++++++ runtime/os_interface/windows/CMakeLists.txt | 1 + runtime/os_interface/windows/driver_info.cpp | 2 +- runtime/os_interface/windows/ocl_reg_path.cpp | 12 ++++++++++++ runtime/os_interface/windows/wddm/wddm.cpp | 2 +- unit_tests/main.cpp | 3 ++- .../os_interface/debug_settings_manager_tests.cpp | 9 +++++---- unit_tests/os_interface/linux/debug_env_reader.cpp | 4 ++-- .../os_interface/windows/registry_reader_tests.h | 5 +++-- .../utilities/debug_settings_reader_creator.cpp | 4 ++-- .../utilities/debug_settings_reader_tests.cpp | 9 +++++---- 23 files changed, 82 insertions(+), 46 deletions(-) create mode 100644 runtime/os_interface/linux/ocl_reg_path.cpp create mode 100644 runtime/os_interface/ocl_reg_path.h create mode 100644 runtime/os_interface/windows/ocl_reg_path.cpp diff --git a/core/os_interface/linux/debug_env_reader.cpp b/core/os_interface/linux/debug_env_reader.cpp index 932d4249d1..f2d9732a84 100644 --- a/core/os_interface/linux/debug_env_reader.cpp +++ b/core/os_interface/linux/debug_env_reader.cpp @@ -9,13 +9,10 @@ namespace NEO { -SettingsReader *SettingsReader::createOsReader(bool userScope) { +SettingsReader *SettingsReader::createOsReader(bool userScope, const std::string ®Key) { return new EnvironmentVariableReader; } -SettingsReader *SettingsReader::createOsReader(const std::string ®Key) { - return new EnvironmentVariableReader; -} const char *EnvironmentVariableReader::appSpecificLocation(const std::string &name) { return name.c_str(); } diff --git a/core/os_interface/windows/debug_registry_reader.cpp b/core/os_interface/windows/debug_registry_reader.cpp index 9c9e7f2392..2528b7a3c4 100644 --- a/core/os_interface/windows/debug_registry_reader.cpp +++ b/core/os_interface/windows/debug_registry_reader.cpp @@ -15,20 +15,15 @@ namespace NEO { -SettingsReader *SettingsReader::createOsReader(bool userScope) { - return new RegistryReader(userScope); -} -SettingsReader *SettingsReader::createOsReader(const std::string ®Key) { - return new RegistryReader("Software\\Intel\\IGFX\\OCL\\" + regKey); +SettingsReader *SettingsReader::createOsReader(bool userScope, const std::string ®Key) { + return new RegistryReader(userScope, regKey); } -RegistryReader::RegistryReader(bool userScope) { +RegistryReader::RegistryReader(bool userScope, const std::string ®Key) : registryReadRootKey(regKey) { igdrclHkeyType = userScope ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; setUpProcessName(); } -RegistryReader::RegistryReader(const std::string ®Key) : registryReadRootKey(regKey) { - setUpProcessName(); -} + void RegistryReader::setUpProcessName() { char buff[MAX_PATH]; GetModuleFileNameA(nullptr, buff, MAX_PATH); diff --git a/core/os_interface/windows/debug_registry_reader.h b/core/os_interface/windows/debug_registry_reader.h index 257f4d3d63..237a388dcf 100644 --- a/core/os_interface/windows/debug_registry_reader.h +++ b/core/os_interface/windows/debug_registry_reader.h @@ -9,7 +9,6 @@ #include "core/utilities/debug_settings_reader.h" -#include "os_inc.h" #include #include @@ -18,16 +17,16 @@ namespace NEO { class RegistryReader : public SettingsReader { public: + RegistryReader() = delete; + RegistryReader(bool userScope, const std::string ®Key); int32_t getSetting(const char *settingName, int32_t defaultValue) override; bool getSetting(const char *settingName, bool defaultValue) override; std::string getSetting(const char *settingName, const std::string &value) override; - RegistryReader(bool userScope); - RegistryReader(const std::string ®Key); const char *appSpecificLocation(const std::string &name) override; protected: - HKEY igdrclHkeyType = HKEY_LOCAL_MACHINE; - std::string registryReadRootKey = "Software\\Intel\\IGFX\\OCL"; + HKEY igdrclHkeyType; + std::string registryReadRootKey; void setUpProcessName(); std::string processName; }; diff --git a/core/utilities/debug_settings_reader.h b/core/utilities/debug_settings_reader.h index b5bec70cad..50751168a4 100644 --- a/core/utilities/debug_settings_reader.h +++ b/core/utilities/debug_settings_reader.h @@ -15,15 +15,14 @@ namespace NEO { class SettingsReader { public: virtual ~SettingsReader() {} - static SettingsReader *create() { + static SettingsReader *create(const std::string ®Key) { SettingsReader *readerImpl = createFileReader(); if (readerImpl != nullptr) return readerImpl; - return createOsReader(false); + return createOsReader(false, regKey); } - static SettingsReader *createOsReader(bool userScope); - static SettingsReader *createOsReader(const std::string ®Key); + static SettingsReader *createOsReader(bool userScope, const std::string ®Key); static SettingsReader *createFileReader(); virtual int32_t getSetting(const char *settingName, int32_t defaultValue) = 0; virtual bool getSetting(const char *settingName, bool defaultValue) = 0; diff --git a/core/utilities/debug_settings_reader_creator.cpp b/core/utilities/debug_settings_reader_creator.cpp index 499213a3f4..48e70b08e1 100644 --- a/core/utilities/debug_settings_reader_creator.cpp +++ b/core/utilities/debug_settings_reader_creator.cpp @@ -8,7 +8,7 @@ #include "core/utilities/debug_settings_reader_creator.h" namespace NEO { -std::unique_ptr SettingsReaderCreator::create() { - return std::unique_ptr(SettingsReader::create()); +std::unique_ptr SettingsReaderCreator::create(const std::string ®Key) { + return std::unique_ptr(SettingsReader::create(regKey)); } }; // namespace NEO diff --git a/core/utilities/debug_settings_reader_creator.h b/core/utilities/debug_settings_reader_creator.h index 895b69f8f9..b0693543dd 100644 --- a/core/utilities/debug_settings_reader_creator.h +++ b/core/utilities/debug_settings_reader_creator.h @@ -14,6 +14,6 @@ namespace NEO { class SettingsReaderCreator { public: - static std::unique_ptr create(); + static std::unique_ptr create(const std::string ®Key); }; } // namespace NEO diff --git a/runtime/command_stream/aub_subcapture.cpp b/runtime/command_stream/aub_subcapture.cpp index 9d9133a407..91d78e3044 100644 --- a/runtime/command_stream/aub_subcapture.cpp +++ b/runtime/command_stream/aub_subcapture.cpp @@ -10,12 +10,13 @@ #include "core/utilities/debug_settings_reader.h" #include "runtime/helpers/dispatch_info.h" #include "runtime/kernel/kernel.h" +#include "runtime/os_interface/ocl_reg_path.h" namespace NEO { AubSubCaptureManager::AubSubCaptureManager(const std::string &fileName, AubSubCaptureCommon &subCaptureCommon) : initialFileName(fileName), subCaptureCommon(subCaptureCommon) { - settingsReader.reset(SettingsReader::createOsReader(true)); + settingsReader.reset(SettingsReader::createOsReader(true, oclRegPath)); } AubSubCaptureManager::~AubSubCaptureManager() = default; diff --git a/runtime/compiler_interface/binary_cache.cpp b/runtime/compiler_interface/binary_cache.cpp index 3c17f15d8a..337b88f484 100644 --- a/runtime/compiler_interface/binary_cache.cpp +++ b/runtime/compiler_interface/binary_cache.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -53,8 +54,9 @@ const std::string BinaryCache::getCachedFileName(const HardwareInfo &hwInfo, con } BinaryCache::BinaryCache() { - std::string keyName = "cl_cache_dir"; - std::unique_ptr settingsReader(SettingsReader::createOsReader(keyName)); + std::string keyName = oclRegPath; + keyName += "cl_cache_dir"; + std::unique_ptr settingsReader(SettingsReader::createOsReader(false, keyName)); clCacheLocation = settingsReader->getSetting(settingsReader->appSpecificLocation(keyName), static_cast(CL_CACHE_LOCATION)); }; diff --git a/runtime/os_interface/CMakeLists.txt b/runtime/os_interface/CMakeLists.txt index a9af2335fb..5f6a44f994 100644 --- a/runtime/os_interface/CMakeLists.txt +++ b/runtime/os_interface/CMakeLists.txt @@ -18,6 +18,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_BASE ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_bdw_plus.inl ${CMAKE_CURRENT_SOURCE_DIR}/metrics_library.cpp ${CMAKE_CURRENT_SOURCE_DIR}/metrics_library.h + ${CMAKE_CURRENT_SOURCE_DIR}/ocl_reg_path.h ${CMAKE_CURRENT_SOURCE_DIR}/os_context.h ${CMAKE_CURRENT_SOURCE_DIR}/os_inc_base.h ${CMAKE_CURRENT_SOURCE_DIR}/os_interface.h diff --git a/runtime/os_interface/debug_settings_manager.cpp b/runtime/os_interface/debug_settings_manager.cpp index b84fb969d5..729c5726fd 100644 --- a/runtime/os_interface/debug_settings_manager.cpp +++ b/runtime/os_interface/debug_settings_manager.cpp @@ -16,6 +16,7 @@ #include "runtime/kernel/kernel.h" #include "runtime/mem_obj/mem_obj.h" #include "runtime/os_interface/definitions/translate_debug_settings.h" +#include "runtime/os_interface/ocl_reg_path.h" #include "CL/cl.h" @@ -37,7 +38,7 @@ DebugSettingsManager::DebugSettingsManager() { logFileName = "igdrcl.log"; if (registryReadAvailable()) { - readerImpl = SettingsReaderCreator::create(); + readerImpl = SettingsReaderCreator::create(oclRegPath); injectSettingsFromReader(); dumpFlags(); } diff --git a/runtime/os_interface/linux/CMakeLists.txt b/runtime/os_interface/linux/CMakeLists.txt index 91800169bb..7e95fd719f 100644 --- a/runtime/os_interface/linux/CMakeLists.txt +++ b/runtime/os_interface/linux/CMakeLists.txt @@ -36,6 +36,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_LINUX ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_info.h + ${CMAKE_CURRENT_SOURCE_DIR}/ocl_reg_path.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.h ${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h diff --git a/runtime/os_interface/linux/ocl_reg_path.cpp b/runtime/os_interface/linux/ocl_reg_path.cpp new file mode 100644 index 0000000000..80d0b55e92 --- /dev/null +++ b/runtime/os_interface/linux/ocl_reg_path.cpp @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/os_interface/ocl_reg_path.h" + +namespace NEO { +const char *oclRegPath = ""; +} diff --git a/runtime/os_interface/ocl_reg_path.h b/runtime/os_interface/ocl_reg_path.h new file mode 100644 index 0000000000..8ee5c8442b --- /dev/null +++ b/runtime/os_interface/ocl_reg_path.h @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +namespace NEO { +extern const char *oclRegPath; +} // namespace NEO diff --git a/runtime/os_interface/windows/CMakeLists.txt b/runtime/os_interface/windows/CMakeLists.txt index 1648e1d1c0..ee314eaabd 100644 --- a/runtime/os_interface/windows/CMakeLists.txt +++ b/runtime/os_interface/windows/CMakeLists.txt @@ -27,6 +27,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS ${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.h ${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener${KMDAF_FILE_SUFFIX}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener.h + ${CMAKE_CURRENT_SOURCE_DIR}/ocl_reg_path.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_context_win.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_context_win.h ${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h diff --git a/runtime/os_interface/windows/driver_info.cpp b/runtime/os_interface/windows/driver_info.cpp index 1871953128..a267b13a55 100644 --- a/runtime/os_interface/windows/driver_info.cpp +++ b/runtime/os_interface/windows/driver_info.cpp @@ -24,7 +24,7 @@ DriverInfo *DriverInfo::create(OSInterface *osInterface) { auto result = new DriverInfoWindows(); path = result->trimRegistryKey(path); - result->setRegistryReader(new RegistryReader(path)); + result->setRegistryReader(new RegistryReader(false, path)); return result; } diff --git a/runtime/os_interface/windows/ocl_reg_path.cpp b/runtime/os_interface/windows/ocl_reg_path.cpp new file mode 100644 index 0000000000..386191e16d --- /dev/null +++ b/runtime/os_interface/windows/ocl_reg_path.cpp @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/os_interface/ocl_reg_path.h" + +namespace NEO { +const char *oclRegPath = "Software\\Intel\\IGFX\\OCL\\"; +} diff --git a/runtime/os_interface/windows/wddm/wddm.cpp b/runtime/os_interface/windows/wddm/wddm.cpp index 49d18f05ef..833523e06b 100644 --- a/runtime/os_interface/windows/wddm/wddm.cpp +++ b/runtime/os_interface/windows/wddm/wddm.cpp @@ -49,7 +49,7 @@ Wddm::Wddm() { memset(gtSystemInfo.get(), 0, sizeof(*gtSystemInfo)); memset(gfxPlatform.get(), 0, sizeof(*gfxPlatform)); - registryReader.reset(new RegistryReader("System\\CurrentControlSet\\Control\\GraphicsDrivers\\Scheduler")); + registryReader.reset(new RegistryReader(false, "System\\CurrentControlSet\\Control\\GraphicsDrivers\\Scheduler")); adapterLuid.HighPart = 0; adapterLuid.LowPart = 0; kmDafListener = std::unique_ptr(new KmDafListener); diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 26485bc0a4..84ff84f25d 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -11,6 +11,7 @@ #include "runtime/helpers/options.h" #include "runtime/os_interface/debug_settings_manager.h" #include "runtime/os_interface/hw_info_config.h" +#include "runtime/os_interface/ocl_reg_path.h" #include "unit_tests/custom_event_listener.h" #include "unit_tests/mocks/mock_gmm.h" #include "unit_tests/mocks/mock_program.h" @@ -275,7 +276,7 @@ int main(int argc, char **argv) { generateRandomInput = true; } else if (!strcmp("--read-config", argv[i]) && testMode == TestMode::AubTests) { if (DebugManager.registryReadAvailable()) { - DebugManager.setReaderImpl(SettingsReader::create()); + DebugManager.setReaderImpl(SettingsReader::create(oclRegPath)); DebugManager.injectSettingsFromReader(); } } else if (!strcmp("--dump_buffer_format", argv[i]) && testMode == TestMode::AubTests) { diff --git a/unit_tests/os_interface/debug_settings_manager_tests.cpp b/unit_tests/os_interface/debug_settings_manager_tests.cpp index 11706bcbcb..3814a89933 100644 --- a/unit_tests/os_interface/debug_settings_manager_tests.cpp +++ b/unit_tests/os_interface/debug_settings_manager_tests.cpp @@ -7,6 +7,7 @@ #include "core/unit_tests/helpers/debug_manager_state_restore.h" #include "core/utilities/debug_file_reader.h" +#include "runtime/os_interface/ocl_reg_path.h" #include "unit_tests/fixtures/buffer_fixture.h" #include "unit_tests/fixtures/image_fixture.h" #include "unit_tests/mocks/mock_buffer.h" @@ -42,7 +43,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityCreatesAndDumpsToLogFile) { FullyEnabledTestDebugManager debugManager; if (debugManager.registryReadAvailable()) { - debugManager.setReaderImpl(SettingsReader::create()); + debugManager.setReaderImpl(SettingsReader::create(oclRegPath)); debugManager.injectSettingsFromReader(); } debugManager.logApiCall("searchString", true, 0); @@ -850,16 +851,16 @@ TEST(DebugSettingsManager, givenStringDebugVariableWhenLongValueExeedingSmallStr TEST(DebugSettingsManager, givenNullAsReaderImplInDebugManagerWhenSettingReaderImplThenItsSetProperly) { FullyDisabledTestDebugManager debugManager; - auto readerImpl = SettingsReader::create(); + auto readerImpl = SettingsReader::create(oclRegPath); debugManager.setReaderImpl(readerImpl); EXPECT_EQ(readerImpl, debugManager.getReaderImpl()); } TEST(DebugSettingsManager, givenReaderImplInDebugManagerWhenSettingDifferentReaderImplThenItsSetProperly) { FullyDisabledTestDebugManager debugManager; - auto readerImpl = SettingsReader::create(); + auto readerImpl = SettingsReader::create(oclRegPath); debugManager.setReaderImpl(readerImpl); - auto readerImpl2 = SettingsReader::create(); + auto readerImpl2 = SettingsReader::create(oclRegPath); debugManager.setReaderImpl(readerImpl2); EXPECT_EQ(readerImpl2, debugManager.getReaderImpl()); } diff --git a/unit_tests/os_interface/linux/debug_env_reader.cpp b/unit_tests/os_interface/linux/debug_env_reader.cpp index e59d5e2f18..17a8cfd5b8 100644 --- a/unit_tests/os_interface/linux/debug_env_reader.cpp +++ b/unit_tests/os_interface/linux/debug_env_reader.cpp @@ -16,7 +16,7 @@ namespace NEO { class DebugEnvReaderTests : public ::testing::Test { public: void SetUp() override { - evr = SettingsReader::createOsReader(false); + evr = SettingsReader::createOsReader(false, ""); EXPECT_NE(nullptr, evr); } void TearDown() override { @@ -79,7 +79,7 @@ TEST_F(DebugEnvReaderTests, appSpecificLacationReturnClCacheLocation) { } TEST_F(DebugEnvReaderTests, givenEnvironmentVariableReaderWhenCreateOsReaderWithStringThenNotNullPointer) { - std::unique_ptr evr(SettingsReader::createOsReader("")); + std::unique_ptr evr(SettingsReader::createOsReader(false, "")); EXPECT_NE(nullptr, evr); } } // namespace NEO diff --git a/unit_tests/os_interface/windows/registry_reader_tests.h b/unit_tests/os_interface/windows/registry_reader_tests.h index 11e136f64c..23d2587f87 100644 --- a/unit_tests/os_interface/windows/registry_reader_tests.h +++ b/unit_tests/os_interface/windows/registry_reader_tests.h @@ -6,12 +6,13 @@ */ #include "core/os_interface/windows/debug_registry_reader.h" +#include "runtime/os_interface/ocl_reg_path.h" namespace NEO { class TestedRegistryReader : public RegistryReader { public: - TestedRegistryReader(bool userScope) : RegistryReader(userScope){}; - TestedRegistryReader(std::string regKey) : RegistryReader(regKey){}; + TestedRegistryReader(bool userScope) : RegistryReader(userScope, oclRegPath){}; + TestedRegistryReader(std::string regKey) : RegistryReader(false, regKey){}; HKEY getHkeyType() const { return igdrclHkeyType; } diff --git a/unit_tests/utilities/debug_settings_reader_creator.cpp b/unit_tests/utilities/debug_settings_reader_creator.cpp index 9116b6329f..aca33c9172 100644 --- a/unit_tests/utilities/debug_settings_reader_creator.cpp +++ b/unit_tests/utilities/debug_settings_reader_creator.cpp @@ -8,7 +8,7 @@ #include "core/utilities/debug_settings_reader_creator.h" namespace NEO { -std::unique_ptr SettingsReaderCreator::create() { - return std::unique_ptr(SettingsReader::createOsReader(false)); +std::unique_ptr SettingsReaderCreator::create(const std::string ®Key) { + return std::unique_ptr(SettingsReader::createOsReader(false, regKey)); } } // namespace NEO diff --git a/unit_tests/utilities/debug_settings_reader_tests.cpp b/unit_tests/utilities/debug_settings_reader_tests.cpp index a6eb46fc29..93062f999e 100644 --- a/unit_tests/utilities/debug_settings_reader_tests.cpp +++ b/unit_tests/utilities/debug_settings_reader_tests.cpp @@ -8,6 +8,7 @@ #include "core/utilities/debug_settings_reader.h" #include "runtime/helpers/file_io.h" #include "runtime/os_interface/debug_settings_manager.h" +#include "runtime/os_interface/ocl_reg_path.h" #include "test.h" #include "gtest/gtest.h" @@ -19,7 +20,7 @@ using namespace NEO; using namespace std; TEST(SettingsReader, Create) { - SettingsReader *reader = SettingsReader::create(); + SettingsReader *reader = SettingsReader::create(oclRegPath); EXPECT_NE(nullptr, reader); delete reader; } @@ -40,14 +41,14 @@ TEST(SettingsReader, CreateFileReader) { } TEST(SettingsReader, CreateOsReader) { - SettingsReader *reader = SettingsReader::createOsReader(false); + SettingsReader *reader = SettingsReader::createOsReader(false, oclRegPath); EXPECT_NE(nullptr, reader); delete reader; } TEST(SettingsReader, CreateOsReaderWithRegKey) { - std::string regKey = "Software\\Intel\\OpenCL"; - unique_ptr reader(SettingsReader::createOsReader(regKey)); + std::string regKey = oclRegPath; + unique_ptr reader(SettingsReader::createOsReader(false, regKey)); EXPECT_NE(nullptr, reader); }