mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Use ProgramInfo instead of Program in sip kernel
Related-To: NEO-5001 Change-Id: I58eda3ecc52fe1215ea8bbc35f97eea3a9d848e0 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
dd5c5ed723
commit
97154f7f98
@ -23,9 +23,7 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_graphics_allocation.h"
|
||||
|
||||
namespace NEO {
|
||||
GlobalMockSipProgram *GlobalMockSipProgram::sipProgram;
|
||||
ExecutionEnvironment GlobalMockSipProgram::executionEnvironment;
|
||||
|
||||
ProgramInfo *GlobalMockSipProgram::globalSipProgramInfo;
|
||||
Device *MockProgram::getDevicePtr() { return this->pDevice; }
|
||||
|
||||
std::string MockProgram::getCachedFileName() const {
|
||||
@ -35,63 +33,55 @@ std::string MockProgram::getCachedFileName() const {
|
||||
auto internalOpts = ArrayRef<const char>(this->internalOptions.c_str(), this->internalOptions.size());
|
||||
return CompilerCache::getCachedFileName(hwInfo, input, opts, internalOpts);
|
||||
}
|
||||
cl_int GlobalMockSipProgram::processGenBinary(uint32_t rootDeviceIndex) {
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
cl_int GlobalMockSipProgram::processGenBinaryOnce(uint32_t rootDeviceIndex) {
|
||||
cl_int ret = Program::processGenBinary(rootDeviceIndex);
|
||||
sipAllocationStorage = alignedMalloc(this->kernelInfoArray[0]->heapInfo.KernelHeapSize, MemoryConstants::pageSize);
|
||||
this->kernelInfoArray[0]->kernelAllocation = new MockGraphicsAllocation(sipAllocationStorage, this->kernelInfoArray[0]->heapInfo.KernelHeapSize);
|
||||
return ret;
|
||||
}
|
||||
void GlobalMockSipProgram::resetAllocationState() {
|
||||
auto allocation = static_cast<MockGraphicsAllocation *>(this->kernelInfoArray[0]->kernelAllocation);
|
||||
for (uint32_t index = 0u; index < allocation->usageInfos.size(); index++) {
|
||||
this->kernelInfoArray[0]->kernelAllocation->releaseResidencyInOsContext(index);
|
||||
}
|
||||
allocation->resetInspectionIds();
|
||||
}
|
||||
void GlobalMockSipProgram::initSipProgram() {
|
||||
cl_int retVal = 0;
|
||||
void GlobalMockSipProgram::initSipProgramInfo() {
|
||||
globalSipProgramInfo = new ProgramInfo();
|
||||
std::vector<char> binary = MockCompilerInterface::getDummyGenBinary();
|
||||
executionEnvironment.prepareRootDeviceEnvironments(maxRootDeviceCount);
|
||||
for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) {
|
||||
executionEnvironment.rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
|
||||
}
|
||||
executionEnvironment.calculateMaxOsContextCount();
|
||||
executionEnvironment.incRefInternal();
|
||||
MockDevice device(&executionEnvironment, mockRootDeviceIndex);
|
||||
sipProgram = Program::createFromGenBinary<GlobalMockSipProgram>(executionEnvironment,
|
||||
nullptr,
|
||||
binary.data(),
|
||||
binary.size(),
|
||||
true,
|
||||
&retVal,
|
||||
&device);
|
||||
DEBUG_BREAK_IF(retVal != 0);
|
||||
sipProgram->processGenBinaryOnce(mockRootDeviceIndex);
|
||||
auto blob = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(binary.data()), binary.size());
|
||||
SingleDeviceBinary deviceBinary = {};
|
||||
deviceBinary.deviceBinary = blob;
|
||||
std::string decodeErrors;
|
||||
std::string decodeWarnings;
|
||||
|
||||
NEO::decodeSingleDeviceBinary(*globalSipProgramInfo, deviceBinary, decodeErrors, decodeWarnings);
|
||||
auto sipAllocationStorage = alignedMalloc(globalSipProgramInfo->kernelInfos[0]->heapInfo.KernelHeapSize, MemoryConstants::pageSize);
|
||||
memcpy(sipAllocationStorage, globalSipProgramInfo->kernelInfos[0]->heapInfo.pKernelHeap, globalSipProgramInfo->kernelInfos[0]->heapInfo.KernelHeapSize);
|
||||
globalSipProgramInfo->kernelInfos[0]->heapInfo.pKernelHeap = sipAllocationStorage;
|
||||
globalSipProgramInfo->kernelInfos[0]->kernelAllocation = new MockGraphicsAllocation(sipAllocationStorage, globalSipProgramInfo->kernelInfos[0]->heapInfo.KernelHeapSize);
|
||||
}
|
||||
void GlobalMockSipProgram::shutDownSipProgramInfo() {
|
||||
deleteAllocation();
|
||||
delete globalSipProgramInfo;
|
||||
}
|
||||
|
||||
void GlobalMockSipProgram::resetAllocation(GraphicsAllocation *allocation) {
|
||||
this->kernelInfoArray[0]->kernelAllocation = allocation;
|
||||
globalSipProgramInfo->kernelInfos[0]->kernelAllocation = allocation;
|
||||
}
|
||||
GraphicsAllocation *GlobalMockSipProgram::getAllocation() {
|
||||
return this->kernelInfoArray[0]->kernelAllocation;
|
||||
return globalSipProgramInfo->kernelInfos[0]->kernelAllocation;
|
||||
}
|
||||
void GlobalMockSipProgram::deleteAllocation() {
|
||||
delete this->kernelInfoArray[0]->kernelAllocation;
|
||||
alignedFree(sipAllocationStorage);
|
||||
this->kernelInfoArray[0]->kernelAllocation = nullptr;
|
||||
auto allocation = globalSipProgramInfo->kernelInfos[0]->kernelAllocation;
|
||||
alignedFree(allocation->getUnderlyingBuffer());
|
||||
delete allocation;
|
||||
globalSipProgramInfo->kernelInfos[0]->kernelAllocation = nullptr;
|
||||
}
|
||||
|
||||
void GlobalMockSipProgram::shutDownSipProgram() {
|
||||
sipProgram->deleteAllocation();
|
||||
|
||||
delete sipProgram;
|
||||
void GlobalMockSipProgram::resetAllocationState() {
|
||||
auto allocation = static_cast<MockGraphicsAllocation *>(globalSipProgramInfo->kernelInfos[0]->kernelAllocation);
|
||||
for (uint32_t index = 0u; index < allocation->usageInfos.size(); index++) {
|
||||
globalSipProgramInfo->kernelInfos[0]->kernelAllocation->releaseResidencyInOsContext(index);
|
||||
}
|
||||
allocation->resetInspectionIds();
|
||||
}
|
||||
|
||||
Program *GlobalMockSipProgram::getSipProgramWithCustomBinary() {
|
||||
ProgramInfo GlobalMockSipProgram::getSipProgramInfo() {
|
||||
ProgramInfo programInfo;
|
||||
programInfo.kernelInfos.push_back(new KernelInfo{});
|
||||
programInfo.kernelInfos[0]->heapInfo = GlobalMockSipProgram::globalSipProgramInfo->kernelInfos[0]->heapInfo;
|
||||
programInfo.kernelInfos[0]->kernelAllocation = GlobalMockSipProgram::getAllocation();
|
||||
return programInfo;
|
||||
}
|
||||
ProgramInfo GlobalMockSipProgram::getSipProgramInfoWithCustomBinary() {
|
||||
NEO::PatchTokenBinary::ProgramFromPatchtokens programTokens;
|
||||
programTokens.kernels.resize(1);
|
||||
|
||||
@ -113,9 +103,6 @@ Program *GlobalMockSipProgram::getSipProgramWithCustomBinary() {
|
||||
|
||||
NEO::ProgramInfo programInfo;
|
||||
NEO::populateProgramInfo(programInfo, programTokens);
|
||||
|
||||
Program *ret = new Program(executionEnvironment, nullptr, false, nullptr);
|
||||
ret->processProgramInfo(programInfo);
|
||||
return ret;
|
||||
return programInfo;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
@ -156,26 +156,17 @@ class MockProgram : public Program {
|
||||
int isOptionValueValidOverride = -1;
|
||||
};
|
||||
|
||||
class GlobalMockSipProgram : public Program {
|
||||
public:
|
||||
using Program::Program;
|
||||
GlobalMockSipProgram(ExecutionEnvironment &executionEnvironment) : Program(executionEnvironment, nullptr, false, nullptr) {
|
||||
}
|
||||
cl_int processGenBinary(uint32_t rootDeviceIndex) override;
|
||||
cl_int processGenBinaryOnce(uint32_t rootDeviceIndex);
|
||||
void resetAllocationState();
|
||||
void resetAllocation(GraphicsAllocation *allocation);
|
||||
void deleteAllocation();
|
||||
GraphicsAllocation *getAllocation();
|
||||
static void initSipProgram();
|
||||
static void shutDownSipProgram();
|
||||
static GlobalMockSipProgram *sipProgram;
|
||||
static Program *getSipProgramWithCustomBinary();
|
||||
|
||||
protected:
|
||||
void *sipAllocationStorage;
|
||||
static ExecutionEnvironment executionEnvironment;
|
||||
};
|
||||
namespace GlobalMockSipProgram {
|
||||
void resetAllocationState();
|
||||
void resetAllocation(GraphicsAllocation *allocation);
|
||||
void deleteAllocation();
|
||||
GraphicsAllocation *getAllocation();
|
||||
void initSipProgramInfo();
|
||||
void shutDownSipProgramInfo();
|
||||
ProgramInfo getSipProgramInfoWithCustomBinary();
|
||||
extern ProgramInfo *globalSipProgramInfo;
|
||||
ProgramInfo getSipProgramInfo();
|
||||
}; // namespace GlobalMockSipProgram
|
||||
|
||||
class GMockProgram : public Program {
|
||||
public:
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <map>
|
||||
|
||||
namespace NEO {
|
||||
MockSipKernel::MockSipKernel(SipKernelType type, Program *sipProgram) : SipKernel(type, sipProgram) {
|
||||
MockSipKernel::MockSipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo) : SipKernel(type, std::move(sipProgramInfo)) {
|
||||
this->mockSipMemoryAllocation =
|
||||
std::make_unique<MemoryAllocation>(0u,
|
||||
GraphicsAllocation::AllocationType::KERNEL_ISA,
|
||||
@ -34,7 +34,7 @@ MockSipKernel::MockSipKernel(SipKernelType type, Program *sipProgram) : SipKerne
|
||||
MemoryPool::System4KBPages, 3u);
|
||||
}
|
||||
|
||||
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
|
||||
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, {}) {
|
||||
this->mockSipMemoryAllocation =
|
||||
std::make_unique<MemoryAllocation>(0u,
|
||||
GraphicsAllocation::AllocationType::KERNEL_ISA,
|
||||
@ -43,7 +43,6 @@ MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
|
||||
0u,
|
||||
MemoryConstants::pageSize,
|
||||
MemoryPool::System4KBPages, 3u);
|
||||
this->program = new MockProgram(this->executionEnvironment, nullptr, false, nullptr);
|
||||
}
|
||||
|
||||
MockSipKernel::~MockSipKernel() = default;
|
||||
|
@ -19,10 +19,10 @@ class MemoryAllocation;
|
||||
|
||||
class MockSipKernel : public SipKernel {
|
||||
public:
|
||||
using SipKernel::program;
|
||||
using SipKernel::programInfo;
|
||||
using SipKernel::type;
|
||||
|
||||
MockSipKernel(SipKernelType type, Program *sipProgram);
|
||||
MockSipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo);
|
||||
MockSipKernel();
|
||||
~MockSipKernel() override;
|
||||
|
||||
|
Reference in New Issue
Block a user