mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-10 15:12:56 +08:00
feature: enable cl_cache by default on Linux
Resolves: NEO-4262 Signed-off-by: Kacper Kasper <kacper.k.kasper@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4db564d029
commit
eeb8a5e1fb
@@ -7,11 +7,12 @@
|
||||
set(IGDRCL_SRCS_tests_compiler_interface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cl_compiler_interface_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_cl_cache_config_tests.cpp
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
@@ -19,6 +19,47 @@ namespace SysCalls {
|
||||
extern bool pathExistsMock;
|
||||
}
|
||||
|
||||
namespace LegacyPathWorksIfNewEnvIsSetToDisabled {
|
||||
bool pathExistsMock(const std::string &path) {
|
||||
if (path.find("cl_cache") != path.npos)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace LegacyPathWorksIfNewEnvIsSetToDisabled
|
||||
|
||||
TEST(CompilerCache, GivenDefaultClCacheConfigWithPathExistsAndNewEnvSetToDisabledThenValuesAreProperlyPopulated) {
|
||||
std::unordered_map<std::string, std::string> mockableEnvs;
|
||||
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
|
||||
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&NEO::IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsPathExists)> 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_TRUE(cacheConfig.enabled);
|
||||
}
|
||||
|
||||
namespace NewEnvIsDisabledAndLegacyPathDoesNotExist {
|
||||
bool pathExistsMock(const std::string &path) {
|
||||
return false;
|
||||
}
|
||||
} // namespace NewEnvIsDisabledAndLegacyPathDoesNotExist
|
||||
|
||||
TEST(CompilerCache, GivenDefaultClCacheConfigWithNotExistingPathAndNewEnvSetToDisabledThenValuesAreProperlyPopulated) {
|
||||
std::unordered_map<std::string, std::string> mockableEnvs;
|
||||
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
|
||||
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&NEO::IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
VariableBackup<decltype(NEO::SysCalls::sysCallsPathExists)> 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_FALSE(cacheConfig.enabled);
|
||||
}
|
||||
|
||||
namespace AllVariablesCorrectlySet {
|
||||
bool pathExistsMock(const std::string &path) {
|
||||
if (path.find("ult/directory/") != path.npos)
|
||||
|
||||
Reference in New Issue
Block a user