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:
parent
dd5c5ed723
commit
97154f7f98
|
@ -8,29 +8,31 @@
|
|||
#include "opencl/source/helpers/built_ins_helper.h"
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
|
||||
#include "opencl/source/program/program.h"
|
||||
#include "opencl/source/program/kernel_info.h"
|
||||
|
||||
namespace NEO {
|
||||
const SipKernel &initSipKernel(SipKernelType type, Device &device) {
|
||||
return device.getBuiltIns()->getSipKernel(type, device);
|
||||
}
|
||||
Program *createProgramForSip(ExecutionEnvironment &executionEnvironment,
|
||||
Context *context,
|
||||
std::vector<char> &binary,
|
||||
size_t size,
|
||||
cl_int *errcodeRet,
|
||||
Device *device) {
|
||||
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device) {
|
||||
|
||||
cl_int retVal = 0;
|
||||
auto program = Program::createFromGenBinary(executionEnvironment,
|
||||
context,
|
||||
binary.data(),
|
||||
size,
|
||||
true,
|
||||
&retVal,
|
||||
device);
|
||||
DEBUG_BREAK_IF(retVal != 0);
|
||||
return program;
|
||||
ProgramInfo programInfo;
|
||||
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;
|
||||
|
||||
DecodeError decodeError;
|
||||
DeviceBinaryFormat singleDeviceBinaryFormat;
|
||||
std::tie(decodeError, singleDeviceBinaryFormat) = NEO::decodeSingleDeviceBinary(programInfo, deviceBinary, decodeErrors, decodeWarnings);
|
||||
UNRECOVERABLE_IF(DecodeError::Success != decodeError);
|
||||
|
||||
auto success = programInfo.kernelInfos[0]->createKernelAllocation(device);
|
||||
UNRECOVERABLE_IF(!success);
|
||||
|
||||
return programInfo;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
|
|
@ -7,16 +7,11 @@
|
|||
|
||||
#pragma once
|
||||
#include "shared/source/built_ins/built_ins.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
|
||||
namespace NEO {
|
||||
class Device;
|
||||
|
||||
const SipKernel &initSipKernel(SipKernelType type, Device &device);
|
||||
Program *createProgramForSip(ExecutionEnvironment &executionEnvironment,
|
||||
Context *context,
|
||||
std::vector<char> &binary,
|
||||
size_t size,
|
||||
int *errcodeRet,
|
||||
Device *device);
|
||||
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device);
|
||||
} // namespace NEO
|
||||
|
|
|
@ -52,7 +52,7 @@ const KernelInfo *Program::getKernelInfo(size_t ordinal) const {
|
|||
}
|
||||
|
||||
cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, const void *variablesInitData) {
|
||||
auto linkerInput = pDevice ? getLinkerInput(pDevice->getRootDeviceIndex()) : nullptr;
|
||||
auto linkerInput = getLinkerInput(pDevice->getRootDeviceIndex());
|
||||
if (linkerInput == nullptr) {
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
@ -162,24 +162,23 @@ cl_int Program::processProgramInfo(ProgramInfo &src) {
|
|||
size_t slmAvailable = 0U;
|
||||
NEO::DeviceInfoKernelPayloadConstants deviceInfoConstants;
|
||||
LinkerInput *linkerInput = nullptr;
|
||||
if (this->pDevice) {
|
||||
slmAvailable = static_cast<size_t>(this->pDevice->getDeviceInfo().localMemSize);
|
||||
deviceInfoConstants.maxWorkGroupSize = (uint32_t)this->pDevice->getDeviceInfo().maxWorkGroupSize;
|
||||
deviceInfoConstants.computeUnitsUsedForScratch = this->pDevice->getDeviceInfo().computeUnitsUsedForScratch;
|
||||
deviceInfoConstants.slmWindowSize = (uint32_t)this->pDevice->getDeviceInfo().localMemSize;
|
||||
if (requiresLocalMemoryWindowVA(src)) {
|
||||
deviceInfoConstants.slmWindow = this->executionEnvironment.memoryManager->getReservedMemory(MemoryConstants::slmWindowSize, MemoryConstants::slmWindowAlignment);
|
||||
}
|
||||
linkerInput = src.linkerInput.get();
|
||||
setLinkerInput(pDevice->getRootDeviceIndex(), std::move(src.linkerInput));
|
||||
slmAvailable = static_cast<size_t>(this->pDevice->getDeviceInfo().localMemSize);
|
||||
deviceInfoConstants.maxWorkGroupSize = (uint32_t)this->pDevice->getDeviceInfo().maxWorkGroupSize;
|
||||
deviceInfoConstants.computeUnitsUsedForScratch = this->pDevice->getDeviceInfo().computeUnitsUsedForScratch;
|
||||
deviceInfoConstants.slmWindowSize = (uint32_t)this->pDevice->getDeviceInfo().localMemSize;
|
||||
if (requiresLocalMemoryWindowVA(src)) {
|
||||
deviceInfoConstants.slmWindow = this->executionEnvironment.memoryManager->getReservedMemory(MemoryConstants::slmWindowSize, MemoryConstants::slmWindowAlignment);
|
||||
}
|
||||
linkerInput = src.linkerInput.get();
|
||||
setLinkerInput(pDevice->getRootDeviceIndex(), std::move(src.linkerInput));
|
||||
|
||||
if (slmNeeded > slmAvailable) {
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
this->kernelInfoArray = std::move(src.kernelInfos);
|
||||
auto svmAllocsManager = context ? context->getSVMAllocsManager() : nullptr;
|
||||
auto rootDeviceIndex = pDevice ? pDevice->getRootDeviceIndex() : 0u;
|
||||
auto rootDeviceIndex = pDevice->getRootDeviceIndex();
|
||||
if (src.globalConstants.size != 0) {
|
||||
UNRECOVERABLE_IF(nullptr == pDevice);
|
||||
buildInfos[rootDeviceIndex].constantSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalConstants.size, true, linkerInput, src.globalConstants.initData);
|
||||
|
@ -188,7 +187,6 @@ cl_int Program::processProgramInfo(ProgramInfo &src) {
|
|||
buildInfos[rootDeviceIndex].globalVarTotalSize = src.globalVariables.size;
|
||||
|
||||
if (src.globalVariables.size != 0) {
|
||||
UNRECOVERABLE_IF(nullptr == pDevice);
|
||||
buildInfos[rootDeviceIndex].globalSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalVariables.size, false, linkerInput, src.globalVariables.initData);
|
||||
if (pDevice->getSpecializedDevice<ClDevice>()->areOcl21FeaturesEnabled() == false) {
|
||||
buildInfos[rootDeviceIndex].globalVarTotalSize = 0u;
|
||||
|
@ -197,11 +195,10 @@ cl_int Program::processProgramInfo(ProgramInfo &src) {
|
|||
|
||||
for (auto &kernelInfo : this->kernelInfoArray) {
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (kernelInfo->heapInfo.KernelHeapSize && this->pDevice) {
|
||||
if (kernelInfo->heapInfo.KernelHeapSize) {
|
||||
retVal = kernelInfo->createKernelAllocation(*this->pDevice) ? CL_SUCCESS : CL_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
DEBUG_BREAK_IF(kernelInfo->heapInfo.KernelHeapSize && !this->pDevice);
|
||||
if (retVal != CL_SUCCESS) {
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -82,16 +82,16 @@ TEST(Sip, GivenSipLlWhenGettingMetadataThenMetadataRequiredByCompilerIsReturned)
|
|||
}
|
||||
|
||||
TEST(Sip, WhenGettingTypeThenCorrectTypeIsReturned) {
|
||||
SipKernel csr{SipKernelType::Csr, GlobalMockSipProgram::getSipProgramWithCustomBinary()};
|
||||
SipKernel csr{SipKernelType::Csr, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()};
|
||||
EXPECT_EQ(SipKernelType::Csr, csr.getType());
|
||||
|
||||
SipKernel dbgCsr{SipKernelType::DbgCsr, GlobalMockSipProgram::getSipProgramWithCustomBinary()};
|
||||
SipKernel dbgCsr{SipKernelType::DbgCsr, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()};
|
||||
EXPECT_EQ(SipKernelType::DbgCsr, dbgCsr.getType());
|
||||
|
||||
SipKernel dbgCsrLocal{SipKernelType::DbgCsrLocal, GlobalMockSipProgram::getSipProgramWithCustomBinary()};
|
||||
SipKernel dbgCsrLocal{SipKernelType::DbgCsrLocal, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()};
|
||||
EXPECT_EQ(SipKernelType::DbgCsrLocal, dbgCsrLocal.getType());
|
||||
|
||||
SipKernel undefined{SipKernelType::COUNT, GlobalMockSipProgram::getSipProgramWithCustomBinary()};
|
||||
SipKernel undefined{SipKernelType::COUNT, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()};
|
||||
EXPECT_EQ(SipKernelType::COUNT, undefined.getType());
|
||||
}
|
||||
|
||||
|
|
|
@ -29,14 +29,7 @@ const SipKernel &initSipKernel(SipKernelType type, Device &device) {
|
|||
MockSipData::called = true;
|
||||
return *MockSipData::mockSipKernel;
|
||||
}
|
||||
Program *createProgramForSip(ExecutionEnvironment &executionEnvironment,
|
||||
Context *context,
|
||||
std::vector<char> &binary,
|
||||
size_t size,
|
||||
cl_int *errcodeRet,
|
||||
Device *device) {
|
||||
GlobalMockSipProgram::sipProgram->incRefApi();
|
||||
GlobalMockSipProgram::sipProgram->resetAllocationState();
|
||||
return GlobalMockSipProgram::sipProgram;
|
||||
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device) {
|
||||
return GlobalMockSipProgram::getSipProgramInfo();
|
||||
}
|
||||
} // namespace NEO
|
||||
|
|
|
@ -147,12 +147,12 @@ LONG WINAPI UltExceptionFilter(
|
|||
#endif
|
||||
|
||||
void initializeTestHelpers() {
|
||||
GlobalMockSipProgram::initSipProgram();
|
||||
GlobalMockSipProgram::initSipProgramInfo();
|
||||
MockSipData::mockSipKernel.reset(new MockSipKernel());
|
||||
}
|
||||
|
||||
void cleanTestHelpers() {
|
||||
GlobalMockSipProgram::shutDownSipProgram();
|
||||
GlobalMockSipProgram::shutDownSipProgramInfo();
|
||||
delete platformsImpl;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -663,8 +663,8 @@ class DrmCommandStreamBatchingTests : public DrmCommandStreamEnhancedTest {
|
|||
void SetUpT() {
|
||||
DrmCommandStreamEnhancedTest::SetUpT<GfxFamily>();
|
||||
if (PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo) == PreemptionMode::MidThread) {
|
||||
tmpAllocation = GlobalMockSipProgram::sipProgram->getAllocation();
|
||||
GlobalMockSipProgram::sipProgram->resetAllocation(device->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||
tmpAllocation = GlobalMockSipProgram::getAllocation();
|
||||
GlobalMockSipProgram::resetAllocation(device->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||
}
|
||||
tagAllocation = static_cast<DrmAllocation *>(device->getDefaultEngine().commandStreamReceiver->getTagAllocation());
|
||||
preemptionAllocation = static_cast<DrmAllocation *>(device->getDefaultEngine().commandStreamReceiver->getPreemptionAllocation());
|
||||
|
@ -673,8 +673,8 @@ class DrmCommandStreamBatchingTests : public DrmCommandStreamEnhancedTest {
|
|||
template <typename GfxFamily>
|
||||
void TearDownT() {
|
||||
if (PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo) == PreemptionMode::MidThread) {
|
||||
device->getMemoryManager()->freeGraphicsMemory((GlobalMockSipProgram::sipProgram)->getAllocation());
|
||||
GlobalMockSipProgram::sipProgram->resetAllocation(tmpAllocation);
|
||||
device->getMemoryManager()->freeGraphicsMemory(GlobalMockSipProgram::getAllocation());
|
||||
GlobalMockSipProgram::resetAllocation(tmpAllocation);
|
||||
}
|
||||
DrmCommandStreamEnhancedTest::TearDownT<GfxFamily>();
|
||||
}
|
||||
|
|
|
@ -806,8 +806,8 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
|||
GraphicsAllocation *tmpAllocation = nullptr;
|
||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||
csrSurfaceCount = 2;
|
||||
tmpAllocation = GlobalMockSipProgram::sipProgram->getAllocation();
|
||||
GlobalMockSipProgram::sipProgram->resetAllocation(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||
tmpAllocation = GlobalMockSipProgram::getAllocation();
|
||||
GlobalMockSipProgram::resetAllocation(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||
}
|
||||
csrSurfaceCount += csr->globalFenceAllocation ? 1 : 0;
|
||||
|
||||
|
@ -884,8 +884,8 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
|||
memoryManager->freeGraphicsMemory(sshAlloc);
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||
memoryManager->freeGraphicsMemory(GlobalMockSipProgram::sipProgram->getAllocation());
|
||||
GlobalMockSipProgram::sipProgram->resetAllocation(tmpAllocation);
|
||||
memoryManager->freeGraphicsMemory(GlobalMockSipProgram::getAllocation());
|
||||
GlobalMockSipProgram::resetAllocation(tmpAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,14 @@
|
|||
#include "opencl/source/platform/platform.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
|
||||
namespace NEO {
|
||||
namespace GlobalMockSipProgram {
|
||||
void resetAllocationState();
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
void NEO::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) {
|
||||
GlobalMockSipProgram::resetAllocationState();
|
||||
referencedHwInfo = *defaultHwInfo;
|
||||
auto executionEnvironment = constructPlatform()->peekExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "shared/source/built_ins/sip.h"
|
||||
#include "shared/source/compiler_interface/compiler_interface.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
|
@ -35,8 +36,6 @@ const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) {
|
|||
auto &sipBuiltIn = this->sipKernels[kernelId];
|
||||
|
||||
auto initializer = [&] {
|
||||
int retVal = 0;
|
||||
|
||||
std::vector<char> sipBinary;
|
||||
auto compilerInteface = device.getCompilerInterface();
|
||||
UNRECOVERABLE_IF(compilerInteface == nullptr);
|
||||
|
@ -45,19 +44,10 @@ const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) {
|
|||
|
||||
UNRECOVERABLE_IF(ret != TranslationOutput::ErrorCode::Success);
|
||||
UNRECOVERABLE_IF(sipBinary.size() == 0);
|
||||
auto program = createProgramForSip(*device.getExecutionEnvironment(),
|
||||
nullptr,
|
||||
sipBinary,
|
||||
sipBinary.size(),
|
||||
&retVal,
|
||||
&device);
|
||||
DEBUG_BREAK_IF(retVal != 0);
|
||||
UNRECOVERABLE_IF(program == nullptr);
|
||||
|
||||
retVal = program->processGenBinary(device.getRootDeviceIndex());
|
||||
DEBUG_BREAK_IF(retVal != 0);
|
||||
ProgramInfo programInfo = createProgramInfoForSip(sipBinary, sipBinary.size(), device);
|
||||
|
||||
sipBuiltIn.first.reset(new SipKernel(type, program));
|
||||
sipBuiltIn.first.reset(new SipKernel(type, std::move(programInfo)));
|
||||
};
|
||||
std::call_once(sipBuiltIn.second, initializer);
|
||||
UNRECOVERABLE_IF(sipBuiltIn.first == nullptr);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
|
||||
#include "opencl/source/program/kernel_info.h"
|
||||
#include "opencl/source/program/program.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
@ -68,24 +67,20 @@ const char *getSipLlSrc(const Device &device) {
|
|||
return (ptrSize == 8) ? llDummySrc64 : llDummySrc32;
|
||||
}
|
||||
|
||||
SipKernel::SipKernel(SipKernelType type, Program *sipProgram)
|
||||
: type(type) {
|
||||
program = sipProgram;
|
||||
}
|
||||
SipKernel::~SipKernel() {
|
||||
program->release();
|
||||
}
|
||||
SipKernel::SipKernel(SipKernelType type, ProgramInfo &&sipProgram)
|
||||
: type(type), programInfo(std::move(sipProgram)) {}
|
||||
SipKernel::~SipKernel() = default;
|
||||
|
||||
GraphicsAllocation *SipKernel::getSipAllocation() const {
|
||||
return program->getKernelInfo(size_t{0})->getGraphicsAllocation();
|
||||
return programInfo.kernelInfos[0]->getGraphicsAllocation();
|
||||
}
|
||||
|
||||
const char *SipKernel::getBinary() const {
|
||||
auto kernelInfo = program->getKernelInfo(size_t{0});
|
||||
auto kernelInfo = programInfo.kernelInfos[0];
|
||||
return reinterpret_cast<const char *>(ptrOffset(kernelInfo->heapInfo.pKernelHeap, kernelInfo->systemKernelOffset));
|
||||
}
|
||||
size_t SipKernel::getBinarySize() const {
|
||||
auto kernelInfo = program->getKernelInfo(size_t{0});
|
||||
auto kernelInfo = programInfo.kernelInfos[0];
|
||||
return kernelInfo->heapInfo.KernelHeapSize - kernelInfo->systemKernelOffset;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
#pragma once
|
||||
#include "shared/source/built_ins/sip_kernel_type.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Device;
|
||||
class Program;
|
||||
class GraphicsAllocation;
|
||||
|
||||
const char *getSipKernelCompilerInternalOptions(SipKernelType kernel);
|
||||
|
@ -23,11 +23,11 @@ const char *getSipLlSrc(const Device &device);
|
|||
|
||||
class SipKernel {
|
||||
public:
|
||||
SipKernel(SipKernelType type, Program *sipProgram);
|
||||
SipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo);
|
||||
SipKernel(const SipKernel &) = delete;
|
||||
SipKernel &operator=(const SipKernel &) = delete;
|
||||
SipKernel(SipKernel &&) = default;
|
||||
SipKernel &operator=(SipKernel &&) = default;
|
||||
SipKernel(SipKernel &&) = delete;
|
||||
SipKernel &operator=(SipKernel &&) = delete;
|
||||
virtual ~SipKernel();
|
||||
|
||||
const char *getBinary() const;
|
||||
|
@ -46,6 +46,6 @@ class SipKernel {
|
|||
|
||||
protected:
|
||||
SipKernelType type = SipKernelType::COUNT;
|
||||
Program *program = nullptr;
|
||||
const ProgramInfo programInfo;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -433,12 +433,12 @@ int main(int argc, char **argv) {
|
|||
GmmInterface::initialize(nullptr, nullptr);
|
||||
}
|
||||
|
||||
GlobalMockSipProgram::initSipProgram();
|
||||
GlobalMockSipProgram::initSipProgramInfo();
|
||||
NEO::MockSipData::mockSipKernel.reset(new NEO::MockSipKernel());
|
||||
|
||||
retVal = RUN_ALL_TESTS();
|
||||
|
||||
GlobalMockSipProgram::shutDownSipProgram();
|
||||
GlobalMockSipProgram::shutDownSipProgramInfo();
|
||||
delete platformsImpl;
|
||||
|
||||
return retVal;
|
||||
|
|
|
@ -113,7 +113,7 @@ HWTEST_P(PreemptionHwTest, GivenPreemptionModeIsNotChangingWhenGettingRequiredCm
|
|||
{
|
||||
auto builtIns = new MockBuiltins();
|
||||
|
||||
builtIns->overrideSipKernel(std::unique_ptr<NEO::SipKernel>(new NEO::SipKernel{SipKernelType::Csr, GlobalMockSipProgram::getSipProgramWithCustomBinary()}));
|
||||
builtIns->overrideSipKernel(std::unique_ptr<NEO::SipKernel>(new NEO::SipKernel{SipKernelType::Csr, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()}));
|
||||
mockDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->builtins.reset(builtIns);
|
||||
PreemptionHelper::programCmdStream<FamilyType>(cmdStream, mode, mode, nullptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue