feature: Add new environment variables for compiler cache

This patch add new environment variables to control compiler cache.
Works as follow: If persistent cache is set driver check if NEO_CACHE_DIR
is set. If not then driver checks XDG_CACHE_HOME - If exists
then driver create neo_compiler_cache folder, if
not then driver checks HOME directory. If each NEO_CACHE_DIR,
XDG_CACHE_HOME and HOME are not set then compiler cache is disabled.
Current support is for Linux only.

Signed-off-by: Diedrich, Kamil <kamil.diedrich@intel.com>

Related-To: NEO-4262
This commit is contained in:
Diedrich, Kamil
2023-05-09 00:39:55 +02:00
committed by Compute-Runtime-Automation
parent 268dcb0777
commit 5a4a2ab8ab
16 changed files with 1257 additions and 585 deletions

View File

@@ -7,6 +7,7 @@
#include "shared/source/compiler_interface/default_cache_config.h"
#include "shared/source/compiler_interface/os_compiler_cache_helper.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/os_interface/sys_calls_common.h"
#include "shared/source/utilities/debug_settings_reader.h"
@@ -19,13 +20,46 @@
#include <string>
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";
CompilerCacheConfig getDefaultCompilerCacheConfig() {
CompilerCacheConfig ret;
std::string keyName = oclRegPath;
keyName += "cl_cache_dir";
std::unique_ptr<SettingsReader> settingsReader(SettingsReader::createOsReader(false, keyName));
ret.cacheDir = settingsReader->getSetting(settingsReader->appSpecificLocation(keyName), static_cast<std::string>(CL_CACHE_LOCATION));
std::unique_ptr<SettingsReader> settingsReader(SettingsReader::createOsReader(false, oclRegPath));
auto cachePersistentKey = oclRegPath + NeoCachePersistent;
if (settingsReader->getSetting(settingsReader->appSpecificLocation(cachePersistentKey), 0l) != 0) {
ret.enabled = true;
std::string emptyString = "";
ret.cacheDir = settingsReader->getSetting(settingsReader->appSpecificLocation(NeoCacheDir), emptyString);
if (ret.cacheDir.empty()) {
if (!checkDefaultCacheDirSettings(ret.cacheDir, settingsReader.get())) {
ret.enabled = false;
return ret;
}
} else {
if (!NEO::SysCalls::pathExists(ret.cacheDir)) {
ret.cacheDir = "";
ret.enabled = false;
return ret;
}
}
ret.cacheSize = static_cast<size_t>(settingsReader->getSetting(settingsReader->appSpecificLocation(NeoCacheMaxSize), static_cast<int64_t>(MemoryConstants::gigaByte)));
if (ret.cacheSize == 0u) {
ret.cacheSize = std::numeric_limits<size_t>::max();
}
return ret;
}
ret.cacheDir = settingsReader->getSetting(settingsReader->appSpecificLocation(ClCacheDir), static_cast<std::string>(CL_CACHE_LOCATION));
if (NEO::SysCalls::pathExists(ret.cacheDir)) {
ret.enabled = true;