mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +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
154530ad23
commit
269cba1659
@@ -57,7 +57,7 @@ which improves performance.
|
||||
##### Environment flags (Linux only)
|
||||
|
||||
NEO_CACHE_PERSISTENT - integer value to enable (1)/disable (0) on-disk binary cache. When enabled
|
||||
Neo will try to cache and reuse compiled binaries. Default is off.
|
||||
Neo will try to cache and reuse compiled binaries. Default is on.
|
||||
|
||||
NEO_CACHE_DIR - path to persistent cache directory. Default values are $XDG_CACHE_HOME/neo_compiler_cache
|
||||
if $XDG_CACHE_HOME is set, $HOME/.cache/neo_compiler_cache otherwise. If none of environment
|
||||
|
||||
@@ -32,7 +32,7 @@ CompilerCacheConfig getDefaultCompilerCacheConfig() {
|
||||
|
||||
auto cachePersistentKey = oclRegPath + NeoCachePersistent;
|
||||
|
||||
if (settingsReader->getSetting(settingsReader->appSpecificLocation(cachePersistentKey), 0l) != 0) {
|
||||
if (settingsReader->getSetting(settingsReader->appSpecificLocation(cachePersistentKey), defaultCacheEnabled()) != 0) {
|
||||
ret.enabled = true;
|
||||
std::string emptyString = "";
|
||||
ret.cacheDir = settingsReader->getSetting(settingsReader->appSpecificLocation(NeoCacheDir), emptyString);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
#include <link.h>
|
||||
|
||||
namespace NEO {
|
||||
int64_t defaultCacheEnabled() {
|
||||
return 1l;
|
||||
}
|
||||
|
||||
std::string makePath(const std::string &lhs, const std::string &rhs) {
|
||||
if (lhs.size() == 0) {
|
||||
return rhs;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
namespace NEO {
|
||||
class SettingsReader;
|
||||
int64_t defaultCacheEnabled();
|
||||
std::string makePath(const std::string &lhs, const std::string &rhs);
|
||||
bool checkDefaultCacheDirSettings(std::string &cacheDir, SettingsReader *reader);
|
||||
time_t getFileModificationTime(const std::string &path);
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
#include "shared/source/compiler_interface/os_compiler_cache_helper.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
int64_t defaultCacheEnabled() {
|
||||
return 0l;
|
||||
}
|
||||
std::string makePath(const std::string &lhs, const std::string &rhs) {
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user