mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Revert "fix: remove compiler cache legacy implementation"
This reverts commit 864f42116c.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0ad5316f53
commit
9568ee47e7
@@ -606,6 +606,7 @@ endif()
|
||||
|
||||
# Miscs options
|
||||
option(IGDRCL_GCOV "generate gcov report" OFF)
|
||||
set(CL_CACHE_LOCATION "cl_cache" CACHE STRING "OpenCL program binary cache location")
|
||||
|
||||
option(NEO_SHOW_VERBOSE_ULT_RESULTS "Use the default/verbose test output" OFF)
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ if(NOT NEO_SKIP_OCL_UNIT_TESTS OR NOT NEO_SKIP_L0_UNIT_TESTS)
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TargetDir}/${product}_aub/${revision_id}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TargetDir}/${product}_aub/${revision_id}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TargetDir}/${product}_aub/${revision_id}/aub_out
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TargetDir}/${product}_aub/${revision_id}/cl_cache
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
@@ -60,6 +60,8 @@ if(NOT NEO_SKIP_OCL_UNIT_TESTS)
|
||||
POST_BUILD
|
||||
COMMAND WORKING_DIRECTORY ${TargetDir}
|
||||
COMMAND echo Running igdrcl_tests ${target} ${slices}x${subslices}x${eu_per_ss} in ${TargetDir}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${outputdir}/cl_cache
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}/cl_cache
|
||||
COMMAND echo Cmd line: ${GTEST_ENV} ${NEO_RUN_INTERCEPTOR_LIST} $<TARGET_FILE:igdrcl_tests> --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} --gtest_repeat=${GTEST_REPEAT} ${GTEST_SHUFFLE} ${GTEST_OUTPUT} ${NEO_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION} --rev_id ${revision_id}
|
||||
COMMAND ${GTEST_ENV} ${NEO_RUN_INTERCEPTOR_LIST} $<TARGET_FILE:igdrcl_tests> --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} --gtest_repeat=${GTEST_REPEAT} ${GTEST_SHUFFLE} ${GTEST_OUTPUT} ${NEO_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION} --rev_id ${revision_id}
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#cmakedefine CL_CACHE_LOCATION "${CL_CACHE_LOCATION}"
|
||||
#cmakedefine NEO_ARCH "${NEO_ARCH}"
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
||||
@@ -78,6 +78,14 @@ bool ApiSpecificConfig::isSharedAllocPrefetchEnabled() {
|
||||
(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";
|
||||
}
|
||||
|
||||
@@ -79,6 +79,14 @@ 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()));
|
||||
}
|
||||
|
||||
@@ -69,6 +69,14 @@ const StackVec<DebugVarPrefix, 4> &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";
|
||||
}
|
||||
|
||||
@@ -71,6 +71,14 @@ 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()));
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ TEST(CompilerCache, GivenDefaultCacheConfigThenValuesAreProperlyPopulated) {
|
||||
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
|
||||
EXPECT_STREQ("ocloc_cache", cacheConfig.cacheDir.c_str());
|
||||
EXPECT_STREQ(".ocloc_cache", cacheConfig.cacheFileExtension.c_str());
|
||||
EXPECT_FALSE(cacheConfig.enabled);
|
||||
EXPECT_TRUE(cacheConfig.enabled);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace NEO {
|
||||
struct HardwareInfo;
|
||||
|
||||
struct CompilerCacheConfig {
|
||||
bool enabled = false;
|
||||
bool enabled = true;
|
||||
std::string cacheFileExtension;
|
||||
std::string cacheDir;
|
||||
size_t cacheSize = 0;
|
||||
|
||||
@@ -56,6 +56,18 @@ CompilerCacheConfig getDefaultCompilerCacheConfig() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret.cacheDir = envReader.getSetting(ApiSpecificConfig::compilerCacheDir().c_str(), ApiSpecificConfig::compilerCacheLocation());
|
||||
|
||||
if (NEO::SysCalls::pathExists(ret.cacheDir)) {
|
||||
ret.enabled = true;
|
||||
ret.cacheSize = static_cast<size_t>(neoCacheMaxSizeDefault);
|
||||
ret.cacheFileExtension = ApiSpecificConfig::compilerCacheFileExtension();
|
||||
} else {
|
||||
ret.enabled = false;
|
||||
ret.cacheSize = 0u;
|
||||
ret.cacheFileExtension = ApiSpecificConfig::compilerCacheFileExtension();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ std::string RegistryReader::getSetting(const char *settingName, const std::strin
|
||||
for (const auto &prefix : prefixString) {
|
||||
std::string neoKey = prefix;
|
||||
neoKey += settingName;
|
||||
envValue = IoFunctions::getenvPtr(neoKey.c_str());
|
||||
envValue = strcmp(processName.c_str(), neoKey.c_str()) ? IoFunctions::getenvPtr(neoKey.c_str()) : IoFunctions::getenvPtr("cl_cache_dir");
|
||||
if (envValue) {
|
||||
keyValue.assign(envValue);
|
||||
type = prefixType[i];
|
||||
@@ -214,7 +214,7 @@ std::string RegistryReader::getSetting(const char *settingName, const std::strin
|
||||
std::string keyValue = value;
|
||||
|
||||
if (!(getSettingStringCommon(settingName, keyValue))) {
|
||||
const char *envValue = IoFunctions::getenvPtr(settingName);
|
||||
const char *envValue = strcmp(processName.c_str(), settingName) ? IoFunctions::getenvPtr(settingName) : IoFunctions::getenvPtr("cl_cache_dir");
|
||||
if (envValue) {
|
||||
keyValue.assign(envValue);
|
||||
}
|
||||
|
||||
@@ -417,7 +417,6 @@ TEST(CompilerInterfaceCachedTests, givenKernelWithoutIncludesAndBinaryInCacheWhe
|
||||
|
||||
std::unique_ptr<CompilerCacheMock> cache(new CompilerCacheMock());
|
||||
cache->loadResult = true;
|
||||
cache->config.enabled = true;
|
||||
auto compilerInterface = std::unique_ptr<CompilerInterface>(CompilerInterface::createInstance(std::move(cache), true));
|
||||
TranslationOutput translationOutput;
|
||||
inputArgs.allowCaching = true;
|
||||
|
||||
@@ -21,6 +21,47 @@ namespace SysCalls {
|
||||
extern bool pathExistsMock;
|
||||
}
|
||||
|
||||
namespace LegacyPathWorksIfNewEnvIsSetToDisabled {
|
||||
bool pathExistsMock(const std::string &path) {
|
||||
if (path.find(ApiSpecificConfig::compilerCacheLocation().c_str()) != path.npos)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace LegacyPathWorksIfNewEnvIsSetToDisabled
|
||||
|
||||
TEST(ClCacheDefaultConfigLinuxTest, 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(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str());
|
||||
EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str());
|
||||
EXPECT_TRUE(cacheConfig.enabled);
|
||||
}
|
||||
|
||||
namespace NewEnvIsDisabledAndLegacyPathDoesNotExist {
|
||||
bool pathExistsMock(const std::string &path) {
|
||||
return false;
|
||||
}
|
||||
} // namespace NewEnvIsDisabledAndLegacyPathDoesNotExist
|
||||
|
||||
TEST(ClCacheDefaultConfigLinuxTest, 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(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str());
|
||||
EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str());
|
||||
EXPECT_FALSE(cacheConfig.enabled);
|
||||
}
|
||||
|
||||
namespace AllVariablesCorrectlySet {
|
||||
bool pathExistsMock(const std::string &path) {
|
||||
if (path.find("ult/directory/") != path.npos)
|
||||
@@ -324,13 +365,4 @@ TEST(ClCacheDefaultConfigLinuxTest, GivenXdgEnvWhenOtherProcessCreatesNeoCompile
|
||||
EXPECT_EQ(cacheConfig.cacheDir, "xdg/directory/neo_compiler_cache");
|
||||
EXPECT_TRUE(XdgPathIsSetAndOtherProcessCreatesPath::mkdirCalled);
|
||||
}
|
||||
|
||||
TEST(ClCacheDefaultConfigLinuxTest, GivenNeoCachePersistentSetToZeroWhenGetDefaultCompilerCacheConfigThenCacheIsDisabled) {
|
||||
std::unordered_map<std::string, std::string> mockableEnvs;
|
||||
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
|
||||
|
||||
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
|
||||
|
||||
EXPECT_FALSE(cacheConfig.enabled);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -62,6 +62,30 @@ struct ClCacheDefaultConfigWindowsTest : public ::testing::Test {
|
||||
VariableBackup<BOOL> createDirectoryAResultBackup;
|
||||
};
|
||||
|
||||
TEST_F(ClCacheDefaultConfigWindowsTest, GivenDefaultClCacheConfigWithPathExistsThenValuesAreProperlyPopulated) {
|
||||
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
|
||||
|
||||
bool pathExistsMock = true;
|
||||
VariableBackup<bool> pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock);
|
||||
|
||||
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
|
||||
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(ClCacheDefaultConfigWindowsTest, GivenDefaultClCacheConfigWithNonExistingPathThenValuesAreProperlyPopulated) {
|
||||
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
|
||||
|
||||
bool pathExistsMock = false;
|
||||
VariableBackup<bool> pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock);
|
||||
|
||||
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
|
||||
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(ClCacheDefaultConfigWindowsTest, GivenAllEnvVarWhenProperlySetThenCorrectConfigIsReturned) {
|
||||
mockableEnvs["NEO_CACHE_PERSISTENT"] = "1";
|
||||
mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22";
|
||||
@@ -265,12 +289,4 @@ TEST_F(ClCacheDefaultConfigWindowsTest, GivenCachePathExistsAndNoEnvVarsSetWhenG
|
||||
EXPECT_EQ(cacheConfig.cacheDir, expectedCacheDirPath);
|
||||
}
|
||||
|
||||
TEST_F(ClCacheDefaultConfigWindowsTest, GivenNeoCachePersistentSetToZeroWhenGetDefaultCompilerCacheConfigThenCacheIsDisabled) {
|
||||
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
|
||||
|
||||
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
|
||||
|
||||
EXPECT_FALSE(cacheConfig.enabled);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -462,6 +462,7 @@ TEST_F(DebugEnvReaderTests, GivenBoolEnvVariableWhenGettingThenCorrectValueIsRet
|
||||
bool ret;
|
||||
bool defaultValue = true;
|
||||
bool expectedValue = false;
|
||||
|
||||
{
|
||||
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{"TestingVariable", "0"}};
|
||||
@@ -482,6 +483,12 @@ TEST_F(DebugEnvReaderTests, GivenBoolEnvVariableWhenGettingThenCorrectValueIsRet
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DebugEnvReaderTests, WhenSettingAppSpecificLocationThenLocationIsReturned) {
|
||||
std::string appSpecific;
|
||||
appSpecific = "cl_cache_dir";
|
||||
EXPECT_EQ(appSpecific, environmentVariableReader->appSpecificLocation(appSpecific));
|
||||
}
|
||||
|
||||
TEST_F(DebugEnvReaderTests, givenEnvironmentVariableReaderWhenCreateOsReaderWithStringThenNotNullPointer) {
|
||||
std::unique_ptr<SettingsReader> settingsReader(SettingsReader::createOsReader(false, ""));
|
||||
EXPECT_NE(nullptr, settingsReader);
|
||||
|
||||
@@ -507,4 +507,24 @@ TEST_F(RegistryReaderTest, givenRegistryKeyPresentWhenValueIsNonZeroInBothDwords
|
||||
EXPECT_TRUE(value);
|
||||
EXPECT_EQ(DebugVarPrefix::none, type);
|
||||
}
|
||||
|
||||
TEST_F(DebugReaderWithRegistryAndEnvTest, givenSetProcessNameWhenReadFromEnvironmentVariableThenReturnClCacheDir) {
|
||||
SysCalls::regOpenKeySuccessCount = 0u;
|
||||
SysCalls::regQueryValueSuccessCount = 0u;
|
||||
registryReader.processName = "processName";
|
||||
std::string defaultCacheDir = "";
|
||||
std::string cacheDir = registryReader.getSetting("processName", defaultCacheDir);
|
||||
EXPECT_STREQ("./tested_cl_cache_dir", cacheDir.c_str());
|
||||
}
|
||||
|
||||
TEST_F(DebugReaderWithRegistryAndEnvTest, givenSetProcessNameWhenReadFromEnvironmentVariableThenReturnClCacheDirPrefix) {
|
||||
SysCalls::regOpenKeySuccessCount = 0u;
|
||||
SysCalls::regQueryValueSuccessCount = 0u;
|
||||
registryReader.processName = "processName";
|
||||
std::string defaultCacheDir = "";
|
||||
DebugVarPrefix type = DebugVarPrefix::none;
|
||||
std::string cacheDir2 = registryReader.getSetting("processName", defaultCacheDir, type);
|
||||
EXPECT_STREQ("./tested_cl_cache_dir", cacheDir2.c_str());
|
||||
EXPECT_EQ(DebugVarPrefix::none, type);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -38,6 +38,7 @@ class TestedRegistryReader : public RegistryReader {
|
||||
IoFunctions::mockableEnvValues->insert({"settingSourceString", "environment"});
|
||||
IoFunctions::mockableEnvValues->insert({"settingSourceInt", "2"});
|
||||
IoFunctions::mockableEnvValues->insert({"processName", "processName"});
|
||||
IoFunctions::mockableEnvValues->insert({"cl_cache_dir", "./tested_cl_cache_dir"});
|
||||
}
|
||||
const char *getRegKey() const {
|
||||
return registryReadRootKey.c_str();
|
||||
|
||||
Reference in New Issue
Block a user