diff --git a/level_zero/core/source/compiler_interface/CMakeLists.txt b/level_zero/core/source/compiler_interface/CMakeLists.txt index e5c4a89e88..afa3211218 100644 --- a/level_zero/core/source/compiler_interface/CMakeLists.txt +++ b/level_zero/core/source/compiler_interface/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2023 Intel Corporation +# Copyright (C) 2020-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -7,6 +7,5 @@ target_sources(${L0_STATIC_LIB_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/default_cache_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/l0_reg_path.h ) diff --git a/level_zero/core/source/compiler_interface/default_cache_config.cpp b/level_zero/core/source/compiler_interface/default_cache_config.cpp deleted file mode 100644 index c2321a623d..0000000000 --- a/level_zero/core/source/compiler_interface/default_cache_config.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2020-2024 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#define L0_CACHE_LOCATION "l0_cache" - -#include "shared/source/compiler_interface/default_cache_config.h" - -#include "shared/source/helpers/constants.h" -#include "shared/source/os_interface/sys_calls_common.h" -#include "shared/source/utilities/debug_settings_reader.h" - -#include "level_zero/core/source/compiler_interface/l0_reg_path.h" - -#include - -namespace NEO { -CompilerCacheConfig getDefaultCompilerCacheConfig() { - NEO::CompilerCacheConfig ret; - - std::string keyName = L0::registryPath; - keyName += "l0_cache_dir"; - std::unique_ptr settingsReader(NEO::SettingsReader::createOsReader(false, keyName)); - ret.cacheDir = settingsReader->getSetting(settingsReader->appSpecificLocation(keyName), static_cast(L0_CACHE_LOCATION)); - - if (NEO::SysCalls::pathExists(ret.cacheDir)) { - ret.enabled = true; - ret.cacheSize = MemoryConstants::gigaByte; - ret.cacheFileExtension = ".l0_cache"; - } else { - ret.enabled = false; - ret.cacheSize = 0u; - ret.cacheFileExtension = ".l0_cache"; - } - - return ret; -} - -} // namespace NEO diff --git a/level_zero/core/source/helpers/api_specific_config_l0.cpp b/level_zero/core/source/helpers/api_specific_config_l0.cpp index 5473279411..a9d4a5c13d 100644 --- a/level_zero/core/source/helpers/api_specific_config_l0.cpp +++ b/level_zero/core/source/helpers/api_specific_config_l0.cpp @@ -74,4 +74,20 @@ bool ApiSpecificConfig::isSharedAllocPrefetchEnabled() { return (NEO::debugManager.flags.ForceMemoryPrefetchForKmdMigratedSharedAllocations.get() || (NEO::debugManager.flags.EnableBOChunkingPrefetch.get() && ((NEO::debugManager.flags.EnableBOChunking.get()) != -1) && ((NEO::debugManager.flags.EnableBOChunking.get()) & 0x1))); } + +std::string ApiSpecificConfig::compilerCacheDir() { + return "l0_cache_dir"; +} + +std::string ApiSpecificConfig::compilerCacheLocation() { + return "l0_cache"; +} + +std::string ApiSpecificConfig::compilerCacheFileExtension() { + return ".l0_cache"; +} + +int64_t ApiSpecificConfig::compilerCacheDefaultEnabled() { + return 0l; +} } // namespace NEO diff --git a/level_zero/core/test/unit_tests/sources/helper/api_specific_config_l0_tests.cpp b/level_zero/core/test/unit_tests/sources/helper/api_specific_config_l0_tests.cpp index ba7ef6c5d6..6a85fa16d9 100644 --- a/level_zero/core/test/unit_tests/sources/helper/api_specific_config_l0_tests.cpp +++ b/level_zero/core/test/unit_tests/sources/helper/api_specific_config_l0_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -78,4 +78,21 @@ TEST(ApiSpecificConfigL0Tests, GivenDebugFlagCombinationsGetCorrectSharedAllocPr TEST(ImplicitScalingApiTests, givenLevelZeroApiUsedThenSupportEnabled) { EXPECT_TRUE(ImplicitScaling::apiSupport); } + +TEST(ApiSpecificConfigL0Tests, WhenGettingCompilerCacheDirThenReturnProperDirString) { + EXPECT_EQ(0, strcmp("l0_cache_dir", ApiSpecificConfig::compilerCacheDir().c_str())); +} + +TEST(ApiSpecificConfigL0Tests, WhenGettingCompilerCacheLocationThenReturnProperLocationString) { + EXPECT_EQ(0, strcmp("l0_cache", ApiSpecificConfig::compilerCacheLocation().c_str())); +} + +TEST(ApiSpecificConfigL0Tests, WhenGettingCompilerCacheFileExtensionThenReturnProperFileExtensionString) { + EXPECT_EQ(0, strcmp(".l0_cache", ApiSpecificConfig::compilerCacheFileExtension().c_str())); +} + +TEST(ApiSpecificConfigL0Tests, WhenCheckingIfCompilerCacheIsEnabledByDefaultThenReturnTrue) { + EXPECT_EQ(0l, ApiSpecificConfig::compilerCacheDefaultEnabled()); +} + } // namespace NEO diff --git a/opencl/source/compiler_interface/CMakeLists.txt b/opencl/source/compiler_interface/CMakeLists.txt deleted file mode 100644 index ede9bd1361..0000000000 --- a/opencl/source/compiler_interface/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (C) 2018-2022 Intel Corporation -# -# SPDX-License-Identifier: MIT -# - -set(RUNTIME_SRCS_COMPILER_INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/default_cache_config.cpp -) - -target_sources(${NEO_STATIC_LIB_NAME} PRIVATE - ${RUNTIME_SRCS_COMPILER_INTERFACE} - ${NEO_SHARED_DIRECTORY}/compiler_interface/oclc_extensions.cpp - ${NEO_SHARED_DIRECTORY}/compiler_interface/oclc_extensions.h -) -set_property(GLOBAL PROPERTY RUNTIME_SRCS_COMPILER_INTERFACE ${RUNTIME_SRCS_COMPILER_INTERFACE}) diff --git a/opencl/source/dll/CMakeLists.txt b/opencl/source/dll/CMakeLists.txt index f0bab87995..826ecad35e 100644 --- a/opencl/source/dll/CMakeLists.txt +++ b/opencl/source/dll/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2018-2023 Intel Corporation +# Copyright (C) 2018-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -30,8 +30,8 @@ set(RUNTIME_SRCS_DLL_BASE ${NEO_SHARED_DIRECTORY}/utilities/cpuintrinsics.cpp ${NEO_SHARED_DIRECTORY}/utilities/debug_settings_reader_creator.cpp ${NEO_SHARED_DIRECTORY}/utilities/io_functions.cpp + ${NEO_SHARED_DIRECTORY}/compiler_interface/default_cache_config.cpp ${NEO_SOURCE_DIR}/opencl/source/api/api.cpp - ${NEO_SOURCE_DIR}/opencl/source/compiler_interface/default_cache_config.cpp ${NEO_SOURCE_DIR}/opencl/source/dll/debug_manager.cpp ${NEO_SOURCE_DIR}/opencl/source/helpers/api_specific_config_ocl.cpp diff --git a/opencl/source/helpers/api_specific_config_ocl.cpp b/opencl/source/helpers/api_specific_config_ocl.cpp index 7ef7c0a26f..7d470438d5 100644 --- a/opencl/source/helpers/api_specific_config_ocl.cpp +++ b/opencl/source/helpers/api_specific_config_ocl.cpp @@ -68,4 +68,20 @@ const StackVec &ApiSpecificConfig::getPrefixStrings() { const StackVec &ApiSpecificConfig::getPrefixTypes() { return validClPrefixTypes; } + +std::string ApiSpecificConfig::compilerCacheDir() { + return "cl_cache_dir"; +} + +std::string ApiSpecificConfig::compilerCacheLocation() { + return "cl_cache"; +} + +std::string ApiSpecificConfig::compilerCacheFileExtension() { + return ".cl_cache"; +} + +int64_t ApiSpecificConfig::compilerCacheDefaultEnabled() { + return 1l; +} } // namespace NEO diff --git a/opencl/test/unit_test/compiler_interface/CMakeLists.txt b/opencl/test/unit_test/compiler_interface/CMakeLists.txt index b197034340..0550acbf94 100644 --- a/opencl/test/unit_test/compiler_interface/CMakeLists.txt +++ b/opencl/test/unit_test/compiler_interface/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2018-2023 Intel Corporation +# Copyright (C) 2018-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -11,8 +11,3 @@ set(IGDRCL_SRCS_tests_compiler_interface target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_compiler_interface}) -if(NOT WIN32) - target_sources(igdrcl_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/linux/default_cl_cache_config_tests.cpp) -else() - target_sources(igdrcl_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/windows/default_cl_cache_config_tests.cpp) -endif() diff --git a/opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp b/opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp index 7d9b7b90fa..0fcb55eddd 100644 --- a/opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp +++ b/opencl/test/unit_test/helpers/api_specific_config_ocl_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -70,4 +70,21 @@ TEST(ApiSpecificConfigOclTests, givenEnableStatelessCompressionWhenProvidingPrin EXPECT_TRUE(NEO::CompressionSelector::preferCompressedAllocation(properties)); } + +TEST(ApiSpecificConfigOclTests, WhenGettingCompilerCacheDirThenReturnProperDirString) { + EXPECT_EQ(0, strcmp("cl_cache_dir", ApiSpecificConfig::compilerCacheDir().c_str())); +} + +TEST(ApiSpecificConfigOclTests, WhenGettingCompilerCacheLocationThenReturnProperLocationString) { + EXPECT_EQ(0, strcmp("cl_cache", ApiSpecificConfig::compilerCacheLocation().c_str())); +} + +TEST(ApiSpecificConfigOclTests, WhenGettingCompilerCacheFileExtensionThenReturnProperFileExtensionString) { + EXPECT_EQ(0, strcmp(".cl_cache", ApiSpecificConfig::compilerCacheFileExtension().c_str())); +} + +TEST(ApiSpecificConfigOclTests, WhenCheckingIfCompilerCacheIsEnabledByDefaultThenReturnTrue) { + EXPECT_EQ(1u, ApiSpecificConfig::compilerCacheDefaultEnabled()); +} + } // namespace NEO diff --git a/opencl/test/unit_test/libult/CMakeLists.txt b/opencl/test/unit_test/libult/CMakeLists.txt index 26b02a851f..d65d80f1a2 100644 --- a/opencl/test/unit_test/libult/CMakeLists.txt +++ b/opencl/test/unit_test/libult/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2018-2023 Intel Corporation +# Copyright (C) 2018-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -17,13 +17,13 @@ endmacro() apply_macro_for_each_core_type("TESTED") set(IGDRCL_SRCS_LIB_ULT - ${NEO_SOURCE_DIR}/opencl/source/compiler_interface/default_cache_config.cpp ${NEO_SOURCE_DIR}/opencl/source/dll/debug_manager.cpp ${NEO_SOURCE_DIR}/opencl/source/helpers/api_specific_config_ocl.cpp ${NEO_SOURCE_DIR}/opencl/source/helpers/implicit_scaling_ocl.cpp ${NEO_SOURCE_DIR}/opencl/source/memory_manager/compression_selector_ocl.cpp ${NEO_SOURCE_DIR}/opencl/source/memory_manager/cpu_page_fault_manager_memory_sync.cpp ${NEO_SOURCE_DIR}/shared/source/helpers/allow_deferred_deleter.cpp + ${NEO_SOURCE_DIR}/shared/source/compiler_interface/default_cache_config.cpp ${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/cl_execution_environment_helper.cpp ${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/cl_execution_environment_helper.h ) diff --git a/shared/source/compiler_interface/CMakeLists.txt b/shared/source/compiler_interface/CMakeLists.txt index 470285ef66..0c3940db29 100644 --- a/shared/source/compiler_interface/CMakeLists.txt +++ b/shared/source/compiler_interface/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 Intel Corporation +# Copyright (C) 2019-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -17,6 +17,7 @@ set(NEO_CORE_COMPILER_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}compiler_options_extra.cpp ${CMAKE_CURRENT_SOURCE_DIR}/compiler_warnings/compiler_warnings.h ${CMAKE_CURRENT_SOURCE_DIR}/create_main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/default_cache_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/default_cache_config.h ${CMAKE_CURRENT_SOURCE_DIR}/external_functions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/external_functions.h diff --git a/opencl/source/compiler_interface/default_cache_config.cpp b/shared/source/compiler_interface/default_cache_config.cpp similarity index 60% rename from opencl/source/compiler_interface/default_cache_config.cpp rename to shared/source/compiler_interface/default_cache_config.cpp index d710f21e52..af9edef712 100644 --- a/opencl/source/compiler_interface/default_cache_config.cpp +++ b/shared/source/compiler_interface/default_cache_config.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2024 Intel Corporation + * Copyright (C) 2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,27 +8,27 @@ #include "shared/source/compiler_interface/default_cache_config.h" #include "shared/source/compiler_interface/os_compiler_cache_helper.h" +#include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/constants.h" #include "shared/source/os_interface/debug_env_reader.h" #include "shared/source/os_interface/sys_calls_common.h" #include "shared/source/utilities/debug_settings_reader.h" -#include "config.h" -#include "os_inc.h" - #include namespace NEO { -std::string neoCachePersistent = "NEO_CACHE_PERSISTENT"; -std::string neoCacheMaxSize = "NEO_CACHE_MAX_SIZE"; -std::string neoCacheDir = "NEO_CACHE_DIR"; -std::string clCacheDir = "cl_cache_dir"; + +const std::string neoCachePersistent = "NEO_CACHE_PERSISTENT"; +const std::string neoCacheMaxSize = "NEO_CACHE_MAX_SIZE"; +const std::string neoCacheDir = "NEO_CACHE_DIR"; + +const int64_t neoCacheMaxSizeDefault = static_cast(MemoryConstants::gigaByte); CompilerCacheConfig getDefaultCompilerCacheConfig() { CompilerCacheConfig ret; NEO::EnvironmentVariableReader envReader; - if (envReader.getSetting(neoCachePersistent.c_str(), defaultCacheEnabled()) != 0) { + if (envReader.getSetting(neoCachePersistent.c_str(), ApiSpecificConfig::compilerCacheDefaultEnabled()) != 0) { ret.enabled = true; std::string emptyString = ""; ret.cacheDir = envReader.getSetting(neoCacheDir.c_str(), emptyString); @@ -46,8 +46,8 @@ CompilerCacheConfig getDefaultCompilerCacheConfig() { } } - ret.cacheFileExtension = ".cl_cache"; - ret.cacheSize = static_cast(envReader.getSetting(neoCacheMaxSize.c_str(), static_cast(MemoryConstants::gigaByte))); + ret.cacheFileExtension = ApiSpecificConfig::compilerCacheFileExtension(); + ret.cacheSize = static_cast(envReader.getSetting(neoCacheMaxSize.c_str(), neoCacheMaxSizeDefault)); if (ret.cacheSize == 0u) { ret.cacheSize = std::numeric_limits::max(); @@ -56,16 +56,16 @@ CompilerCacheConfig getDefaultCompilerCacheConfig() { return ret; } - ret.cacheDir = envReader.getSetting(clCacheDir.c_str(), static_cast(CL_CACHE_LOCATION)); + ret.cacheDir = envReader.getSetting(ApiSpecificConfig::compilerCacheDir().c_str(), ApiSpecificConfig::compilerCacheLocation()); if (NEO::SysCalls::pathExists(ret.cacheDir)) { ret.enabled = true; - ret.cacheSize = MemoryConstants::gigaByte; - ret.cacheFileExtension = ".cl_cache"; + ret.cacheSize = static_cast(neoCacheMaxSizeDefault); + ret.cacheFileExtension = ApiSpecificConfig::compilerCacheFileExtension(); } else { ret.enabled = false; ret.cacheSize = 0u; - ret.cacheFileExtension = ".cl_cache"; + ret.cacheFileExtension = ApiSpecificConfig::compilerCacheFileExtension(); } return ret; diff --git a/shared/source/compiler_interface/linux/os_compiler_cache_helper.cpp b/shared/source/compiler_interface/linux/os_compiler_cache_helper.cpp index f7ab23092a..8e8ec692d0 100644 --- a/shared/source/compiler_interface/linux/os_compiler_cache_helper.cpp +++ b/shared/source/compiler_interface/linux/os_compiler_cache_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -18,10 +18,6 @@ #include namespace NEO { -int64_t defaultCacheEnabled() { - return 1l; -} - bool createCompilerCachePath(std::string &cacheDir) { if (NEO::SysCalls::pathExists(cacheDir)) { if (NEO::SysCalls::pathExists(joinPath(cacheDir, "neo_compiler_cache"))) { diff --git a/shared/source/compiler_interface/os_compiler_cache_helper.h b/shared/source/compiler_interface/os_compiler_cache_helper.h index 11a492254d..5f76bf69aa 100644 --- a/shared/source/compiler_interface/os_compiler_cache_helper.h +++ b/shared/source/compiler_interface/os_compiler_cache_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -10,7 +10,6 @@ namespace NEO { class EnvironmentVariableReader; -int64_t defaultCacheEnabled(); bool checkDefaultCacheDirSettings(std::string &cacheDir, NEO::EnvironmentVariableReader &reader); time_t getFileModificationTime(const std::string &path); size_t getFileSize(const std::string &path); diff --git a/shared/source/compiler_interface/windows/os_compiler_cache_helper.cpp b/shared/source/compiler_interface/windows/os_compiler_cache_helper.cpp index 89e5fabebd..480f0b56cc 100644 --- a/shared/source/compiler_interface/windows/os_compiler_cache_helper.cpp +++ b/shared/source/compiler_interface/windows/os_compiler_cache_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2023-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,10 +15,6 @@ #include namespace NEO { -int64_t defaultCacheEnabled() { - return 1l; -} - std::string getKnownFolderPath(REFKNOWNFOLDERID rfid) { PWSTR path = nullptr; auto result = SysCalls::shGetKnownFolderPath(rfid, 0, nullptr, &path); diff --git a/shared/source/helpers/api_specific_config.h b/shared/source/helpers/api_specific_config.h index 3d4faba7e1..6d816f3036 100644 --- a/shared/source/helpers/api_specific_config.h +++ b/shared/source/helpers/api_specific_config.h @@ -35,5 +35,9 @@ struct ApiSpecificConfig { return (getName() + "_"); } static bool isSharedAllocPrefetchEnabled(); + static std::string compilerCacheDir(); + static std::string compilerCacheLocation(); + static std::string compilerCacheFileExtension(); + static int64_t compilerCacheDefaultEnabled(); }; } // namespace NEO diff --git a/shared/test/unit_test/api_specific_config_ult.cpp b/shared/test/unit_test/api_specific_config_ult.cpp index 3c364caf66..ceae45ce74 100644 --- a/shared/test/unit_test/api_specific_config_ult.cpp +++ b/shared/test/unit_test/api_specific_config_ult.cpp @@ -78,4 +78,20 @@ const StackVec &ApiSpecificConfig::getPrefixTypes() { } } +std::string ApiSpecificConfig::compilerCacheDir() { + return "cl_cache_dir"; +} + +std::string ApiSpecificConfig::compilerCacheLocation() { + return "cl_cache"; +} + +std::string ApiSpecificConfig::compilerCacheFileExtension() { + return ".cl_cache"; +} + +int64_t ApiSpecificConfig::compilerCacheDefaultEnabled() { + return 1l; +} + } // namespace NEO diff --git a/shared/test/unit_test/compiler_interface/CMakeLists.txt b/shared/test/unit_test/compiler_interface/CMakeLists.txt index 1e8d8144cb..d942276808 100644 --- a/shared/test/unit_test/compiler_interface/CMakeLists.txt +++ b/shared/test/unit_test/compiler_interface/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2019-2023 Intel Corporation +# Copyright (C) 2019-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -17,9 +17,11 @@ target_sources(neo_shared_tests PRIVATE if(WIN32) target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/windows/compiler_cache_tests_windows.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/windows/default_cl_cache_config_tests.cpp ) else() target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/linux/compiler_cache_tests_linux.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/linux/default_cl_cache_config_tests.cpp ) endif() diff --git a/opencl/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp b/shared/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp similarity index 79% rename from opencl/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp rename to shared/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp index c589b8978a..373d7e7a9c 100644 --- a/opencl/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp +++ b/shared/test/unit_test/compiler_interface/linux/default_cl_cache_config_tests.cpp @@ -6,8 +6,10 @@ */ #include "shared/source/compiler_interface/default_cache_config.h" +#include "shared/source/helpers/api_specific_config.h" #include "shared/source/os_interface/sys_calls_common.h" #include "shared/source/utilities/io_functions.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/mock_io_functions.h" #include "shared/test/common/os_interface/linux/sys_calls_linux_ult.h" @@ -21,14 +23,14 @@ extern bool pathExistsMock; namespace LegacyPathWorksIfNewEnvIsSetToDisabled { bool pathExistsMock(const std::string &path) { - if (path.find("cl_cache") != path.npos) + if (path.find(ApiSpecificConfig::compilerCacheLocation().c_str()) != path.npos) return true; return false; } } // namespace LegacyPathWorksIfNewEnvIsSetToDisabled -TEST(CompilerCache, GivenDefaultClCacheConfigWithPathExistsAndNewEnvSetToDisabledThenValuesAreProperlyPopulated) { +TEST(ClCacheDefaultConfigLinuxTest, GivenDefaultClCacheConfigWithPathExistsAndNewEnvSetToDisabledThenValuesAreProperlyPopulated) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "0"; @@ -36,8 +38,8 @@ TEST(CompilerCache, GivenDefaultClCacheConfigWithPathExistsAndNewEnvSetToDisable VariableBackup pathExistsBackup(&NEO::SysCalls::sysCallsPathExists, LegacyPathWorksIfNewEnvIsSetToDisabled::pathExistsMock); auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); - EXPECT_STREQ("cl_cache", cacheConfig.cacheDir.c_str()); - EXPECT_STREQ(".cl_cache", cacheConfig.cacheFileExtension.c_str()); + EXPECT_STREQ(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str()); + EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str()); EXPECT_TRUE(cacheConfig.enabled); } @@ -47,7 +49,7 @@ bool pathExistsMock(const std::string &path) { } } // namespace NewEnvIsDisabledAndLegacyPathDoesNotExist -TEST(CompilerCache, GivenDefaultClCacheConfigWithNotExistingPathAndNewEnvSetToDisabledThenValuesAreProperlyPopulated) { +TEST(ClCacheDefaultConfigLinuxTest, GivenDefaultClCacheConfigWithNotExistingPathAndNewEnvSetToDisabledThenValuesAreProperlyPopulated) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "0"; @@ -55,8 +57,8 @@ TEST(CompilerCache, GivenDefaultClCacheConfigWithNotExistingPathAndNewEnvSetToDi VariableBackup pathExistsBackup(&NEO::SysCalls::sysCallsPathExists, NewEnvIsDisabledAndLegacyPathDoesNotExist::pathExistsMock); auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); - EXPECT_STREQ("cl_cache", cacheConfig.cacheDir.c_str()); - EXPECT_STREQ(".cl_cache", cacheConfig.cacheFileExtension.c_str()); + EXPECT_STREQ(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str()); + EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str()); EXPECT_FALSE(cacheConfig.enabled); } @@ -69,7 +71,7 @@ bool pathExistsMock(const std::string &path) { } } // namespace AllVariablesCorrectlySet -TEST(CompilerCache, GivenAllEnvVarWhenProperlySetThenProperConfigIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenAllEnvVarWhenProperlySetThenProperConfigIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -81,7 +83,7 @@ TEST(CompilerCache, GivenAllEnvVarWhenProperlySetThenProperConfigIsReturned) { auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "ult/directory/"); } @@ -92,7 +94,7 @@ bool pathExistsMock(const std::string &path) { } } // namespace NonExistingPathIsSet -TEST(CompilerCache, GivenNonExistingPathWhenGetCompilerCacheConfigThenConfigWithDisabledCacheIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenNonExistingPathWhenGetCompilerCacheConfigThenConfigWithDisabledCacheIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -119,7 +121,7 @@ bool pathExistsMock(const std::string &path) { } } // namespace XDGEnvPathIsSet -TEST(CompilerCache, GivenXdgCachePathSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenXdgCachePathSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -131,12 +133,12 @@ TEST(CompilerCache, GivenXdgCachePathSetWhenGetCompilerCacheConfigThenConfigWith auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "xdg/directory/neo_compiler_cache"); } -TEST(CompilerCache, GivenXdgCachePathWithoutTrailingSlashSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenXdgCachePathWithoutTrailingSlashSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -148,7 +150,7 @@ TEST(CompilerCache, GivenXdgCachePathWithoutTrailingSlashSetWhenGetCompilerCache auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "xdg/directory/neo_compiler_cache"); } @@ -165,7 +167,7 @@ bool pathExistsMock(const std::string &path) { } } // namespace HomeEnvPathIsSet -TEST(CompilerCache, GivenHomeCachePathSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenHomeCachePathSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -177,12 +179,12 @@ TEST(CompilerCache, GivenHomeCachePathSetWhenGetCompilerCacheConfigThenConfigWit auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "home/directory/.cache/neo_compiler_cache"); } -TEST(CompilerCache, GivenHomeCachePathWithoutTrailingSlashSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenHomeCachePathWithoutTrailingSlashSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -194,12 +196,12 @@ TEST(CompilerCache, GivenHomeCachePathWithoutTrailingSlashSetWhenGetCompilerCach auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "home/directory/.cache/neo_compiler_cache"); } -TEST(CompilerCache, GivenCacheMaxSizeSetTo0WhenGetDefaultConfigThenCacheSizeIsSetToMaxSize) { +TEST(ClCacheDefaultConfigLinuxTest, GivenCacheMaxSizeSetTo0WhenGetDefaultConfigThenCacheSizeIsSetToMaxSize) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "0"; @@ -211,7 +213,7 @@ TEST(CompilerCache, GivenCacheMaxSizeSetTo0WhenGetDefaultConfigThenCacheSizeIsSe auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, std::numeric_limits::max()); EXPECT_EQ(cacheConfig.cacheDir, "ult/directory/"); } @@ -234,7 +236,7 @@ int mkdirMock(const std::string &dir) { } } // namespace HomeEnvPathIsSetButDotCacheDoesNotExist -TEST(CompilerCache, GivenHomeCachePathSetWithoutExistingDotCacheWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenHomeCachePathSetWithoutExistingDotCacheWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -247,12 +249,12 @@ TEST(CompilerCache, GivenHomeCachePathSetWithoutExistingDotCacheWhenGetCompilerC auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "home/directory/.cache/neo_compiler_cache"); } -TEST(CompilerCache, GivenHomeCachePathWithoutExistingDotCacheWithoutTrailingSlashSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenHomeCachePathWithoutExistingDotCacheWithoutTrailingSlashSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -265,7 +267,7 @@ TEST(CompilerCache, GivenHomeCachePathWithoutExistingDotCacheWithoutTrailingSlas auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "home/directory/.cache/neo_compiler_cache"); } @@ -285,7 +287,7 @@ int mkdirMock(const std::string &dir) { } } // namespace XdgPathIsSetAndNeedToCreate -TEST(CompilerCache, GivenXdgEnvWhenNeoCompilerCacheNotExistsThenCreateNeoCompilerCacheFolder) { +TEST(ClCacheDefaultConfigLinuxTest, GivenXdgEnvWhenNeoCompilerCacheNotExistsThenCreateNeoCompilerCacheFolder) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -298,12 +300,12 @@ TEST(CompilerCache, GivenXdgEnvWhenNeoCompilerCacheNotExistsThenCreateNeoCompile auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "xdg/directory/neo_compiler_cache"); } -TEST(CompilerCache, GivenXdgEnvWithoutTrailingSlashWhenNeoCompilerCacheNotExistsThenCreateNeoCompilerCacheFolder) { +TEST(ClCacheDefaultConfigLinuxTest, GivenXdgEnvWithoutTrailingSlashWhenNeoCompilerCacheNotExistsThenCreateNeoCompilerCacheFolder) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -316,7 +318,7 @@ TEST(CompilerCache, GivenXdgEnvWithoutTrailingSlashWhenNeoCompilerCacheNotExists auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "xdg/directory/neo_compiler_cache"); } @@ -343,7 +345,7 @@ int mkdirMock(const std::string &dir) { } } // namespace XdgPathIsSetAndOtherProcessCreatesPath -TEST(CompilerCache, GivenXdgEnvWhenOtherProcessCreatesNeoCompilerCacheFolderThenProperConfigIsReturned) { +TEST(ClCacheDefaultConfigLinuxTest, GivenXdgEnvWhenOtherProcessCreatesNeoCompilerCacheFolderThenProperConfigIsReturned) { std::unordered_map mockableEnvs; mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -358,7 +360,7 @@ TEST(CompilerCache, GivenXdgEnvWhenOtherProcessCreatesNeoCompilerCacheFolderThen auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "xdg/directory/neo_compiler_cache"); EXPECT_TRUE(XdgPathIsSetAndOtherProcessCreatesPath::mkdirCalled); diff --git a/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp b/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp index 08b9ecdc1d..a4a9a19930 100644 --- a/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp +++ b/shared/test/unit_test/compiler_interface/windows/compiler_cache_tests_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2023 Intel Corporation + * Copyright (C) 2019-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -986,10 +986,6 @@ TEST_F(CompilerCacheWindowsTest, givenCacheBinaryWhenRenameTempFileBinaryToPrope EXPECT_EQ(0u, SysCalls::writeFileCalled); } -TEST(CompilerCacheHelperWindowsTest, whenDefaultCacheEnabledIsCalledThenReturnCorrectValue) { - EXPECT_EQ(1l, NEO::defaultCacheEnabled()); -} - TEST(CompilerCacheHelperWindowsTest, givenFindFirstFileASuccessWhenGetFileModificationTimeThenFindCloseIsCalled) { VariableBackup findFirstFileAResultBackup(&SysCalls::findFirstFileAResult, reinterpret_cast(0x1234)); VariableBackup findCloseCalledBackup(&SysCalls::findCloseCalled, 0u); diff --git a/opencl/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp b/shared/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp similarity index 74% rename from opencl/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp rename to shared/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp index 1b9bbe496a..a9db8df6bc 100644 --- a/opencl/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp +++ b/shared/test/unit_test/compiler_interface/windows/default_cl_cache_config_tests.cpp @@ -6,10 +6,12 @@ */ #include "shared/source/compiler_interface/default_cache_config.h" +#include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/constants.h" #include "shared/source/os_interface/sys_calls_common.h" #include "shared/source/os_interface/windows/sys_calls.h" #include "shared/source/utilities/debug_settings_reader.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/variable_backup.h" #include "shared/test/common/mocks/mock_io_functions.h" #include "shared/test/common/test_macros/test.h" @@ -31,8 +33,8 @@ extern const size_t shGetKnownFolderSetPathSize; extern wchar_t shGetKnownFolderSetPath[]; } // namespace SysCalls -struct CompilerCacheTest : public ::testing::Test { - CompilerCacheTest() +struct ClCacheDefaultConfigWindowsTest : public ::testing::Test { + ClCacheDefaultConfigWindowsTest() : mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs), getLastErrorResultBackup(&SysCalls::getLastErrorResult), shGetKnownFolderPathResultBackup(&SysCalls::shGetKnownFolderPathResult), @@ -60,31 +62,31 @@ struct CompilerCacheTest : public ::testing::Test { VariableBackup createDirectoryAResultBackup; }; -TEST_F(CompilerCacheTest, GivenDefaultClCacheConfigWithPathExistsThenValuesAreProperlyPopulated) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenDefaultClCacheConfigWithPathExistsThenValuesAreProperlyPopulated) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "0"; bool pathExistsMock = true; VariableBackup pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock); auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); - EXPECT_STREQ("cl_cache", cacheConfig.cacheDir.c_str()); - EXPECT_STREQ(".cl_cache", cacheConfig.cacheFileExtension.c_str()); + EXPECT_STREQ(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str()); + EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str()); EXPECT_TRUE(cacheConfig.enabled); } -TEST_F(CompilerCacheTest, GivenDefaultClCacheConfigWithNonExistingPathThenValuesAreProperlyPopulated) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenDefaultClCacheConfigWithNonExistingPathThenValuesAreProperlyPopulated) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "0"; bool pathExistsMock = false; VariableBackup pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock); auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); - EXPECT_STREQ("cl_cache", cacheConfig.cacheDir.c_str()); - EXPECT_STREQ(".cl_cache", cacheConfig.cacheFileExtension.c_str()); + EXPECT_STREQ(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str()); + EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str()); EXPECT_FALSE(cacheConfig.enabled); } -TEST_F(CompilerCacheTest, GivenAllEnvVarWhenProperlySetThenCorrectConfigIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenAllEnvVarWhenProperlySetThenCorrectConfigIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; mockableEnvs["NEO_CACHE_DIR"] = "ult\\directory\\"; @@ -95,12 +97,12 @@ TEST_F(CompilerCacheTest, GivenAllEnvVarWhenProperlySetThenCorrectConfigIsReturn auto cacheConfig = NEO::getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, "ult\\directory\\"); } -TEST_F(CompilerCacheTest, GivenNonExistingPathWhenGetCompilerCacheConfigThenConfigWithDisabledCacheIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenNonExistingPathWhenGetCompilerCacheConfigThenConfigWithDisabledCacheIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; mockableEnvs["NEO_CACHE_DIR"] = "ult\\directory\\"; @@ -114,7 +116,7 @@ TEST_F(CompilerCacheTest, GivenNonExistingPathWhenGetCompilerCacheConfigThenConf EXPECT_TRUE(cacheConfig.cacheDir.empty()); } -TEST_F(CompilerCacheTest, GivenLocalAppDataCachePathSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenLocalAppDataCachePathSetWhenGetCompilerCacheConfigThenConfigWithEnabledCacheIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -131,12 +133,12 @@ TEST_F(CompilerCacheTest, GivenLocalAppDataCachePathSetWhenGetCompilerCacheConfi const std::string expectedCacheDirPath = "C:\\Users\\user1\\AppData\\Local\\NEO\\neo_compiler_cache"; EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, expectedCacheDirPath); } -TEST_F(CompilerCacheTest, GivenNeoCacheDirNotSetAndLocalAppDataCachePathNotSetWhenGetCompilerCacheConfigThenConfigWithDisabledCacheIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenNeoCacheDirNotSetAndLocalAppDataCachePathNotSetWhenGetCompilerCacheConfigThenConfigWithDisabledCacheIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -148,7 +150,7 @@ TEST_F(CompilerCacheTest, GivenNeoCacheDirNotSetAndLocalAppDataCachePathNotSetWh EXPECT_TRUE(cacheConfig.cacheDir.empty()); } -TEST_F(CompilerCacheTest, GivenLocalAppDataSetAndNonExistingNeoDirectoryWhenGetCompilerCacheConfigThenNeoDirectoryIsCreatedAndConfigWithEnabledCacheIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenLocalAppDataSetAndNonExistingNeoDirectoryWhenGetCompilerCacheConfigThenNeoDirectoryIsCreatedAndConfigWithEnabledCacheIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -163,13 +165,13 @@ TEST_F(CompilerCacheTest, GivenLocalAppDataSetAndNonExistingNeoDirectoryWhenGetC const std::string expectedCacheDirPath = "C:\\Users\\user1\\AppData\\Local\\NEO\\neo_compiler_cache"; EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, expectedCacheDirPath); EXPECT_EQ(1u, SysCalls::createDirectoryACalled); } -TEST_F(CompilerCacheTest, GivenLocalAppDataSetAndNonExistingNeoDirectoryWhenGetCompilerCacheConfigAndNeoDirCreationFailsThenConfigWithDisabledCacheIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenLocalAppDataSetAndNonExistingNeoDirectoryWhenGetCompilerCacheConfigAndNeoDirCreationFailsThenConfigWithDisabledCacheIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -187,7 +189,7 @@ TEST_F(CompilerCacheTest, GivenLocalAppDataSetAndNonExistingNeoDirectoryWhenGetC EXPECT_EQ(1u, SysCalls::createDirectoryACalled); } -TEST_F(CompilerCacheTest, GivenLocalAppDataSetAndNonExistingNeoCompilerCacheDirectoryWhenGetCompilerCacheConfigThenNeoCompilerCacheDirectoryIsCreatedAndConfigWithEnabledCacheIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenLocalAppDataSetAndNonExistingNeoCompilerCacheDirectoryWhenGetCompilerCacheConfigThenNeoCompilerCacheDirectoryIsCreatedAndConfigWithEnabledCacheIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -203,13 +205,13 @@ TEST_F(CompilerCacheTest, GivenLocalAppDataSetAndNonExistingNeoCompilerCacheDire const std::string expectedCacheDirPath = "C:\\Users\\user1\\AppData\\Local\\NEO\\neo_compiler_cache"; EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, expectedCacheDirPath); EXPECT_EQ(1u, SysCalls::createDirectoryACalled); } -TEST_F(CompilerCacheTest, GivenLocalAppDataSetAndNonExistingNeoCompilerCacheDirectoryWhenGetCompilerCacheConfigAndDirectoryCreationFailsThenConfigWithDisabledCacheIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenLocalAppDataSetAndNonExistingNeoCompilerCacheDirectoryWhenGetCompilerCacheConfigAndDirectoryCreationFailsThenConfigWithDisabledCacheIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -229,7 +231,7 @@ TEST_F(CompilerCacheTest, GivenLocalAppDataSetAndNonExistingNeoCompilerCacheDire EXPECT_EQ(1u, SysCalls::createDirectoryACalled); } -TEST_F(CompilerCacheTest, GivenLocalAppDataSetWhenGetCompilerCacheConfigAndNeoCompilerCacheDirectoryAlreadyExistsThenConfigWithEnabledCacheIsReturned) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenLocalAppDataSetWhenGetCompilerCacheConfigAndNeoCompilerCacheDirectoryAlreadyExistsThenConfigWithEnabledCacheIsReturned) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22"; @@ -247,13 +249,13 @@ TEST_F(CompilerCacheTest, GivenLocalAppDataSetWhenGetCompilerCacheConfigAndNeoCo const std::string expectedCacheDirPath = "C:\\Users\\user1\\AppData\\Local\\NEO\\neo_compiler_cache"; EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, 22u); EXPECT_EQ(cacheConfig.cacheDir, expectedCacheDirPath); EXPECT_EQ(1u, SysCalls::createDirectoryACalled); } -TEST_F(CompilerCacheTest, GivenCacheMaxSizeSetTo0WhenGetDefaultConfigThenCacheSizeIsSetToMaxSize) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenCacheMaxSizeSetTo0WhenGetDefaultConfigThenCacheSizeIsSetToMaxSize) { mockableEnvs["NEO_CACHE_PERSISTENT"] = "1"; mockableEnvs["NEO_CACHE_MAX_SIZE"] = "0"; mockableEnvs["NEO_CACHE_DIR"] = "ult\\directory\\"; @@ -263,12 +265,12 @@ TEST_F(CompilerCacheTest, GivenCacheMaxSizeSetTo0WhenGetDefaultConfigThenCacheSi auto cacheConfig = getDefaultCompilerCacheConfig(); EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, std::numeric_limits::max()); EXPECT_EQ(cacheConfig.cacheDir, "ult\\directory\\"); } -TEST_F(CompilerCacheTest, GivenCachePathExistsAndNoEnvVarsSetWhenGetDefaultCompilerCacheConfigThenCacheIsEnabled) { +TEST_F(ClCacheDefaultConfigWindowsTest, GivenCachePathExistsAndNoEnvVarsSetWhenGetDefaultCompilerCacheConfigThenCacheIsEnabled) { bool pathExistsMock = true; VariableBackup pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock); @@ -282,7 +284,7 @@ TEST_F(CompilerCacheTest, GivenCachePathExistsAndNoEnvVarsSetWhenGetDefaultCompi const std::string expectedCacheDirPath = "C:\\Users\\user1\\AppData\\Local\\NEO\\neo_compiler_cache"; EXPECT_TRUE(cacheConfig.enabled); - EXPECT_EQ(cacheConfig.cacheFileExtension, ".cl_cache"); + EXPECT_EQ(cacheConfig.cacheFileExtension, ApiSpecificConfig::compilerCacheFileExtension().c_str()); EXPECT_EQ(cacheConfig.cacheSize, static_cast(MemoryConstants::gigaByte)); EXPECT_EQ(cacheConfig.cacheDir, expectedCacheDirPath); } diff --git a/shared/test/unit_test/ult_specific_config.cpp b/shared/test/unit_test/ult_specific_config.cpp index 72ef0f6d1c..d1588d33f4 100644 --- a/shared/test/unit_test/ult_specific_config.cpp +++ b/shared/test/unit_test/ult_specific_config.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2023 Intel Corporation + * Copyright (C) 2021-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -35,7 +35,6 @@ void PageFaultManager::transferToGpu(void *ptr, void *cmdQ) { } void PageFaultManager::allowCPUMemoryEviction(void *ptr, PageFaultData &pageFaultData) { } -CompilerCacheConfig getDefaultCompilerCacheConfig() { return {}; } const char *getAdditionalBuiltinAsString(EBuiltInOps::Type builtin) { return nullptr; } void RootDeviceEnvironment::initApiGfxCoreHelper() {