fix: ocloc - regenerate genHash after compilation

This PR ensures that the genHash will be the same
whether the cl_cache is re-used or just created.
So it has to be regenerated after compilation
to make sure it's created with non NULL irBinary.

It also allows to cache debugDataBinary.

Minor: Rename NEO_PERSISTENT_CACHE -> NEO_CACHE_PERSISTENT in FAQ,
since this version is used in code.

Related-To: NEO-8288, NEO-8092
Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwolinski
2023-08-25 16:41:59 +00:00
committed by Compute-Runtime-Automation
parent b578e4ad57
commit 1369882b3c
4 changed files with 61 additions and 10 deletions

View File

@@ -331,26 +331,36 @@ int OfflineCompiler::buildSourceCode() {
return INVALID_PROGRAM;
}
const std::string igcRevision = igcFacade->getIgcRevision();
const auto igcLibSize = igcFacade->getIgcLibSize();
const auto igcLibMTime = igcFacade->getIgcLibMTime();
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, igcRevision, igcLibSize, igcLibMTime);
irBinary = cache->loadCachedBinary(irHash, irBinarySize).release();
genHash = cache->getCachedFileName(getHardwareInfo(), ArrayRef<const char>(irBinary, irBinarySize), options, internalOptions, igcRevision, igcLibSize, igcLibMTime);
genBinary = cache->loadCachedBinary(genHash, genBinarySize).release();
const bool generateDebugInfo = CompilerOptions::contains(options, CompilerOptions::generateDebugInfo);
if (generateDebugInfo) {
dbgHash = cache->getCachedFileName(getHardwareInfo(), irHash, options, internalOptions, igcRevision, igcLibSize, igcLibMTime);
debugDataBinary = cache->loadCachedBinary(dbgHash, debugDataBinarySize).release();
}
if (irBinary && genBinary) {
if (!CompilerOptions::contains(options, CompilerOptions::generateDebugInfo))
bool isZebin = isDeviceBinaryFormat<DeviceBinaryFormat::Zebin>(ArrayRef<uint8_t>(reinterpret_cast<uint8_t *>(genBinary), genBinarySize));
auto asBitcode = ArrayRef<const uint8_t>::fromAny(irBinary, irBinarySize);
isSpirV = NEO::isSpirVBitcode(asBitcode);
if (!generateDebugInfo) {
return retVal;
} else if (debugDataBinary || isZebin) {
return retVal;
else {
dbgHash = cache->getCachedFileName(getHardwareInfo(), irHash, options, internalOptions, igcRevision, igcLibSize, igcLibMTime);
debugDataBinary = cache->loadCachedBinary(dbgHash, debugDataBinarySize).release();
if (debugDataBinary)
return retVal;
}
}
delete[] irBinary;
delete[] genBinary;
irBinary = nullptr;
@@ -399,6 +409,7 @@ int OfflineCompiler::buildSourceCode() {
storeBinary(debugDataBinary, debugDataBinarySize, igcOutput->GetDebugData()->GetMemory<char>(), igcOutput->GetDebugData()->GetSizeRaw());
}
if (allowCaching) {
genHash = cache->getCachedFileName(getHardwareInfo(), ArrayRef<const char>(irBinary, irBinarySize), options, internalOptions, igcRevision, igcLibSize, igcLibMTime);
cache->cacheBinary(irHash, irBinary, static_cast<uint32_t>(irBinarySize));
cache->cacheBinary(genHash, genBinary, static_cast<uint32_t>(genBinarySize));
cache->cacheBinary(dbgHash, debugDataBinary, static_cast<uint32_t>(debugDataBinarySize));

View File

@@ -19,6 +19,7 @@ class CompilerCacheMock : public CompilerCache {
bool cacheBinary(const std::string &kernelFileHash, const char *pBinary, size_t binarySize) override {
cacheInvoked++;
cacheBinaryKernelFileHashes.push_back(kernelFileHash);
return cacheResult;
}
@@ -31,6 +32,7 @@ class CompilerCacheMock : public CompilerCache {
return nullptr;
}
std::vector<std::string> cacheBinaryKernelFileHashes{};
bool cacheResult = false;
uint32_t cacheInvoked = 0u;
bool loadResult = false;