Refactor Sip Kernel usage

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-12-02 10:22:27 +00:00
committed by Compute-Runtime-Automation
parent da779d067f
commit 8198a739c8
30 changed files with 190 additions and 251 deletions

View File

@@ -7,13 +7,17 @@
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h" #include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
#include "opencl/source/helpers/built_ins_helper.h" #include "shared/source/built_ins/sip.h"
namespace L0 { namespace L0 {
namespace ult { namespace ult {
const NEO::SipKernel &MockBuiltins::getSipKernel(NEO::SipKernelType type, NEO::Device &device) { const NEO::SipKernel &MockBuiltins::getSipKernel(NEO::SipKernelType type, NEO::Device &device) {
return NEO::initSipKernel(type, device); if (!(sipKernel && sipKernel->getType() == type)) {
sipKernel.reset(new NEO::SipKernel(type, allocation.get()));
}
return *sipKernel;
} }
} // namespace ult } // namespace ult

View File

@@ -7,13 +7,19 @@
#pragma once #pragma once
#include "shared/source/built_ins/built_ins.h" #include "shared/source/built_ins/built_ins.h"
#include "shared/test/unit_test/mocks/mock_graphics_allocation.h"
namespace L0 { namespace L0 {
namespace ult { namespace ult {
class MockBuiltins : public NEO::BuiltIns { class MockBuiltins : public NEO::BuiltIns {
public: public:
MockBuiltins() : BuiltIns() {
allocation.reset(new NEO::MockGraphicsAllocation());
}
const NEO::SipKernel &getSipKernel(NEO::SipKernelType type, NEO::Device &device) override; const NEO::SipKernel &getSipKernel(NEO::SipKernelType type, NEO::Device &device) override;
std::unique_ptr<NEO::SipKernel> sipKernel;
std::unique_ptr<NEO::MockGraphicsAllocation> allocation;
}; };
} // namespace ult } // namespace ult
} // namespace L0 } // namespace L0

View File

@@ -8,6 +8,7 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_1.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_3.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_api.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_api.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_barrier.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_barrier.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_event_reset.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_event_reset.cpp

View File

@@ -1114,72 +1114,5 @@ HWTEST2_F(CommandListCreate, givenHostAllocInMapWhenPtrLowerThanAnyInMapThenNull
commandList->hostPtrMap.clear(); commandList->hostPtrMap.clear();
} }
struct MemoryManagerCommandListCreateNegativeTest : public NEO::MockMemoryManager {
MemoryManagerCommandListCreateNegativeTest(NEO::ExecutionEnvironment &executionEnvironment) : NEO::MockMemoryManager(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
NEO::GraphicsAllocation *allocateGraphicsMemoryWithProperties(const NEO::AllocationProperties &properties) override {
if (forceFailureInPrimaryAllocation) {
return nullptr;
}
return NEO::MemoryManager::allocateGraphicsMemoryWithProperties(properties);
}
bool forceFailureInPrimaryAllocation = false;
};
struct CommandListCreateNegativeTest : public ::testing::Test {
void SetUp() override {
executionEnvironment = new NEO::ExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(numRootDevices);
for (uint32_t i = 0; i < numRootDevices; i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(NEO::defaultHwInfo.get());
}
memoryManager = new MemoryManagerCommandListCreateNegativeTest(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
std::vector<std::unique_ptr<NEO::Device>> devices;
for (uint32_t i = 0; i < numRootDevices; i++) {
neoDevice = NEO::MockDevice::create<NEO::MockDevice>(executionEnvironment, i);
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
}
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
driverHandle->initialize(std::move(devices));
device = driverHandle->devices[0];
}
void TearDown() override {
}
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
NEO::MockDevice *neoDevice = nullptr;
L0::Device *device = nullptr;
MemoryManagerCommandListCreateNegativeTest *memoryManager = nullptr;
const uint32_t numRootDevices = 1u;
};
TEST_F(CommandListCreateNegativeTest, whenDeviceAllocationFailsDuringCommandListCreateThenAppropriateValueIsReturned) {
ze_result_t returnValue;
memoryManager->forceFailureInPrimaryAllocation = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue));
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, returnValue);
ASSERT_EQ(nullptr, commandList);
}
TEST_F(CommandListCreateNegativeTest, whenDeviceAllocationFailsDuringCommandListImmediateCreateThenAppropriateValueIsReturned) {
ze_result_t returnValue;
const ze_command_queue_desc_t desc = {};
bool internalEngine = true;
memoryManager->forceFailureInPrimaryAllocation = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily,
device,
&desc,
internalEngine,
NEO::EngineGroupType::RenderCompute,
returnValue));
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, returnValue);
ASSERT_EQ(nullptr, commandList);
}
} // namespace ult } // namespace ult
} // namespace L0 } // namespace L0

