mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 09:59:39 +08:00
Add process safety to cl_cache on Linux
Current flow will be to have one synchronization point config.file. Read remains unblocking, only write(caching) operation will be blocking (lock on config.file) Related-To: NEO-4262 Signed-off-by: Diedrich, Kamil <kamil.diedrich@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c9fdeb200c
commit
26ca64bb28
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
namespace NEO {
|
||||
std::mutex CompilerCache::cacheAccessMtx;
|
||||
|
||||
const std::string CompilerCache::getCachedFileName(const HardwareInfo &hwInfo, const ArrayRef<const char> input,
|
||||
const ArrayRef<const char> options, const ArrayRef<const char> internalOptions) {
|
||||
Hash hash;
|
||||
@@ -109,20 +110,4 @@ const std::string CompilerCache::getCachedFileName(const HardwareInfo &hwInfo, c
|
||||
CompilerCache::CompilerCache(const CompilerCacheConfig &cacheConfig)
|
||||
: config(cacheConfig){};
|
||||
|
||||
bool CompilerCache::cacheBinary(const std::string kernelFileHash, const char *pBinary, uint32_t binarySize) {
|
||||
if (pBinary == nullptr || binarySize == 0) {
|
||||
return false;
|
||||
}
|
||||
std::string filePath = config.cacheDir + PATH_SEPARATOR + kernelFileHash + config.cacheFileExtension;
|
||||
std::lock_guard<std::mutex> lock(cacheAccessMtx);
|
||||
return 0 != writeDataToFile(filePath.c_str(), pBinary, binarySize);
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> CompilerCache::loadCachedBinary(const std::string kernelFileHash, size_t &cachedBinarySize) {
|
||||
std::string filePath = config.cacheDir + PATH_SEPARATOR + kernelFileHash + config.cacheFileExtension;
|
||||
|
||||
std::lock_guard<std::mutex> lock(cacheAccessMtx);
|
||||
return loadDataFromFile(filePath.c_str(), cachedBinarySize);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user