Files
compute-runtime/shared/test/common/mocks/mock_compiler_cache.h
Diedrich, Kamil 26ca64bb28 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>
2023-04-25 17:35:40 +02:00

38 lines
986 B
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:
CompilerCacheMock() : CompilerCache(CompilerCacheConfig{}) {
}
bool cacheBinary(const std::string &kernelFileHash, const char *pBinary, size_t binarySize) override {
cacheInvoked++;
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;
}
bool cacheResult = false;
uint32_t cacheInvoked = 0u;
bool loadResult = false;
uint32_t numberOfLoadResult = 0u;
};
} // namespace NEO