View File

@@ -0,0 +1,84 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
#include "test.h"
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h"
namespace L0 {
namespace ult {
struct MemoryManagerCommandListCreateNegativeTest : public NEO::MockMemoryManager {
MemoryManagerCommandListCreateNegativeTest(NEO::ExecutionEnvironment &executionEnvironment) : NEO::MockMemoryManager(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
NEO::GraphicsAllocation *allocateGraphicsMemoryWithProperties(const NEO::AllocationProperties &properties) override {
if (forceFailureInPrimaryAllocation) {
return nullptr;
}
return NEO::MemoryManager::allocateGraphicsMemoryWithProperties(properties);
}
bool forceFailureInPrimaryAllocation = false;
};
struct CommandListCreateNegativeTest : public ::testing::Test {
void SetUp() override {
executionEnvironment = new NEO::ExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(numRootDevices);
for (uint32_t i = 0; i < numRootDevices; i++) {
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(NEO::defaultHwInfo.get());
}
memoryManager = new MemoryManagerCommandListCreateNegativeTest(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
std::vector<std::unique_ptr<NEO::Device>> devices;
for (uint32_t i = 0; i < numRootDevices; i++) {
neoDevice = NEO::MockDevice::create<NEO::MockDevice>(executionEnvironment, i);
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
}
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
driverHandle->initialize(std::move(devices));
device = driverHandle->devices[0];
}
void TearDown() override {
}
NEO::ExecutionEnvironment *executionEnvironment = nullptr;
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
NEO::MockDevice *neoDevice = nullptr;
L0::Device *device = nullptr;
MemoryManagerCommandListCreateNegativeTest *memoryManager = nullptr;
const uint32_t numRootDevices = 1u;
};
TEST_F(CommandListCreateNegativeTest, whenDeviceAllocationFailsDuringCommandListCreateThenAppropriateValueIsReturned) {
ze_result_t returnValue;
memoryManager->forceFailureInPrimaryAllocation = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue));
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, returnValue);
ASSERT_EQ(nullptr, commandList);
}
TEST_F(CommandListCreateNegativeTest, whenDeviceAllocationFailsDuringCommandListImmediateCreateThenAppropriateValueIsReturned) {
ze_result_t returnValue;
const ze_command_queue_desc_t desc = {};
bool internalEngine = true;
memoryManager->forceFailureInPrimaryAllocation = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily,
device,
&desc,
internalEngine,
NEO::EngineGroupType::RenderCompute,
returnValue));
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, returnValue);
ASSERT_EQ(nullptr, commandList);
}
} // namespace ult
} // namespace L0

View File

@@ -10,29 +10,8 @@
#include "shared/source/device/device.h" #include "shared/source/device/device.h"
#include "shared/source/device_binary_format/device_binary_formats.h" #include "shared/source/device_binary_format/device_binary_formats.h"
#include "opencl/source/program/kernel_info.h"
namespace NEO { namespace NEO {
const SipKernel &initSipKernel(SipKernelType type, Device &device) { void initSipKernel(SipKernelType type, Device &device) {
return device.getBuiltIns()->getSipKernel(type, device); device.getBuiltIns()->getSipKernel(type, device);
}
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device) {
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, true);
UNRECOVERABLE_IF(!success);
return programInfo;
} }
} // namespace NEO } // namespace NEO

View File

@@ -12,6 +12,6 @@
namespace NEO { namespace NEO {
class Device; class Device;
const SipKernel &initSipKernel(SipKernelType type, Device &device); void initSipKernel(SipKernelType type, Device &device);
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device);
} // namespace NEO } // namespace NEO

View File

