2018-03-05 16:25:40 +08:00
|
|
|
/*
|
2020-01-30 16:36:05 +08:00
|
|
|
* Copyright (C) 2018-2020 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2018-03-05 16:25:40 +08:00
|
|
|
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_sip.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/file_io.h"
|
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/memory_manager/os_agnostic_memory_manager.h"
|
|
|
|
#include "opencl/source/os_interface/os_inc_base.h"
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/helpers/test_files.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_compilers.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_program.h"
|
2018-03-05 16:25:40 +08:00
|
|
|
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "cif/macros/enable.h"
|
2018-03-05 16:25:40 +08:00
|
|
|
#include "ocl_igc_interface/igc_ocl_device_ctx.h"
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <map>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-12-03 22:57:45 +08:00
|
|
|
MockSipKernel::MockSipKernel(SipKernelType type, Program *sipProgram) : SipKernel(type, sipProgram) {
|
|
|
|
this->mockSipMemoryAllocation =
|
|
|
|
std::make_unique<MemoryAllocation>(0u,
|
|
|
|
GraphicsAllocation::AllocationType::KERNEL_ISA,
|
|
|
|
nullptr,
|
|
|
|
MemoryConstants::pageSize * 10u,
|
|
|
|
0u,
|
|
|
|
MemoryConstants::pageSize,
|
|
|
|
MemoryPool::System4KBPages);
|
|
|
|
}
|
|
|
|
|
|
|
|
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
|
|
|
|
this->mockSipMemoryAllocation =
|
|
|
|
std::make_unique<MemoryAllocation>(0u,
|
|
|
|
GraphicsAllocation::AllocationType::KERNEL_ISA,
|
|
|
|
nullptr,
|
|
|
|
MemoryConstants::pageSize * 10u,
|
|
|
|
0u,
|
|
|
|
MemoryConstants::pageSize,
|
|
|
|
MemoryPool::System4KBPages);
|
2020-02-20 15:12:44 +08:00
|
|
|
this->program = new MockProgram(this->executionEnvironment, nullptr, false, nullptr);
|
2019-12-03 22:57:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MockSipKernel::~MockSipKernel() = default;
|
|
|
|
|
2018-03-05 16:25:40 +08:00
|
|
|
std::vector<char> MockSipKernel::dummyBinaryForSip;
|
|
|
|
std::vector<char> MockSipKernel::getDummyGenBinary() {
|
2019-07-29 22:11:51 +08:00
|
|
|
if (dummyBinaryForSip.empty()) {
|
2018-03-05 16:25:40 +08:00
|
|
|
dummyBinaryForSip = getBinary();
|
|
|
|
}
|
|
|
|
return dummyBinaryForSip;
|
|
|
|
}
|
|
|
|
std::vector<char> MockSipKernel::getBinary() {
|
2018-04-24 19:06:49 +08:00
|
|
|
std::string testFile;
|
2020-02-12 17:10:28 +08:00
|
|
|
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd16_", ".gen");
|
2018-03-05 16:25:40 +08:00
|
|
|
|
2019-08-29 21:10:51 +08:00
|
|
|
size_t binarySize = 0;
|
|
|
|
auto binary = loadDataFromFile(testFile.c_str(), binarySize);
|
2019-02-16 03:01:40 +08:00
|
|
|
UNRECOVERABLE_IF(binary == nullptr);
|
|
|
|
|
2019-08-29 21:10:51 +08:00
|
|
|
std::vector<char> ret{binary.get(), binary.get() + binarySize};
|
2019-02-16 03:01:40 +08:00
|
|
|
|
2018-03-05 16:25:40 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
void MockSipKernel::initDummyBinary() {
|
|
|
|
dummyBinaryForSip = getBinary();
|
|
|
|
}
|
|
|
|
void MockSipKernel::shutDown() {
|
|
|
|
MockSipKernel::dummyBinaryForSip.clear();
|
|
|
|
}
|
2019-12-03 22:57:45 +08:00
|
|
|
|
|
|
|
GraphicsAllocation *MockSipKernel::getSipAllocation() const {
|
|
|
|
return mockSipMemoryAllocation.get();
|
|
|
|
}
|
2019-12-17 15:11:16 +08:00
|
|
|
} // namespace NEO
|