2020-02-05 08:30:17 +01:00
|
|
|
/*
|
2023-03-08 23:15:36 +01:00
|
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
2020-02-05 08:30:17 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/compiler_interface/default_cache_config.h"
|
2020-02-05 08:30:17 +01:00
|
|
|
|
2023-05-09 00:39:55 +02:00
|
|
|
#include "shared/source/compiler_interface/os_compiler_cache_helper.h"
|
2023-03-08 23:15:36 +01:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2023-04-27 08:42:36 +00:00
|
|
|
#include "shared/source/os_interface/sys_calls_common.h"
|
2022-09-28 14:33:16 +00:00
|
|
|
#include "shared/source/utilities/debug_settings_reader.h"
|
|
|
|
|
|
|
|
|
|
#include "opencl/source/os_interface/ocl_reg_path.h"
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "os_inc.h"
|
|
|
|
|
|
|
|
|
|
#include <string>
|
2020-02-05 08:30:17 +01:00
|
|
|
|
|
|
|
|
namespace NEO {
|
2023-05-09 00:39:55 +02:00
|
|
|
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";
|
|
|
|
|
|
2020-02-05 08:30:17 +01:00
|
|
|
CompilerCacheConfig getDefaultCompilerCacheConfig() {
|
2022-09-28 14:33:16 +00:00
|
|
|
CompilerCacheConfig ret;
|
|
|
|
|
|
2023-05-09 00:39:55 +02:00
|
|
|
std::unique_ptr<SettingsReader> settingsReader(SettingsReader::createOsReader(false, oclRegPath));
|
|
|
|
|
|
|
|
|
|
auto cachePersistentKey = oclRegPath + NeoCachePersistent;
|
|
|
|
|
|
2023-08-31 11:14:30 +00:00
|
|
|
if (settingsReader->getSetting(settingsReader->appSpecificLocation(cachePersistentKey), defaultCacheEnabled()) != 0) {
|
2023-05-09 00:39:55 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 10:22:58 +00:00
|
|
|
ret.cacheFileExtension = ".cl_cache";
|
2023-05-09 00:39:55 +02:00
|
|
|
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));
|
2022-09-28 14:33:16 +00:00
|
|
|
|
2023-04-27 08:42:36 +00:00
|
|
|
if (NEO::SysCalls::pathExists(ret.cacheDir)) {
|
|
|
|
|
ret.enabled = true;
|
|
|
|
|
ret.cacheSize = MemoryConstants::gigaByte;
|
|
|
|
|
ret.cacheFileExtension = ".cl_cache";
|
|
|
|
|
} else {
|
|
|
|
|
ret.enabled = false;
|
|
|
|
|
ret.cacheSize = 0u;
|
|
|
|
|
ret.cacheFileExtension = ".cl_cache";
|
|
|
|
|
}
|
2022-09-28 14:33:16 +00:00
|
|
|
|
|
|
|
|
return ret;
|
2020-02-05 08:30:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace NEO
|