@@ -2005,28 +2005,31 @@ TEST_F(BuiltInTests, GivenInvalidBuiltinKernelNameWhenCreatingBuiltInProgramThen
} }
TEST_F(BuiltInTests, WhenGettingSipKernelThenReturnProgramCreatedFromIsaAcquiredThroughCompilerInterface) { TEST_F(BuiltInTests, WhenGettingSipKernelThenReturnProgramCreatedFromIsaAcquiredThroughCompilerInterface) {
MockBuiltins mockBuiltins;
auto mockCompilerInterface = new MockCompilerInterface(); auto mockCompilerInterface = new MockCompilerInterface();
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->compilerInterface.reset(mockCompilerInterface); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->compilerInterface.reset(mockCompilerInterface);
auto builtins = new BuiltIns;
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->builtins.reset(builtins);
mockCompilerInterface->sipKernelBinaryOverride = mockCompilerInterface->getDummyGenBinary(); mockCompilerInterface->sipKernelBinaryOverride = mockCompilerInterface->getDummyGenBinary();
cl_int errCode = CL_BUILD_PROGRAM_FAILURE; cl_int errCode = CL_BUILD_PROGRAM_FAILURE;
auto p = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), mockCompilerInterface->sipKernelBinaryOverride.data(), mockCompilerInterface->sipKernelBinaryOverride.size(), &errCode); auto p = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), mockCompilerInterface->sipKernelBinaryOverride.data(), mockCompilerInterface->sipKernelBinaryOverride.size(), &errCode);
ASSERT_EQ(CL_SUCCESS, errCode); ASSERT_EQ(CL_SUCCESS, errCode);
errCode = p->processGenBinary(*pClDevice); errCode = p->processGenBinary(*pClDevice);
ASSERT_EQ(CL_SUCCESS, errCode); ASSERT_EQ(CL_SUCCESS, errCode);
const SipKernel &sipKern = mockBuiltins.getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice());
const auto &sipKernelInfo = p->getKernelInfo(static_cast<size_t>(0), rootDeviceIndex); const auto &sipKernelInfo = p->getKernelInfo(static_cast<size_t>(0), rootDeviceIndex);
auto compbinedKernelHeapSize = sipKernelInfo->heapInfo.KernelHeapSize; auto compbinedKernelHeapSize = sipKernelInfo->heapInfo.KernelHeapSize;
auto sipOffset = sipKernelInfo->systemKernelOffset; auto sipOffset = sipKernelInfo->systemKernelOffset;
ASSERT_GT(compbinedKernelHeapSize, sipOffset); ASSERT_GT(compbinedKernelHeapSize, sipOffset);
const SipKernel &sipKernel = builtins->getSipKernel(SipKernelType::Csr, *pDevice);
auto expectedMem = reinterpret_cast<const char *>(sipKernelInfo->heapInfo.pKernelHeap) + sipOffset; auto expectedMem = reinterpret_cast<const char *>(sipKernelInfo->heapInfo.pKernelHeap) + sipOffset;
ASSERT_EQ(compbinedKernelHeapSize - sipOffset, sipKern.getBinarySize()); EXPECT_EQ(0, memcmp(expectedMem, sipKernel.getSipAllocation()->getUnderlyingBuffer(), compbinedKernelHeapSize - sipOffset));
EXPECT_EQ(0, memcmp(expectedMem, sipKern.getBinary(), sipKern.getBinarySize()));
EXPECT_EQ(SipKernelType::Csr, mockCompilerInterface->requestedSipKernel); EXPECT_EQ(SipKernelType::Csr, mockCompilerInterface->requestedSipKernel);
p->release(); p->release();
mockCompilerInterface->releaseDummyGenBinary();
} }
TEST_F(BuiltInTests, givenSipKernelWhenItIsCreatedThenItHasGraphicsAllocationForKernel) { TEST_F(BuiltInTests, givenSipKernelWhenItIsCreatedThenItHasGraphicsAllocationForKernel) {

View File

@@ -82,16 +82,16 @@ TEST(Sip, GivenSipLlWhenGettingMetadataThenMetadataRequiredByCompilerIsReturned)
} }
TEST(Sip, WhenGettingTypeThenCorrectTypeIsReturned) { TEST(Sip, WhenGettingTypeThenCorrectTypeIsReturned) {
SipKernel csr{SipKernelType::Csr, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()}; SipKernel csr{SipKernelType::Csr, nullptr};
EXPECT_EQ(SipKernelType::Csr, csr.getType()); EXPECT_EQ(SipKernelType::Csr, csr.getType());
SipKernel dbgCsr{SipKernelType::DbgCsr, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()}; SipKernel dbgCsr{SipKernelType::DbgCsr, nullptr};
EXPECT_EQ(SipKernelType::DbgCsr, dbgCsr.getType()); EXPECT_EQ(SipKernelType::DbgCsr, dbgCsr.getType());
SipKernel dbgCsrLocal{SipKernelType::DbgCsrLocal, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()}; SipKernel dbgCsrLocal{SipKernelType::DbgCsrLocal, nullptr};
EXPECT_EQ(SipKernelType::DbgCsrLocal, dbgCsrLocal.getType()); EXPECT_EQ(SipKernelType::DbgCsrLocal, dbgCsrLocal.getType());
SipKernel undefined{SipKernelType::COUNT, GlobalMockSipProgram::getSipProgramInfoWithCustomBinary()}; SipKernel undefined{SipKernelType::COUNT, nullptr};
EXPECT_EQ(SipKernelType::COUNT, undefined.getType()); EXPECT_EQ(SipKernelType::COUNT, undefined.getType());
} }

View File

@@ -23,13 +23,9 @@ SipKernelType calledType = SipKernelType::COUNT;
bool called = false; bool called = false;
} // namespace MockSipData } // namespace MockSipData
const SipKernel &initSipKernel(SipKernelType type, Device &device) { void initSipKernel(SipKernelType type, Device &device) {
MockSipData::calledType = type; MockSipData::calledType = type;
MockSipData::mockSipKernel->type = type;
MockSipData::called = true; MockSipData::called = true;
return *MockSipData::mockSipKernel;
}
ProgramInfo createProgramInfoForSip(std::vector<char> &binary, size_t size, const Device &device) {
return GlobalMockSipProgram::getSipProgramInfo();
} }
} // namespace NEO } // namespace NEO

View File

@@ -113,6 +113,11 @@ void applyWorkarounds() {
}); });
tempThreadID = t.get_id(); tempThreadID = t.get_id();
t.join(); t.join();
//Create FileLogger to prevent false memory leaks
{
NEO::FileLoggerInstance();
}
} }
#ifdef __linux__ #ifdef __linux__
void handle_SIGALRM(int signal) { void handle_SIGALRM(int signal) {
@@ -148,12 +153,10 @@ LONG WINAPI UltExceptionFilter(
#endif #endif
void initializeTestHelpers() { void initializeTestHelpers() {
GlobalMockSipProgram::initSipProgramInfo();
MockSipData::mockSipKernel.reset(new MockSipKernel()); MockSipData::mockSipKernel.reset(new MockSipKernel());
} }
void cleanTestHelpers() { void cleanTestHelpers() {
GlobalMockSipProgram::shutDownSipProgramInfo();
delete platformsImpl; delete platformsImpl;
} }

View File

@@ -11,7 +11,7 @@
#include "shared/source/built_ins/sip.h" #include "shared/source/built_ins/sip.h"
#include "opencl/source/built_ins/builtins_dispatch_builder.h" #include "opencl/source/built_ins/builtins_dispatch_builder.h"
#include "opencl/source/program/program.h" #include "opencl/test/unit_test/mocks/mock_sip.h"
#include <memory> #include <memory>
@@ -24,14 +24,14 @@ class MockBuiltins : public BuiltIns {
} }
getSipKernelCalled = true; getSipKernelCalled = true;
getSipKernelType = type; getSipKernelType = type;
return BuiltIns::getSipKernel(type, device); MockSipData::mockSipKernel->type = type;
return *MockSipData::mockSipKernel;
} }
void overrideSipKernel(std::unique_ptr<SipKernel> kernel) { void overrideSipKernel(std::unique_ptr<SipKernel> kernel) {
sipKernelsOverride[kernel->getType()] = std::move(kernel); sipKernelsOverride[kernel->getType()] = std::move(kernel);
} }
std::unique_ptr<BuiltinDispatchInfoBuilder> setBuiltinDispatchInfoBuilder(EBuiltInOps::Type operation, Context &context, Device &device, std::unique_ptr<BuiltinDispatchInfoBuilder> builder); std::unique_ptr<BuiltinDispatchInfoBuilder> setBuiltinDispatchInfoBuilder(EBuiltInOps::Type operation, Context &context, Device &device, std::unique_ptr<BuiltinDispatchInfoBuilder> builder);
BuiltIns *originalGlobalBuiltins = nullptr;
std::map<SipKernelType, std::unique_ptr<SipKernel>> sipKernelsOverride; std::map<SipKernelType, std::unique_ptr<SipKernel>> sipKernelsOverride;
bool getSipKernelCalled = false; bool getSipKernelCalled = false;
SipKernelType getSipKernelType = SipKernelType::COUNT; SipKernelType getSipKernelType = SipKernelType::COUNT;

View File

@@ -628,4 +628,8 @@ IGC::FclOclTranslationCtxBase *MockFclOclDeviceCtx::CreateTranslationCtxImpl(CIF
std::vector<char> MockCompilerInterface::getDummyGenBinary() { std::vector<char> MockCompilerInterface::getDummyGenBinary() {
return MockSipKernel::getDummyGenBinary(); return MockSipKernel::getDummyGenBinary();
} }
void MockCompilerInterface::releaseDummyGenBinary() {
MockSipKernel::shutDown();
}
} // namespace NEO } // namespace NEO

View File

