mirror of
https://github.com/intel/compute-runtime.git
synced 2025-06-28 17:58:30 +08:00

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>
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2022-2023 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "shared/source/compiler_interface/compiler_cache.h"
|
|
|
|
namespace NEO {
|
|
class CompilerCacheMock : public CompilerCache {
|
|
public:
|
|
using CompilerCache::config;
|
|
|
|
CompilerCacheMock() : CompilerCache(CompilerCacheConfig{}) {
|
|
}
|
|
|
|
bool cacheBinary(const std::string &kernelFileHash, const char *pBinary, size_t binarySize) override {
|
|
cacheInvoked++;
|
|
cacheBinaryKernelFileHashes.push_back(kernelFileHash);
|
|
return cacheResult;
|
|
}
|
|
|
|
std::unique_ptr<char[]> loadCachedBinary(const std::string &kernelFileHash, size_t &cachedBinarySize) override {
|
|
if (loadResult || numberOfLoadResult > 0) {
|
|
numberOfLoadResult--;
|
|
cachedBinarySize = sizeof(char);
|
|
return std::unique_ptr<char[]>{new char[1]};
|
|
} else
|
|
return nullptr;
|
|
}
|
|
|
|
std::vector<std::string> cacheBinaryKernelFileHashes{};
|
|
bool cacheResult = false;
|
|
uint32_t cacheInvoked = 0u;
|
|
bool loadResult = false;
|
|
uint32_t numberOfLoadResult = 0u;
|
|
};
|
|
} // namespace NEO
|