mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
fix: extend cache hash with compiler commit sha, lib size and mtime
Related-To: NEO-4262 Signed-off-by: Kacper Kasper <kacper.k.kasper@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d49190f4ae
commit
991febcdf4
@@ -136,6 +136,7 @@ endif()
|
||||
if(WIN32)
|
||||
list(APPEND CLOC_LIB_SRCS_LIB
|
||||
${NEO_SHARED_DIRECTORY}/compiler_interface/windows/compiler_cache_windows.cpp
|
||||
${NEO_SHARED_DIRECTORY}/compiler_interface/windows/os_compiler_cache_helper.cpp
|
||||
${NEO_SHARED_DIRECTORY}/dll/windows/options_windows.cpp
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/windows/os_inc.h
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/windows/os_library_win.cpp
|
||||
@@ -145,6 +146,7 @@ if(WIN32)
|
||||
else()
|
||||
list(APPEND CLOC_LIB_SRCS_LIB
|
||||
${NEO_SHARED_DIRECTORY}/compiler_interface/linux/compiler_cache_linux.cpp
|
||||
${NEO_SHARED_DIRECTORY}/compiler_interface/linux/os_compiler_cache_helper.cpp
|
||||
${NEO_SHARED_DIRECTORY}/dll/linux/options_linux.cpp
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/linux/os_inc.h
|
||||
${NEO_SHARED_DIRECTORY}/os_interface/linux/os_library_linux.cpp
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#include "shared/offline_compiler/source/ocloc_arg_helper.h"
|
||||
#include "shared/offline_compiler/source/ocloc_error_code.h"
|
||||
#include "shared/source/compiler_interface/igc_platform_helper.h"
|
||||
#include "shared/source/compiler_interface/os_compiler_cache_helper.h"
|
||||
#include "shared/source/helpers/compiler_product_helper.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
@@ -37,6 +39,10 @@ int OclocIgcFacade::initialize(const HardwareInfo &hwInfo) {
|
||||
return OclocErrorCode::OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
std::string igcPath = igcLib->getFullPath();
|
||||
igcLibSize = NEO::getFileSize(igcPath);
|
||||
igcLibMTime = NEO::getFileModificationTime(igcPath);
|
||||
|
||||
const auto igcCreateMainFunction = loadCreateIgcMainFunction();
|
||||
if (!igcCreateMainFunction) {
|
||||
argHelper->printf("Error! Cannot load required functions from IGC library.\n");
|
||||
@@ -63,6 +69,16 @@ int OclocIgcFacade::initialize(const HardwareInfo &hwInfo) {
|
||||
return OclocErrorCode::OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
{
|
||||
auto igcDeviceCtx3 = igcMain->CreateInterface<IGC::IgcOclDeviceCtx<3>>();
|
||||
if (igcDeviceCtx3) {
|
||||
const char *revision = igcDeviceCtx3->GetIGCRevision();
|
||||
// revision is sha-1 hash
|
||||
igcRevision.resize(41);
|
||||
strncpy_s(igcRevision.data(), 41, revision, 40);
|
||||
}
|
||||
}
|
||||
|
||||
igcDeviceCtx = createIgcDeviceContext();
|
||||
if (!igcDeviceCtx) {
|
||||
argHelper->printf("Error! Cannot create IGC device context!\n");
|
||||
@@ -140,6 +156,18 @@ void OclocIgcFacade::populateWithFeatures(IGC::IgcFeaturesAndWorkaroundsTagOCL *
|
||||
handle->SetFtrPooledEuEnabled(hwInfo.featureTable.flags.ftrPooledEuEnabled);
|
||||
}
|
||||
|
||||
const char *OclocIgcFacade::getIgcRevision() {
|
||||
return igcRevision.data();
|
||||
}
|
||||
|
||||
size_t OclocIgcFacade::getIgcLibSize() {
|
||||
return igcLibSize;
|
||||
}
|
||||
|
||||
time_t OclocIgcFacade::getIgcLibMTime() {
|
||||
return igcLibMTime;
|
||||
}
|
||||
|
||||
CIF::RAII::UPtr_t<CIF::Builtins::BufferLatest> OclocIgcFacade::createConstBuffer(const void *data, size_t size) {
|
||||
return CIF::Builtins::CreateConstBuffer(igcMain.get(), data, size);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ class OclocIgcFacade {
|
||||
|
||||
int initialize(const HardwareInfo &hwInfo);
|
||||
bool isInitialized() const;
|
||||
const char *getIgcRevision();
|
||||
size_t getIgcLibSize();
|
||||
time_t getIgcLibMTime();
|
||||
CIF::RAII::UPtr_t<CIF::Builtins::BufferLatest> createConstBuffer(const void *data, size_t size);
|
||||
CIF::RAII::UPtr_t<IGC::IgcOclTranslationCtxTagOCL> createTranslationContext(IGC::CodeType::CodeType_t inType, IGC::CodeType::CodeType_t outType);
|
||||
|
||||
@@ -54,6 +57,9 @@ class OclocIgcFacade {
|
||||
|
||||
OclocArgHelper *argHelper{};
|
||||
std::unique_ptr<OsLibrary> igcLib;
|
||||
std::vector<char> igcRevision;
|
||||
size_t igcLibSize{0};
|
||||
time_t igcLibMTime{0};
|
||||
CIF::RAII::UPtr_t<CIF::CIFMain> igcMain;
|
||||
CIF::RAII::UPtr_t<IGC::IgcOclDeviceCtxTagOCL> igcDeviceCtx;
|
||||
bool initialized{false};
|
||||
|
||||
@@ -209,10 +209,13 @@ int OfflineCompiler::buildIrBinary() {
|
||||
int retVal = SUCCESS;
|
||||
|
||||
if (allowCaching) {
|
||||
const std::string igcRevision = igcFacade->getIgcRevision();
|
||||
const auto igcLibSize = igcFacade->getIgcLibSize();
|
||||
const auto igcLibMTime = igcFacade->getIgcLibMTime();
|
||||
irHash = cache->getCachedFileName(getHardwareInfo(),
|
||||
sourceCode,
|
||||
options,
|
||||
internalOptions);
|
||||
internalOptions, igcRevision, igcLibSize, igcLibMTime);
|
||||
irBinary = cache->loadCachedBinary(irHash, irBinarySize).release();
|
||||
if (irBinary) {
|
||||
return retVal;
|
||||
@@ -329,17 +332,20 @@ int OfflineCompiler::buildSourceCode() {
|
||||
}
|
||||
|
||||
if (allowCaching) {
|
||||
irHash = cache->getCachedFileName(getHardwareInfo(), sourceCode, options, internalOptions);
|
||||
const std::string igcRevision = igcFacade->getIgcRevision();
|
||||
const auto igcLibSize = igcFacade->getIgcLibSize();
|
||||
const auto igcLibMTime = igcFacade->getIgcLibMTime();
|
||||
irHash = cache->getCachedFileName(getHardwareInfo(), sourceCode, options, internalOptions, igcRevision, igcLibSize, igcLibMTime);
|
||||
irBinary = cache->loadCachedBinary(irHash, irBinarySize).release();
|
||||
|
||||
genHash = cache->getCachedFileName(getHardwareInfo(), ArrayRef<const char>(irBinary, irBinarySize), options, internalOptions);
|
||||
genHash = cache->getCachedFileName(getHardwareInfo(), ArrayRef<const char>(irBinary, irBinarySize), options, internalOptions, igcRevision, igcLibSize, igcLibMTime);
|
||||
genBinary = cache->loadCachedBinary(genHash, genBinarySize).release();
|
||||
|
||||
if (irBinary && genBinary) {
|
||||
if (!CompilerOptions::contains(options, CompilerOptions::generateDebugInfo))
|
||||
return retVal;
|
||||
else {
|
||||
dbgHash = cache->getCachedFileName(getHardwareInfo(), irHash, options, internalOptions);
|
||||
dbgHash = cache->getCachedFileName(getHardwareInfo(), irHash, options, internalOptions, igcRevision, igcLibSize, igcLibMTime);
|
||||
debugDataBinary = cache->loadCachedBinary(dbgHash, debugDataBinarySize).release();
|
||||
if (debugDataBinary)
|
||||
return retVal;
|
||||
@@ -1121,10 +1127,13 @@ bool OfflineCompiler::generateElfBinary() {
|
||||
}
|
||||
|
||||
if (allowCaching) {
|
||||
const std::string igcRevision = igcFacade->getIgcRevision();
|
||||
const auto igcLibSize = igcFacade->getIgcLibSize();
|
||||
const auto igcLibMTime = igcFacade->getIgcLibMTime();
|
||||
elfHash = cache->getCachedFileName(getHardwareInfo(),
|
||||
genHash,
|
||||
options,
|
||||
internalOptions);
|
||||
internalOptions, igcRevision, igcLibSize, igcLibMTime);
|
||||
auto loadedData = cache->loadCachedBinary(elfHash, elfBinarySize);
|
||||
elfBinary.assign(loadedData.get(), loadedData.get() + elfBinarySize);
|
||||
if (!elfBinary.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user