@@ -33,6 +33,7 @@ struct MockCompilerDebugVars {
bool failCreatePlatformInterface = false; bool failCreatePlatformInterface = false;
bool failCreateGtSystemInfoInterface = false; bool failCreateGtSystemInfoInterface = false;
bool failCreateIgcFeWaInterface = false; bool failCreateIgcFeWaInterface = false;
IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine = IGC::SystemRoutineType::undefined;
std::string *receivedInternalOptionsOutput = nullptr; std::string *receivedInternalOptionsOutput = nullptr;
std::string *receivedInput = nullptr; std::string *receivedInput = nullptr;

View File

@@ -28,7 +28,7 @@ ClDeviceVector toClDeviceVector(ClDevice &clDevice) {
deviceVector.push_back(&clDevice); deviceVector.push_back(&clDevice);
return deviceVector; return deviceVector;
} }
ProgramInfo *GlobalMockSipProgram::globalSipProgramInfo;
int MockProgram::initInternalOptionsCalled = 0; int MockProgram::initInternalOptionsCalled = 0;
std::string MockProgram::getCachedFileName() const { std::string MockProgram::getCachedFileName() const {
@@ -40,75 +40,4 @@ std::string MockProgram::getCachedFileName() const {
return CompilerCache::getCachedFileName(hwInfo, input, opts, internalOpts); return CompilerCache::getCachedFileName(hwInfo, input, opts, internalOpts);
} }
void GlobalMockSipProgram::initSipProgramInfo() {
globalSipProgramInfo = new ProgramInfo();
std::vector<char> binary = MockCompilerInterface::getDummyGenBinary();
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) {
globalSipProgramInfo->kernelInfos[0]->kernelAllocation = allocation;
}
GraphicsAllocation *GlobalMockSipProgram::getAllocation() {
return globalSipProgramInfo->kernelInfos[0]->kernelAllocation;
}
void GlobalMockSipProgram::deleteAllocation() {
auto allocation = globalSipProgramInfo->kernelInfos[0]->kernelAllocation;
alignedFree(allocation->getUnderlyingBuffer());
delete allocation;
globalSipProgramInfo->kernelInfos[0]->kernelAllocation = nullptr;
}
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();
}
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);
const uint8_t isa[] = "kernel morphEUs()";
const char name[] = "sip";
SProgramBinaryHeader progHeader = {};
progHeader.NumberOfKernels = 1;
SKernelBinaryHeaderCommon kernHeader = {};
kernHeader.KernelNameSize = sizeof(name);
kernHeader.KernelHeapSize = sizeof(isa);
kernHeader.KernelUnpaddedSize = sizeof(isa);
programTokens.header = &progHeader;
programTokens.kernels[0].header = &kernHeader;
programTokens.kernels[0].isa = isa;
programTokens.kernels[0].name = name;
NEO::ProgramInfo programInfo;
NEO::populateProgramInfo(programInfo, programTokens);
return programInfo;
}
} // namespace NEO } // namespace NEO

View File

@@ -178,18 +178,6 @@ class MockProgram : public Program {
int isOptionValueValidOverride = -1; int isOptionValueValidOverride = -1;
}; };
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 { class GMockProgram : public Program {
public: public:
using Program::Program; using Program::Program;

View File

@@ -23,7 +23,7 @@
#include <map> #include <map>
namespace NEO { namespace NEO {
MockSipKernel::MockSipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo) : SipKernel(type, std::move(sipProgramInfo)) { MockSipKernel::MockSipKernel(SipKernelType type, GraphicsAllocation *sipAlloc) : SipKernel(type, sipAlloc) {
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, ProgramInfo &&sipProgramInfo) :
MemoryPool::System4KBPages, 3u); MemoryPool::System4KBPages, 3u);
} }
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, {}) { MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
this->mockSipMemoryAllocation = this->mockSipMemoryAllocation =
std::make_unique<MemoryAllocation>(0u, std::make_unique<MemoryAllocation>(0u,
GraphicsAllocation::AllocationType::KERNEL_ISA, GraphicsAllocation::AllocationType::KERNEL_ISA,
@@ -71,6 +71,7 @@ void MockSipKernel::initDummyBinary() {
} }
void MockSipKernel::shutDown() { void MockSipKernel::shutDown() {
MockSipKernel::dummyBinaryForSip.clear(); MockSipKernel::dummyBinaryForSip.clear();
std::vector<char>().swap(MockSipKernel::dummyBinaryForSip);
} }
GraphicsAllocation *MockSipKernel::getSipAllocation() const { GraphicsAllocation *MockSipKernel::getSipAllocation() const {

View File

@@ -19,10 +19,9 @@ class MemoryAllocation;
class MockSipKernel : public SipKernel { class MockSipKernel : public SipKernel {
public: public:
using SipKernel::programInfo;
using SipKernel::type; using SipKernel::type;
MockSipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo); MockSipKernel(SipKernelType type, GraphicsAllocation *sipAlloc);
MockSipKernel(); MockSipKernel();
~MockSipKernel() override; ~MockSipKernel() override;
@@ -37,4 +36,10 @@ class MockSipKernel : public SipKernel {
std::unique_ptr<MemoryAllocation> mockSipMemoryAllocation; std::unique_ptr<MemoryAllocation> mockSipMemoryAllocation;
MockExecutionEnvironment executionEnvironment; MockExecutionEnvironment executionEnvironment;
}; };
namespace MockSipData {
extern std::unique_ptr<MockSipKernel> mockSipKernel;
extern SipKernelType calledType;
extern bool called;
} // namespace MockSipData
} // namespace NEO } // namespace NEO

View File

@@ -659,25 +659,16 @@ class DrmCommandStreamBatchingTests : public DrmCommandStreamEnhancedTest {
public: public:
DrmAllocation *tagAllocation; DrmAllocation *tagAllocation;
DrmAllocation *preemptionAllocation; DrmAllocation *preemptionAllocation;
GraphicsAllocation *tmpAllocation;
template <typename GfxFamily> template <typename GfxFamily>
void SetUpT() { void SetUpT() {
DrmCommandStreamEnhancedTest::SetUpT<GfxFamily>(); DrmCommandStreamEnhancedTest::SetUpT<GfxFamily>();
if (PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo) == PreemptionMode::MidThread) {
tmpAllocation = GlobalMockSipProgram::getAllocation();
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());
} }
template <typename GfxFamily> template <typename GfxFamily>
void TearDownT() { void TearDownT() {
if (PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo) == PreemptionMode::MidThread) {
device->getMemoryManager()->freeGraphicsMemory(GlobalMockSipProgram::getAllocation());
GlobalMockSipProgram::resetAllocation(tmpAllocation);
}
DrmCommandStreamEnhancedTest::TearDownT<GfxFamily>(); DrmCommandStreamEnhancedTest::TearDownT<GfxFamily>();
} }
}; };
@@ -789,7 +780,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamBatchingTests, givenCsrWhenDispatchPolicyIsSe
EXPECT_EQ(testedCsr->commandStream.getGraphicsAllocation(), recordedCmdBuffer->batchBuffer.commandBufferAllocation); EXPECT_EQ(testedCsr->commandStream.getGraphicsAllocation(), recordedCmdBuffer->batchBuffer.commandBufferAllocation);
int ioctlUserPtrCnt = 3; int ioctlUserPtrCnt = (device->getPreemptionMode() == PreemptionMode::MidThread) ? 4 : 3;
EXPECT_EQ(ioctlUserPtrCnt, this->mock->ioctl_cnt.total); EXPECT_EQ(ioctlUserPtrCnt, this->mock->ioctl_cnt.total);
EXPECT_EQ(ioctlUserPtrCnt, this->mock->ioctl_cnt.gemUserptr); EXPECT_EQ(ioctlUserPtrCnt, this->mock->ioctl_cnt.gemUserptr);
@@ -864,7 +855,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhen
} }
int ioctlExecCnt = 1; int ioctlExecCnt = 1;
int ioctlUserPtrCnt = 2; int ioctlUserPtrCnt = (device->getPreemptionMode() == PreemptionMode::MidThread) ? 3 : 2;
EXPECT_EQ(ioctlExecCnt, this->mock->ioctl_cnt.execbuffer2); EXPECT_EQ(ioctlExecCnt, this->mock->ioctl_cnt.execbuffer2);
EXPECT_EQ(ioctlUserPtrCnt, this->mock->ioctl_cnt.gemUserptr); EXPECT_EQ(ioctlUserPtrCnt, this->mock->ioctl_cnt.gemUserptr);
EXPECT_EQ(ioctlExecCnt + ioctlUserPtrCnt, this->mock->ioctl_cnt.total); EXPECT_EQ(ioctlExecCnt + ioctlUserPtrCnt, this->mock->ioctl_cnt.total);

View File

@@ -13,6 +13,7 @@
#include "opencl/test/unit_test/fixtures/memory_management_fixture.h" #include "opencl/test/unit_test/fixtures/memory_management_fixture.h"
#include "opencl/test/unit_test/mocks/linux/mock_drm_command_stream_receiver.h" #include "opencl/test/unit_test/mocks/linux/mock_drm_command_stream_receiver.h"
#include "opencl/test/unit_test/mocks/mock_builtins.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h" #include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_execution_environment.h" #include "opencl/test/unit_test/mocks/mock_execution_environment.h"
#include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture.h" #include "opencl/test/unit_test/os_interface/linux/device_command_stream_fixture.h"
@@ -61,6 +62,7 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>(); rootDeviceEnvironment->osInterface = std::make_unique<OSInterface>();
rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom()); rootDeviceEnvironment->osInterface->get()->setDrm(new DrmMockCustom());
rootDeviceEnvironment->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*rootDeviceEnvironment->osInterface->get()->getDrm(), i); rootDeviceEnvironment->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*rootDeviceEnvironment->osInterface->get()->getDrm(), i);
rootDeviceEnvironment->builtins.reset(new MockBuiltins);
} }
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get(); rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex].get();

View File

@@ -810,11 +810,11 @@ TEST_F(WddmCommandStreamMockGdiTest, WhenMakingResidentThenResidencyAllocationsL
HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmittedThenFlushTaskIsProperlyCalled) { HWTEST_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenItIsSubmittedThenFlushTaskIsProperlyCalled) {
//preemption allocation + sip allocation //preemption allocation + sip allocation
size_t csrSurfaceCount = 0; size_t csrSurfaceCount = 0;
GraphicsAllocation *tmpAllocation = nullptr; //GraphicsAllocation *tmpAllocation = nullptr;
if (device->getPreemptionMode() == PreemptionMode::MidThread) { if (device->getPreemptionMode() == PreemptionMode::MidThread) {
csrSurfaceCount = 2; csrSurfaceCount = 2;
tmpAllocation = GlobalMockSipProgram::getAllocation(); //tmpAllocation = GlobalMockSipProgram::getAllocation();
GlobalMockSipProgram::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;
@@ -891,8 +891,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::getAllocation()); // memoryManager->freeGraphicsMemory(GlobalMockSipProgram::getAllocation());
GlobalMockSipProgram::resetAllocation(tmpAllocation); // GlobalMockSipProgram::resetAllocation(tmpAllocation);
} }
} }

View File

@@ -17,14 +17,7 @@
#include "third_party/aub_stream/headers/aubstream.h" #include "third_party/aub_stream/headers/aubstream.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);

View File

@@ -12,6 +12,7 @@
#include "shared/source/device_binary_format/device_binary_formats.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"
#include "shared/source/memory_manager/memory_manager.h"
#include "opencl/source/helpers/built_ins_helper.h" #include "opencl/source/helpers/built_ins_helper.h"
#include "opencl/source/helpers/convert_color.h" #include "opencl/source/helpers/convert_color.h"
@@ -45,13 +46,35 @@ 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);
ProgramInfo programInfo = createProgramInfoForSip(sipBinary, sipBinary.size(), device); ProgramInfo programInfo;
auto blob = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(sipBinary.data()), sipBinary.size());
SingleDeviceBinary deviceBinary = {};
deviceBinary.deviceBinary = blob;
std::string decodeErrors;
std::string decodeWarnings;
sipBuiltIn.first.reset(new SipKernel(type, std::move(programInfo))); 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, true);
UNRECOVERABLE_IF(!success);
sipBuiltIn.first.reset(new SipKernel(type, programInfo.kernelInfos[0]->kernelAllocation));
programInfo.kernelInfos[0]->kernelAllocation = nullptr;
}; };
std::call_once(sipBuiltIn.second, initializer); std::call_once(sipBuiltIn.second, initializer);
UNRECOVERABLE_IF(sipBuiltIn.first == nullptr); UNRECOVERABLE_IF(sipBuiltIn.first == nullptr);
return *sipBuiltIn.first; return *sipBuiltIn.first;
} }
void BuiltIns::freeSipKernels(MemoryManager *memoryManager) {
for (auto &sipKernel : sipKernels) {
if (sipKernel.first.get()) {
memoryManager->freeGraphicsMemory(sipKernel.first->getSipAllocation());
}
}
}
} // namespace NEO } // namespace NEO

View File

