mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +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
@@ -8,29 +8,31 @@
|
|||||||
#include "opencl/source/helpers/built_ins_helper.h"
|
#include "opencl/source/helpers/built_ins_helper.h"
|
||||||
|
|
||||||
#include "shared/source/device/device.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 {
|
namespace NEO {
|
||||||
const SipKernel &initSipKernel(SipKernelType type, Device &device) {
|
const SipKernel &initSipKernel(SipKernelType type, Device &device) {
|
||||||
return device.getBuiltIns()->getSipKernel(type, device);
|
return device.getBuiltIns()->getSipKernel(type, device);
|
||||||
}
|
}
|
||||||
Program *createProgramForSip(ExecutionEnvironment &executionEnvironment,
|
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device) {
|
||||||
Context *context,
|
|
||||||
std::vector<char> &binary,
|
|
||||||
size_t size,
|
|
||||||
cl_int *errcodeRet,
|
|
||||||
Device *device) {
|
|
||||||
|
|
||||||
cl_int retVal = 0;
|
ProgramInfo programInfo;
|
||||||
auto program = Program::createFromGenBinary(executionEnvironment,
|
auto blob = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(binary.data()), binary.size());
|
||||||
context,
|
SingleDeviceBinary deviceBinary = {};
|
||||||
binary.data(),
|
deviceBinary.deviceBinary = blob;
|
||||||
size,
|
std::string decodeErrors;
|
||||||
true,
|
std::string decodeWarnings;
|
||||||
&retVal,
|
|
||||||
device);
|
DecodeError decodeError;
|
||||||
DEBUG_BREAK_IF(retVal != 0);
|
DeviceBinaryFormat singleDeviceBinaryFormat;
|
||||||
return program;
|
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
|
} // namespace NEO
|
||||||
|
|||||||
@@ -7,16 +7,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "shared/source/built_ins/built_ins.h"
|
#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 {
|
namespace NEO {
|
||||||
class Device;
|
class Device;
|
||||||
|
|
||||||
const SipKernel &initSipKernel(SipKernelType type, Device &device);
|
const SipKernel &initSipKernel(SipKernelType type, Device &device);
|
||||||
Program *createProgramForSip(ExecutionEnvironment &executionEnvironment,
|
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device);
|
||||||
Context *context,
|
|
||||||
std::vector<char> &binary,
|
|
||||||
size_t size,
|
|
||||||
int *errcodeRet,
|
|
||||||
Device *device);
|
|
||||||
} // namespace NEO
|
} // 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) {
|
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) {
|
if (linkerInput == nullptr) {
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -162,24 +162,23 @@ cl_int Program::processProgramInfo(ProgramInfo &src) {
|
|||||||
size_t slmAvailable = 0U;
|
size_t slmAvailable = 0U;
|
||||||
NEO::DeviceInfoKernelPayloadConstants deviceInfoConstants;
|
NEO::DeviceInfoKernelPayloadConstants deviceInfoConstants;
|
||||||
LinkerInput *linkerInput = nullptr;
|
LinkerInput *linkerInput = nullptr;
|
||||||
if (this->pDevice) {
|
slmAvailable = static_cast<size_t>(this->pDevice->getDeviceInfo().localMemSize);
|
||||||
slmAvailable = static_cast<size_t>(this->pDevice->getDeviceInfo().localMemSize);
|
deviceInfoConstants.maxWorkGroupSize = (uint32_t)this->pDevice->getDeviceInfo().maxWorkGroupSize;
|
||||||
deviceInfoConstants.maxWorkGroupSize = (uint32_t)this->pDevice->getDeviceInfo().maxWorkGroupSize;
|
deviceInfoConstants.computeUnitsUsedForScratch = this->pDevice->getDeviceInfo().computeUnitsUsedForScratch;
|
||||||
deviceInfoConstants.computeUnitsUsedForScratch = this->pDevice->getDeviceInfo().computeUnitsUsedForScratch;
|
deviceInfoConstants.slmWindowSize = (uint32_t)this->pDevice->getDeviceInfo().localMemSize;
|
||||||
deviceInfoConstants.slmWindowSize = (uint32_t)this->pDevice->getDeviceInfo().localMemSize;
|
if (requiresLocalMemoryWindowVA(src)) {
|
||||||
if (requiresLocalMemoryWindowVA(src)) {
|
deviceInfoConstants.slmWindow = this->executionEnvironment.memoryManager->getReservedMemory(MemoryConstants::slmWindowSize, MemoryConstants::slmWindowAlignment);
|
||||||
deviceInfoConstants.slmWindow = this->executionEnvironment.memoryManager->getReservedMemory(MemoryConstants::slmWindowSize, MemoryConstants::slmWindowAlignment);
|
|
||||||
}
|
|
||||||
linkerInput = src.linkerInput.get();
|
|
||||||
setLinkerInput(pDevice->getRootDeviceIndex(), std::move(src.linkerInput));
|
|
||||||
}
|
}
|
||||||
|
linkerInput = src.linkerInput.get();
|
||||||
|
setLinkerInput(pDevice->getRootDeviceIndex(), std::move(src.linkerInput));
|
||||||
|
|
||||||
if (slmNeeded > slmAvailable) {
|
if (slmNeeded > slmAvailable) {
|
||||||
return CL_OUT_OF_RESOURCES;
|
return CL_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->kernelInfoArray = std::move(src.kernelInfos);
|
this->kernelInfoArray = std::move(src.kernelInfos);
|
||||||
auto svmAllocsManager = context ? context->getSVMAllocsManager() : nullptr;
|
auto svmAllocsManager = context ? context->getSVMAllocsManager() : nullptr;
|
||||||
auto rootDeviceIndex = pDevice ? pDevice->getRootDeviceIndex() : 0u;
|
auto rootDeviceIndex = pDevice->getRootDeviceIndex();
|
||||||
if (src.globalConstants.size != 0) {
|
if (src.globalConstants.size != 0) {
|
||||||
UNRECOVERABLE_IF(nullptr == pDevice);
|
UNRECOVERABLE_IF(nullptr == pDevice);
|
||||||
buildInfos[rootDeviceIndex].constantSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalConstants.size, true, linkerInput, src.globalConstants.initData);
|
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;
|
buildInfos[rootDeviceIndex].globalVarTotalSize = src.globalVariables.size;
|
||||||
|
|
||||||
if (src.globalVariables.size != 0) {
|
if (src.globalVariables.size != 0) {
|
||||||
UNRECOVERABLE_IF(nullptr == pDevice);
|
|
||||||
buildInfos[rootDeviceIndex].globalSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalVariables.size, false, linkerInput, src.globalVariables.initData);
|
buildInfos[rootDeviceIndex].globalSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalVariables.size, false, linkerInput, src.globalVariables.initData);
|
||||||
if (pDevice->getSpecializedDevice<ClDevice>()->areOcl21FeaturesEnabled() == false) {
|
if (pDevice->getSpecializedDevice<ClDevice>()->areOcl21FeaturesEnabled() == false) {
|
||||||
buildInfos[rootDeviceIndex].globalVarTotalSize = 0u;
|
buildInfos[rootDeviceIndex].globalVarTotalSize = 0u;
|
||||||
@@ -197,11 +195,10 @@ cl_int Program::processProgramInfo(ProgramInfo &src) {
|
|||||||
|
|
||||||
for (auto &kernelInfo : this->kernelInfoArray) {
|
for (auto &kernelInfo : this->kernelInfoArray) {
|
||||||
cl_int retVal = CL_SUCCESS;
|
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;
|
retVal = kernelInfo->createKernelAllocation(*this->pDevice) ? CL_SUCCESS : CL_OUT_OF_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_BREAK_IF(kernelInfo->heapInfo.KernelHeapSize && !this->pDevice);
|
|
||||||
if (retVal != CL_SUCCESS) {
|
if (retVal != CL_SUCCESS) {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,16 +82,16 @@ TEST(Sip, GivenSipLlWhenGettingMetadataThenMetadataRequiredByCompilerIsReturned)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Sip, WhenGettingTypeThenCorrectTypeIsReturned) {
|
TEST(Sip, WhenGettingTypeThenCorrectTypeIsReturned) {
|
||||||
SipKernel csr{SipKernelType::Csr, GlobalMockSipProgram::getSipProgramWithCustomBinary()};
|
SipKernel csr{SipKernelType::Csr, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()};
|
||||||
EXPECT_EQ(SipKernelType::Csr, csr.getType());
|
EXPECT_EQ(SipKernelType::Csr, csr.getType());
|
||||||
|
|
||||||
SipKernel dbgCsr{SipKernelType::DbgCsr, GlobalMockSipProgram::getSipProgramWithCustomBinary()};
|
SipKernel dbgCsr{SipKernelType::DbgCsr, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()};
|
||||||
EXPECT_EQ(SipKernelType::DbgCsr, dbgCsr.getType());
|
EXPECT_EQ(SipKernelType::DbgCsr, dbgCsr.getType());
|
||||||
|
|
||||||
SipKernel dbgCsrLocal{SipKernelType::DbgCsrLocal, GlobalMockSipProgram::getSipProgramWithCustomBinary()};
|
SipKernel dbgCsrLocal{SipKernelType::DbgCsrLocal, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()};
|
||||||
EXPECT_EQ(SipKernelType::DbgCsrLocal, dbgCsrLocal.getType());
|
EXPECT_EQ(SipKernelType::DbgCsrLocal, dbgCsrLocal.getType());
|
||||||
|
|
||||||
SipKernel undefined{SipKernelType::COUNT, GlobalMockSipProgram::getSipProgramWithCustomBinary()};
|
SipKernel undefined{SipKernelType::COUNT, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()};
|
||||||
EXPECT_EQ(SipKernelType::COUNT, undefined.getType());
|
EXPECT_EQ(SipKernelType::COUNT, undefined.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,14 +29,7 @@ const SipKernel &initSipKernel(SipKernelType type, Device &device) {
|
|||||||
MockSipData::called = true;
|
MockSipData::called = true;
|
||||||
return *MockSipData::mockSipKernel;
|
return *MockSipData::mockSipKernel;
|
||||||
}
|
}
|
||||||
Program *createProgramForSip(ExecutionEnvironment &executionEnvironment,
|
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device) {
|
||||||
Context *context,
|
return GlobalMockSipProgram::getSipProgramInfo();
|
||||||
std::vector<char> &binary,
|
|
||||||
size_t size,
|
|
||||||
cl_int *errcodeRet,
|
|
||||||
Device *device) {
|
|
||||||
GlobalMockSipProgram::sipProgram->incRefApi();
|
|
||||||
GlobalMockSipProgram::sipProgram->resetAllocationState();
|
|
||||||
return GlobalMockSipProgram::sipProgram;
|
|
||||||
}
|
}
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -147,12 +147,12 @@ LONG WINAPI UltExceptionFilter(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initializeTestHelpers() {
|
void initializeTestHelpers() {
|
||||||
GlobalMockSipProgram::initSipProgram();
|
GlobalMockSipProgram::initSipProgramInfo();
|
||||||
MockSipData::mockSipKernel.reset(new MockSipKernel());
|
MockSipData::mockSipKernel.reset(new MockSipKernel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanTestHelpers() {
|
void cleanTestHelpers() {
|
||||||
GlobalMockSipProgram::shutDownSipProgram();
|
GlobalMockSipProgram::shutDownSipProgramInfo();
|
||||||
delete platformsImpl;
|
delete platformsImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,7 @@
|
|||||||
#include "opencl/test/unit_test/mocks/mock_graphics_allocation.h"
|
#include "opencl/test/unit_test/mocks/mock_graphics_allocation.h"
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
GlobalMockSipProgram *GlobalMockSipProgram::sipProgram;
|
ProgramInfo *GlobalMockSipProgram::globalSipProgramInfo;
|
||||||
ExecutionEnvironment GlobalMockSipProgram::executionEnvironment;
|
|
||||||
|
|
||||||
Device *MockProgram::getDevicePtr() { return this->pDevice; }
|
Device *MockProgram::getDevicePtr() { return this->pDevice; }
|
||||||
|
|
||||||
std::string MockProgram::getCachedFileName() const {
|
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());
|
auto internalOpts = ArrayRef<const char>(this->internalOptions.c_str(), this->internalOptions.size());
|
||||||
return CompilerCache::getCachedFileName(hwInfo, input, opts, internalOpts);
|
return CompilerCache::getCachedFileName(hwInfo, input, opts, internalOpts);
|
||||||
}
|
}
|
||||||
cl_int GlobalMockSipProgram::processGenBinary(uint32_t rootDeviceIndex) {
|
|
||||||
return CL_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
cl_int GlobalMockSipProgram::processGenBinaryOnce(uint32_t rootDeviceIndex) {
|
void GlobalMockSipProgram::initSipProgramInfo() {
|
||||||
cl_int ret = Program::processGenBinary(rootDeviceIndex);
|
globalSipProgramInfo = new ProgramInfo();
|
||||||
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;
|
|
||||||
std::vector<char> binary = MockCompilerInterface::getDummyGenBinary();
|
std::vector<char> binary = MockCompilerInterface::getDummyGenBinary();
|
||||||
executionEnvironment.prepareRootDeviceEnvironments(maxRootDeviceCount);
|
auto blob = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(binary.data()), binary.size());
|
||||||
for (auto i = 0u; i < executionEnvironment.rootDeviceEnvironments.size(); i++) {
|
SingleDeviceBinary deviceBinary = {};
|
||||||
executionEnvironment.rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
|
deviceBinary.deviceBinary = blob;
|
||||||
}
|
std::string decodeErrors;
|
||||||
executionEnvironment.calculateMaxOsContextCount();
|
std::string decodeWarnings;
|
||||||
executionEnvironment.incRefInternal();
|
|
||||||
MockDevice device(&executionEnvironment, mockRootDeviceIndex);
|
NEO::decodeSingleDeviceBinary(*globalSipProgramInfo, deviceBinary, decodeErrors, decodeWarnings);
|
||||||
sipProgram = Program::createFromGenBinary<GlobalMockSipProgram>(executionEnvironment,
|
auto sipAllocationStorage = alignedMalloc(globalSipProgramInfo->kernelInfos[0]->heapInfo.KernelHeapSize, MemoryConstants::pageSize);
|
||||||
nullptr,
|
memcpy(sipAllocationStorage, globalSipProgramInfo->kernelInfos[0]->heapInfo.pKernelHeap, globalSipProgramInfo->kernelInfos[0]->heapInfo.KernelHeapSize);
|
||||||
binary.data(),
|
globalSipProgramInfo->kernelInfos[0]->heapInfo.pKernelHeap = sipAllocationStorage;
|
||||||
binary.size(),
|
globalSipProgramInfo->kernelInfos[0]->kernelAllocation = new MockGraphicsAllocation(sipAllocationStorage, globalSipProgramInfo->kernelInfos[0]->heapInfo.KernelHeapSize);
|
||||||
true,
|
}
|
||||||
&retVal,
|
void GlobalMockSipProgram::shutDownSipProgramInfo() {
|
||||||
&device);
|
deleteAllocation();
|
||||||
DEBUG_BREAK_IF(retVal != 0);
|
delete globalSipProgramInfo;
|
||||||
sipProgram->processGenBinaryOnce(mockRootDeviceIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalMockSipProgram::resetAllocation(GraphicsAllocation *allocation) {
|
void GlobalMockSipProgram::resetAllocation(GraphicsAllocation *allocation) {
|
||||||
this->kernelInfoArray[0]->kernelAllocation = allocation;
|
globalSipProgramInfo->kernelInfos[0]->kernelAllocation = allocation;
|
||||||
}
|
}
|
||||||
GraphicsAllocation *GlobalMockSipProgram::getAllocation() {
|
GraphicsAllocation *GlobalMockSipProgram::getAllocation() {
|
||||||
return this->kernelInfoArray[0]->kernelAllocation;
|
return globalSipProgramInfo->kernelInfos[0]->kernelAllocation;
|
||||||
}
|
}
|
||||||
void GlobalMockSipProgram::deleteAllocation() {
|
void GlobalMockSipProgram::deleteAllocation() {
|
||||||
delete this->kernelInfoArray[0]->kernelAllocation;
|
auto allocation = globalSipProgramInfo->kernelInfos[0]->kernelAllocation;
|
||||||
alignedFree(sipAllocationStorage);
|
alignedFree(allocation->getUnderlyingBuffer());
|
||||||
this->kernelInfoArray[0]->kernelAllocation = nullptr;
|
delete allocation;
|
||||||
|
globalSipProgramInfo->kernelInfos[0]->kernelAllocation = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalMockSipProgram::shutDownSipProgram() {
|
void GlobalMockSipProgram::resetAllocationState() {
|
||||||
sipProgram->deleteAllocation();
|
auto allocation = static_cast<MockGraphicsAllocation *>(globalSipProgramInfo->kernelInfos[0]->kernelAllocation);
|
||||||
|
for (uint32_t index = 0u; index < allocation->usageInfos.size(); index++) {
|
||||||
delete sipProgram;
|
globalSipProgramInfo->kernelInfos[0]->kernelAllocation->releaseResidencyInOsContext(index);
|
||||||
|
}
|
||||||
|
allocation->resetInspectionIds();
|
||||||
}
|
}
|
||||||
|
ProgramInfo GlobalMockSipProgram::getSipProgramInfo() {
|
||||||
Program *GlobalMockSipProgram::getSipProgramWithCustomBinary() {
|
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;
|
NEO::PatchTokenBinary::ProgramFromPatchtokens programTokens;
|
||||||
programTokens.kernels.resize(1);
|
programTokens.kernels.resize(1);
|
||||||
|
|
||||||
@@ -113,9 +103,6 @@ Program *GlobalMockSipProgram::getSipProgramWithCustomBinary() {
|
|||||||
|
|
||||||
NEO::ProgramInfo programInfo;
|
NEO::ProgramInfo programInfo;
|
||||||
NEO::populateProgramInfo(programInfo, programTokens);
|
NEO::populateProgramInfo(programInfo, programTokens);
|
||||||
|
return programInfo;
|
||||||
Program *ret = new Program(executionEnvironment, nullptr, false, nullptr);
|
|
||||||
ret->processProgramInfo(programInfo);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -156,26 +156,17 @@ class MockProgram : public Program {
|
|||||||
int isOptionValueValidOverride = -1;
|
int isOptionValueValidOverride = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlobalMockSipProgram : public Program {
|
namespace GlobalMockSipProgram {
|
||||||
public:
|
void resetAllocationState();
|
||||||
using Program::Program;
|
void resetAllocation(GraphicsAllocation *allocation);
|
||||||
GlobalMockSipProgram(ExecutionEnvironment &executionEnvironment) : Program(executionEnvironment, nullptr, false, nullptr) {
|
void deleteAllocation();
|
||||||
}
|
GraphicsAllocation *getAllocation();
|
||||||
cl_int processGenBinary(uint32_t rootDeviceIndex) override;
|
void initSipProgramInfo();
|
||||||
cl_int processGenBinaryOnce(uint32_t rootDeviceIndex);
|
void shutDownSipProgramInfo();
|
||||||
void resetAllocationState();
|
ProgramInfo getSipProgramInfoWithCustomBinary();
|
||||||
void resetAllocation(GraphicsAllocation *allocation);
|
extern ProgramInfo *globalSipProgramInfo;
|
||||||
void deleteAllocation();
|
ProgramInfo getSipProgramInfo();
|
||||||
GraphicsAllocation *getAllocation();
|
}; // namespace GlobalMockSipProgram
|
||||||
static void initSipProgram();
|
|
||||||
static void shutDownSipProgram();
|
|
||||||
static GlobalMockSipProgram *sipProgram;
|
|
||||||
static Program *getSipProgramWithCustomBinary();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void *sipAllocationStorage;
|
|
||||||
static ExecutionEnvironment executionEnvironment;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GMockProgram : public Program {
|
class GMockProgram : public Program {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
MockSipKernel::MockSipKernel(SipKernelType type, Program *sipProgram) : SipKernel(type, sipProgram) {
|
MockSipKernel::MockSipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo) : SipKernel(type, std::move(sipProgramInfo)) {
|
||||||
this->mockSipMemoryAllocation =
|
this->mockSipMemoryAllocation =
|
||||||
std::make_unique<MemoryAllocation>(0u,
|
std::make_unique<MemoryAllocation>(0u,
|
||||||
GraphicsAllocation::AllocationType::KERNEL_ISA,
|
GraphicsAllocation::AllocationType::KERNEL_ISA,
|
||||||
@@ -34,7 +34,7 @@ MockSipKernel::MockSipKernel(SipKernelType type, Program *sipProgram) : SipKerne
|
|||||||
MemoryPool::System4KBPages, 3u);
|
MemoryPool::System4KBPages, 3u);
|
||||||
}
|
}
|
||||||
|
|
||||||
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
|
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, {}) {
|
||||||
this->mockSipMemoryAllocation =
|
this->mockSipMemoryAllocation =
|
||||||
std::make_unique<MemoryAllocation>(0u,
|
std::make_unique<MemoryAllocation>(0u,
|
||||||
GraphicsAllocation::AllocationType::KERNEL_ISA,
|
GraphicsAllocation::AllocationType::KERNEL_ISA,
|
||||||
@@ -43,7 +43,6 @@ MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
|
|||||||
0u,
|
0u,
|
||||||
MemoryConstants::pageSize,
|
MemoryConstants::pageSize,
|
||||||
MemoryPool::System4KBPages, 3u);
|
MemoryPool::System4KBPages, 3u);
|
||||||
this->program = new MockProgram(this->executionEnvironment, nullptr, false, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MockSipKernel::~MockSipKernel() = default;
|
MockSipKernel::~MockSipKernel() = default;
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ class MemoryAllocation;
|
|||||||
|
|
||||||
class MockSipKernel : public SipKernel {
|
class MockSipKernel : public SipKernel {
|
||||||
public:
|
public:
|
||||||
using SipKernel::program;
|
using SipKernel::programInfo;
|
||||||
using SipKernel::type;
|
using SipKernel::type;
|
||||||
|
|
||||||
MockSipKernel(SipKernelType type, Program *sipProgram);
|
MockSipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo);
|
||||||
MockSipKernel();
|
MockSipKernel();
|
||||||
~MockSipKernel() override;
|
~MockSipKernel() override;
|
||||||
|
|
||||||
|
|||||||
@@ -663,8 +663,8 @@ class DrmCommandStreamBatchingTests : public DrmCommandStreamEnhancedTest {
|
|||||||
void SetUpT() {
|
void SetUpT() {
|
||||||
DrmCommandStreamEnhancedTest::SetUpT<GfxFamily>();
|
DrmCommandStreamEnhancedTest::SetUpT<GfxFamily>();
|
||||||
if (PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo) == PreemptionMode::MidThread) {
|
if (PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo) == PreemptionMode::MidThread) {
|
||||||
tmpAllocation = GlobalMockSipProgram::sipProgram->getAllocation();
|
tmpAllocation = GlobalMockSipProgram::getAllocation();
|
||||||
GlobalMockSipProgram::sipProgram->resetAllocation(device->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
GlobalMockSipProgram::resetAllocation(device->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||||
}
|
}
|
||||||
tagAllocation = static_cast<DrmAllocation *>(device->getDefaultEngine().commandStreamReceiver->getTagAllocation());
|
tagAllocation = static_cast<DrmAllocation *>(device->getDefaultEngine().commandStreamReceiver->getTagAllocation());
|
||||||
preemptionAllocation = static_cast<DrmAllocation *>(device->getDefaultEngine().commandStreamReceiver->getPreemptionAllocation());
|
preemptionAllocation = static_cast<DrmAllocation *>(device->getDefaultEngine().commandStreamReceiver->getPreemptionAllocation());
|
||||||
@@ -673,8 +673,8 @@ class DrmCommandStreamBatchingTests : public DrmCommandStreamEnhancedTest {
|
|||||||
template <typename GfxFamily>
|
template <typename GfxFamily>
|
||||||
void TearDownT() {
|
void TearDownT() {
|
||||||
if (PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo) == PreemptionMode::MidThread) {
|
if (PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo) == PreemptionMode::MidThread) {
|
||||||
device->getMemoryManager()->freeGraphicsMemory((GlobalMockSipProgram::sipProgram)->getAllocation());
|
device->getMemoryManager()->freeGraphicsMemory(GlobalMockSipProgram::getAllocation());
|
||||||
GlobalMockSipProgram::sipProgram->resetAllocation(tmpAllocation);
|
GlobalMockSipProgram::resetAllocation(tmpAllocation);
|
||||||
}
|
}
|
||||||
DrmCommandStreamEnhancedTest::TearDownT<GfxFamily>();
|
DrmCommandStreamEnhancedTest::TearDownT<GfxFamily>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -806,8 +806,8 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
|||||||
GraphicsAllocation *tmpAllocation = nullptr;
|
GraphicsAllocation *tmpAllocation = nullptr;
|
||||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||||
csrSurfaceCount = 2;
|
csrSurfaceCount = 2;
|
||||||
tmpAllocation = GlobalMockSipProgram::sipProgram->getAllocation();
|
tmpAllocation = GlobalMockSipProgram::getAllocation();
|
||||||
GlobalMockSipProgram::sipProgram->resetAllocation(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
GlobalMockSipProgram::resetAllocation(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}));
|
||||||
}
|
}
|
||||||
csrSurfaceCount += csr->globalFenceAllocation ? 1 : 0;
|
csrSurfaceCount += csr->globalFenceAllocation ? 1 : 0;
|
||||||
|
|
||||||
@@ -884,8 +884,8 @@ HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmitt
|
|||||||
memoryManager->freeGraphicsMemory(sshAlloc);
|
memoryManager->freeGraphicsMemory(sshAlloc);
|
||||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||||
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
if (device->getPreemptionMode() == PreemptionMode::MidThread) {
|
||||||
memoryManager->freeGraphicsMemory(GlobalMockSipProgram::sipProgram->getAllocation());
|
memoryManager->freeGraphicsMemory(GlobalMockSipProgram::getAllocation());
|
||||||
GlobalMockSipProgram::sipProgram->resetAllocation(tmpAllocation);
|
GlobalMockSipProgram::resetAllocation(tmpAllocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,14 @@
|
|||||||
#include "opencl/source/platform/platform.h"
|
#include "opencl/source/platform/platform.h"
|
||||||
#include "opencl/test/unit_test/mocks/mock_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) {
|
void NEO::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) {
|
||||||
|
GlobalMockSipProgram::resetAllocationState();
|
||||||
referencedHwInfo = *defaultHwInfo;
|
referencedHwInfo = *defaultHwInfo;
|
||||||
auto executionEnvironment = constructPlatform()->peekExecutionEnvironment();
|
auto executionEnvironment = constructPlatform()->peekExecutionEnvironment();
|
||||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "shared/source/built_ins/sip.h"
|
#include "shared/source/built_ins/sip.h"
|
||||||
#include "shared/source/compiler_interface/compiler_interface.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/basic_math.h"
|
||||||
#include "shared/source/helpers/debug_helpers.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 &sipBuiltIn = this->sipKernels[kernelId];
|
||||||
|
|
||||||
auto initializer = [&] {
|
auto initializer = [&] {
|
||||||
int retVal = 0;
|
|
||||||
|
|
||||||
std::vector<char> sipBinary;
|
std::vector<char> sipBinary;
|
||||||
auto compilerInteface = device.getCompilerInterface();
|
auto compilerInteface = device.getCompilerInterface();
|
||||||
UNRECOVERABLE_IF(compilerInteface == nullptr);
|
UNRECOVERABLE_IF(compilerInteface == nullptr);
|
||||||
@@ -45,19 +44,10 @@ const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) {
|
|||||||
|
|
||||||
UNRECOVERABLE_IF(ret != TranslationOutput::ErrorCode::Success);
|
UNRECOVERABLE_IF(ret != TranslationOutput::ErrorCode::Success);
|
||||||
UNRECOVERABLE_IF(sipBinary.size() == 0);
|
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());
|
ProgramInfo programInfo = createProgramInfoForSip(sipBinary, sipBinary.size(), device);
|
||||||
DEBUG_BREAK_IF(retVal != 0);
|
|
||||||
|
|
||||||
sipBuiltIn.first.reset(new SipKernel(type, program));
|
sipBuiltIn.first.reset(new SipKernel(type, std::move(programInfo)));
|
||||||
};
|
};
|
||||||
std::call_once(sipBuiltIn.second, initializer);
|
std::call_once(sipBuiltIn.second, initializer);
|
||||||
UNRECOVERABLE_IF(sipBuiltIn.first == nullptr);
|
UNRECOVERABLE_IF(sipBuiltIn.first == nullptr);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||||
|
|
||||||
#include "opencl/source/program/kernel_info.h"
|
#include "opencl/source/program/kernel_info.h"
|
||||||
#include "opencl/source/program/program.h"
|
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
@@ -68,24 +67,20 @@ const char *getSipLlSrc(const Device &device) {
|
|||||||
return (ptrSize == 8) ? llDummySrc64 : llDummySrc32;
|
return (ptrSize == 8) ? llDummySrc64 : llDummySrc32;
|
||||||
}
|
}
|
||||||
|
|
||||||
SipKernel::SipKernel(SipKernelType type, Program *sipProgram)
|
SipKernel::SipKernel(SipKernelType type, ProgramInfo &&sipProgram)
|
||||||
: type(type) {
|
: type(type), programInfo(std::move(sipProgram)) {}
|
||||||
program = sipProgram;
|
SipKernel::~SipKernel() = default;
|
||||||
}
|
|
||||||
SipKernel::~SipKernel() {
|
|
||||||
program->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
GraphicsAllocation *SipKernel::getSipAllocation() const {
|
GraphicsAllocation *SipKernel::getSipAllocation() const {
|
||||||
return program->getKernelInfo(size_t{0})->getGraphicsAllocation();
|
return programInfo.kernelInfos[0]->getGraphicsAllocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SipKernel::getBinary() const {
|
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));
|
return reinterpret_cast<const char *>(ptrOffset(kernelInfo->heapInfo.pKernelHeap, kernelInfo->systemKernelOffset));
|
||||||
}
|
}
|
||||||
size_t SipKernel::getBinarySize() const {
|
size_t SipKernel::getBinarySize() const {
|
||||||
auto kernelInfo = program->getKernelInfo(size_t{0});
|
auto kernelInfo = programInfo.kernelInfos[0];
|
||||||
return kernelInfo->heapInfo.KernelHeapSize - kernelInfo->systemKernelOffset;
|
return kernelInfo->heapInfo.KernelHeapSize - kernelInfo->systemKernelOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "shared/source/built_ins/sip_kernel_type.h"
|
#include "shared/source/built_ins/sip_kernel_type.h"
|
||||||
#include "shared/source/helpers/hw_info.h"
|
#include "shared/source/helpers/hw_info.h"
|
||||||
|
#include "shared/source/program/program_info.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
class Program;
|
|
||||||
class GraphicsAllocation;
|
class GraphicsAllocation;
|
||||||
|
|
||||||
const char *getSipKernelCompilerInternalOptions(SipKernelType kernel);
|
const char *getSipKernelCompilerInternalOptions(SipKernelType kernel);
|
||||||
@@ -23,11 +23,11 @@ const char *getSipLlSrc(const Device &device);
|
|||||||
|
|
||||||
class SipKernel {
|
class SipKernel {
|
||||||
public:
|
public:
|
||||||
SipKernel(SipKernelType type, Program *sipProgram);
|
SipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo);
|
||||||
SipKernel(const SipKernel &) = delete;
|
SipKernel(const SipKernel &) = delete;
|
||||||
SipKernel &operator=(const SipKernel &) = delete;
|
SipKernel &operator=(const SipKernel &) = delete;
|
||||||
SipKernel(SipKernel &&) = default;
|
SipKernel(SipKernel &&) = delete;
|
||||||
SipKernel &operator=(SipKernel &&) = default;
|
SipKernel &operator=(SipKernel &&) = delete;
|
||||||
virtual ~SipKernel();
|
virtual ~SipKernel();
|
||||||
|
|
||||||
const char *getBinary() const;
|
const char *getBinary() const;
|
||||||
@@ -46,6 +46,6 @@ class SipKernel {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
SipKernelType type = SipKernelType::COUNT;
|
SipKernelType type = SipKernelType::COUNT;
|
||||||
Program *program = nullptr;
|
const ProgramInfo programInfo;
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -433,12 +433,12 @@ int main(int argc, char **argv) {
|
|||||||
GmmInterface::initialize(nullptr, nullptr);
|
GmmInterface::initialize(nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalMockSipProgram::initSipProgram();
|
GlobalMockSipProgram::initSipProgramInfo();
|
||||||
NEO::MockSipData::mockSipKernel.reset(new NEO::MockSipKernel());
|
NEO::MockSipData::mockSipKernel.reset(new NEO::MockSipKernel());
|
||||||
|
|
||||||
retVal = RUN_ALL_TESTS();
|
retVal = RUN_ALL_TESTS();
|
||||||
|
|
||||||
GlobalMockSipProgram::shutDownSipProgram();
|
GlobalMockSipProgram::shutDownSipProgramInfo();
|
||||||
delete platformsImpl;
|
delete platformsImpl;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ HWTEST_P(PreemptionHwTest, GivenPreemptionModeIsNotChangingWhenGettingRequiredCm
|
|||||||
{
|
{
|
||||||
auto builtIns = new MockBuiltins();
|
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);
|
mockDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->builtins.reset(builtIns);
|
||||||
PreemptionHelper::programCmdStream<FamilyType>(cmdStream, mode, mode, nullptr);
|
PreemptionHelper::programCmdStream<FamilyType>(cmdStream, mode, mode, nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user