@@ -33,6 +33,7 @@ struct KernelInfo;
struct MultiDispatchInfo; struct MultiDispatchInfo;
class Program; class Program;
class SipKernel; class SipKernel;
class MemoryManager;
static constexpr ConstStringRef mediaKernelsBuildOptionsList[] = { static constexpr ConstStringRef mediaKernelsBuildOptionsList[] = {
"-D cl_intel_device_side_advanced_vme_enable", "-D cl_intel_device_side_advanced_vme_enable",
@@ -156,6 +157,7 @@ class BuiltIns {
virtual ~BuiltIns(); virtual ~BuiltIns();
MOCKABLE_VIRTUAL const SipKernel &getSipKernel(SipKernelType type, Device &device); MOCKABLE_VIRTUAL const SipKernel &getSipKernel(SipKernelType type, Device &device);
MOCKABLE_VIRTUAL void freeSipKernels(MemoryManager *memoryManager);
BuiltinsLib &getBuiltinsLib() { BuiltinsLib &getBuiltinsLib() {
DEBUG_BREAK_IF(!builtinsLib.get()); DEBUG_BREAK_IF(!builtinsLib.get());

View File

@@ -14,9 +14,9 @@
#include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/ptr_math.h" #include "shared/source/helpers/ptr_math.h"
#include "shared/source/helpers/string.h" #include "shared/source/helpers/string.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/memory_manager/graphics_allocation.h" #include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "opencl/source/program/kernel_info.h"
namespace NEO { namespace NEO {
@@ -67,21 +67,13 @@ const char *getSipLlSrc(const Device &device) {
return (ptrSize == 8) ? llDummySrc64 : llDummySrc32; return (ptrSize == 8) ? llDummySrc64 : llDummySrc32;
} }
SipKernel::SipKernel(SipKernelType type, ProgramInfo &&sipProgram)
: type(type), programInfo(std::move(sipProgram)) {}
SipKernel::~SipKernel() = default; SipKernel::~SipKernel() = default;
GraphicsAllocation *SipKernel::getSipAllocation() const { SipKernel::SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc) : type(type), sipAllocation(sipAlloc) {
return programInfo.kernelInfos[0]->getGraphicsAllocation();
} }
const char *SipKernel::getBinary() const { GraphicsAllocation *SipKernel::getSipAllocation() const {
auto kernelInfo = programInfo.kernelInfos[0]; return sipAllocation;
return reinterpret_cast<const char *>(ptrOffset(kernelInfo->heapInfo.pKernelHeap, kernelInfo->systemKernelOffset));
}
size_t SipKernel::getBinarySize() const {
auto kernelInfo = programInfo.kernelInfos[0];
return kernelInfo->heapInfo.KernelHeapSize - kernelInfo->systemKernelOffset;
} }
SipKernelType SipKernel::getSipKernelType(GFXCORE_FAMILY family, bool debuggingActive) { SipKernelType SipKernel::getSipKernelType(GFXCORE_FAMILY family, bool debuggingActive) {
@@ -94,5 +86,4 @@ GraphicsAllocation *SipKernel::getSipKernelAllocation(Device &device) {
auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, debuggingEnabled); auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, debuggingEnabled);
return device.getBuiltIns()->getSipKernel(sipType, device).getSipAllocation(); return device.getBuiltIns()->getSipKernel(sipType, device).getSipAllocation();
} }
} // namespace NEO } // namespace NEO

View File

@@ -11,7 +11,7 @@
#include "shared/source/program/program_info.h" #include "shared/source/program/program_info.h"
#include <memory> #include <memory>
#include <vector>
namespace NEO { namespace NEO {
class Device; class Device;
@@ -23,17 +23,13 @@ const char *getSipLlSrc(const Device &device);
class SipKernel { class SipKernel {
public: public:
SipKernel(SipKernelType type, ProgramInfo &&sipProgramInfo); SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc);
SipKernel(const SipKernel &) = delete; SipKernel(const SipKernel &) = delete;
SipKernel &operator=(const SipKernel &) = delete; SipKernel &operator=(const SipKernel &) = delete;
SipKernel(SipKernel &&) = delete; SipKernel(SipKernel &&) = delete;
SipKernel &operator=(SipKernel &&) = delete; SipKernel &operator=(SipKernel &&) = delete;
virtual ~SipKernel(); virtual ~SipKernel();
const char *getBinary() const;
size_t getBinarySize() const;
SipKernelType getType() const { SipKernelType getType() const {
return type; return type;
} }
@@ -46,6 +42,6 @@ class SipKernel {
protected: protected:
SipKernelType type = SipKernelType::COUNT; SipKernelType type = SipKernelType::COUNT;
const ProgramInfo programInfo; GraphicsAllocation *sipAllocation = nullptr;
}; };
} // namespace NEO } // namespace NEO

View File

@@ -7,6 +7,7 @@
#include "shared/source/execution_environment/execution_environment.h" #include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/built_ins/built_ins.h"
#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/hw_helper.h"
#include "shared/source/memory_manager/memory_manager.h" #include "shared/source/memory_manager/memory_manager.h"
@@ -19,6 +20,11 @@ ExecutionEnvironment::ExecutionEnvironment() = default;
ExecutionEnvironment::~ExecutionEnvironment() { ExecutionEnvironment::~ExecutionEnvironment() {
if (memoryManager) { if (memoryManager) {
memoryManager->commonCleanup(); memoryManager->commonCleanup();
for (const auto &rootDeviceEnvironment : this->rootDeviceEnvironments) {
if (rootDeviceEnvironment->builtins.get()) {
rootDeviceEnvironment->builtins.get()->freeSipKernels(memoryManager.get());
}
}
} }
rootDeviceEnvironments.clear(); rootDeviceEnvironments.clear();
} }

View File

@@ -440,12 +440,10 @@ int main(int argc, char **argv) {
GmmInterface::initialize(nullptr, nullptr); GmmInterface::initialize(nullptr, nullptr);
} }
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::shutDownSipProgramInfo();
delete platformsImpl; delete platformsImpl;
return retVal; return retVal;

View File

@@ -124,6 +124,7 @@ class MockCompilerInterface : public CompilerInterface {
} }
static std::vector<char> getDummyGenBinary(); static std::vector<char> getDummyGenBinary();
static void releaseDummyGenBinary();
void (*lockListener)(MockCompilerInterface &compInt) = nullptr; void (*lockListener)(MockCompilerInterface &compInt) = nullptr;
void *lockListenerData = nullptr; void *lockListenerData = nullptr;

View File

@@ -113,7 +113,6 @@ 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::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);
} }