Add sip kernel as hexadecimal array header

Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
Related-To: NEO-5777
This commit is contained in:
Kamil Kopryk 2021-08-29 23:41:42 +00:00 committed by Compute-Runtime-Automation
parent c051495eb8
commit a203cd2863
21 changed files with 230 additions and 21 deletions

View File

@ -10,6 +10,7 @@
#include "shared/test/common/mocks/mock_compilers.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_os_library.h"
#include "shared/test/common/mocks/mock_sip.h"
#include "opencl/test/unit_test/mocks/mock_source_level_debugger.h"
@ -39,6 +40,11 @@ struct ActiveDebuggerFixture {
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo);
auto isHexadecimalArrayPrefered = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isSipKernelAsHexadecimalArrayPreferred();
if (isHexadecimalArrayPrefered) {
MockSipData::useMockSip = true;
}
debugger = new MockActiveSourceLevelDebugger(new MockOsLibrary);
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(debugger);
executionEnvironment->initializeMemoryManager();
@ -70,6 +76,9 @@ struct ActiveDebuggerFixture {
L0::Device *deviceL0;
MockActiveSourceLevelDebugger *debugger = nullptr;
HardwareInfo hwInfo;
VariableBackup<bool> mockSipCalled{&NEO::MockSipData::called};
VariableBackup<NEO::SipKernelType> mockSipCalledType{&NEO::MockSipData::calledType};
VariableBackup<bool> backupSipInitType{&MockSipData::useMockSip};
};
} // namespace ult
} // namespace L0

View File

@ -9,6 +9,7 @@
#include "shared/test/common/mocks/mock_compilers.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_memory_operations_handler.h"
#include "shared/test/common/mocks/mock_sip.h"
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h"
@ -30,6 +31,12 @@ struct L0DebuggerFixture {
hwInfo = *NEO::defaultHwInfo.get();
hwInfo.featureTable.ftrLocalMemory = true;
auto isHexadecimalArrayPrefered = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isSipKernelAsHexadecimalArrayPreferred();
if (isHexadecimalArrayPrefered) {
MockSipData::useMockSip = true;
}
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo);
executionEnvironment->initializeMemoryManager();
@ -52,6 +59,9 @@ struct L0DebuggerFixture {
L0::Device *device = nullptr;
NEO::HardwareInfo hwInfo;
MockMemoryOperations *memoryOperationsHandler = nullptr;
VariableBackup<bool> mockSipCalled{&NEO::MockSipData::called};
VariableBackup<NEO::SipKernelType> mockSipCalledType{&NEO::MockSipData::calledType};
VariableBackup<bool> backupSipInitType{&MockSipData::useMockSip};
};
struct L0DebuggerHwFixture : public L0DebuggerFixture {

View File

@ -53,7 +53,11 @@ TEST_F(L0DebuggerTest, givenL0DebuggerWhenGettingSipAllocationThenValidSipTypeIs
ASSERT_NE(nullptr, systemRoutine);
auto sipType = SipKernel::getSipKernelType(*neoDevice);
auto expectedSipAllocation = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getSipAllocation();
auto isHexadecimalArrayPreferred = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isSipKernelAsHexadecimalArrayPreferred();
auto expectedSipAllocation = isHexadecimalArrayPreferred
? NEO::MockSipData::mockSipKernel->getSipAllocation()
: neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getSipAllocation();
EXPECT_EQ(expectedSipAllocation, systemRoutine);
}
@ -69,9 +73,13 @@ TEST_F(L0DebuggerTest, givenL0DebuggerWhenGettingStateSaveAreaHeaderThenValidSip
TEST(Debugger, givenL0DebuggerOFFWhenGettingStateSaveAreaHeaderThenValidSipTypeIsReturned) {
auto executionEnvironment = new NEO::ExecutionEnvironment();
auto mockBuiltIns = new MockBuiltins();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
auto isHexadecimalArrayPreferred = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).isSipKernelAsHexadecimalArrayPreferred();
if (!isHexadecimalArrayPreferred) {
auto mockBuiltIns = new MockBuiltins();
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
}
auto hwInfo = *NEO::defaultHwInfo.get();
hwInfo.featureTable.ftrLocalMemory = true;
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&hwInfo);
@ -84,13 +92,20 @@ TEST(Debugger, givenL0DebuggerOFFWhenGettingStateSaveAreaHeaderThenValidSipTypeI
driverHandle->enableProgramDebugging = false;
driverHandle->initialize(std::move(devices));
auto sipType = SipKernel::getSipKernelType(*neoDevice);
if (isHexadecimalArrayPreferred) {
SipKernel::initSipKernel(sipType, *neoDevice);
}
auto &stateSaveAreaHeader = SipKernel::getSipKernel(*neoDevice).getStateSaveAreaHeader();
auto sipType = SipKernel::getSipKernelType(*neoDevice);
auto &expectedStateSaveAreaHeader = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getStateSaveAreaHeader();
EXPECT_EQ(expectedStateSaveAreaHeader, stateSaveAreaHeader);
if (isHexadecimalArrayPreferred) {
auto &expectedStateSaveAreaHeader = neoDevice->getRootDeviceEnvironment().sipKernels[static_cast<uint32_t>(sipType)]->getStateSaveAreaHeader();
EXPECT_EQ(expectedStateSaveAreaHeader, stateSaveAreaHeader);
} else {
auto &expectedStateSaveAreaHeader = neoDevice->getBuiltIns()->getSipKernel(sipType, *neoDevice).getStateSaveAreaHeader();
EXPECT_EQ(expectedStateSaveAreaHeader, stateSaveAreaHeader);
}
}
HWTEST_F(L0DebuggerTest, givenL0DebuggerWhenCreatedThenPerContextSbaTrackingBuffersAreAllocated) {
@ -195,7 +210,7 @@ HWTEST_F(L0DebuggerTest, givenDebuggingEnabledWhenCommandListIsExecutedThenValid
auto systemRoutine = SipKernel::getSipKernel(*neoDevice).getSipAllocation();
ASSERT_NE(nullptr, systemRoutine);
EXPECT_EQ(systemRoutine->getGpuAddress(), stateSip->getSystemInstructionPointer());
EXPECT_EQ(systemRoutine->getGpuAddressToPatch(), stateSip->getSystemInstructionPointer());
}
for (auto i = 0u; i < numCommandLists; i++) {

View File

@ -84,8 +84,9 @@ struct OOQueueHwTest : public ClDeviceFixture,
HWTEST_F(CommandQueueHwTest, WhenConstructingTwoCommandQueuesThenOnlyOneDebugSurfaceIsAllocated) {
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary));
auto device = std::make_unique<MockClDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(executionEnvironment, 0u));
auto sipType = SipKernel::getSipKernelType(device->getDevice());
SipKernel::initSipKernel(sipType, device->getDevice());
MockCommandQueueHw<FamilyType> mockCmdQueueHw1(context, device.get(), nullptr);

View File

@ -36,6 +36,9 @@ class EnqueueDebugKernelTest : public ProgramSimpleFixture,
device = pClDevice;
pDevice->executionEnvironment->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->debugger.reset(new SourceLevelDebugger(nullptr));
auto sipType = SipKernel::getSipKernelType(*pDevice);
SipKernel::initSipKernel(sipType, *pDevice);
if (pDevice->getHardwareInfo().platform.eRenderCoreFamily >= IGFX_GEN9_CORE) {
pDevice->deviceInfo.debuggerActive = true;
std::string filename;

View File

@ -188,6 +188,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeAndMidThread
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
dispatchFlags.preemptionMode = PreemptionMode::MidThread;
auto sipType = SipKernel::getSipKernelType(*pDevice);
SipKernel::initSipKernel(sipType, *pDevice);
mockCsr.flushTask(commandStream,
0,
@ -219,6 +221,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInDefaultModeAndMidThreadP
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
dispatchFlags.preemptionMode = PreemptionMode::MidThread;
auto sipType = SipKernel::getSipKernelType(*pDevice);
SipKernel::initSipKernel(sipType, *pDevice);
mockCsr->flushTask(commandStream,
0,

View File

@ -1307,6 +1307,30 @@ HWTEST_F(HwHelperTest, whenSetRenderCompressedFlagThenProperFlagSet) {
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.RenderCompressed);
}
HWTEST_F(HwHelperTest, whenAdjustPreemptionSurfaceSizeIsCalledThenCsrSizeDoesntChange) {
auto &hwHelper = HwHelper::get(renderCoreFamily);
size_t csrSize = 1024;
size_t oldCsrSize = csrSize;
hwHelper.adjustPreemptionSurfaceSize(csrSize);
EXPECT_EQ(oldCsrSize, csrSize);
}
HWTEST_F(HwHelperTest, whenSetSipKernelDataIsCalledThenSipKernelDataDoesntChange) {
auto &hwHelper = HwHelper::get(renderCoreFamily);
uint32_t *sipKernelBinary = nullptr;
uint32_t *oldSipKernelBinary = sipKernelBinary;
size_t kernelBinarySize = 1024;
size_t oldKernelBinarySize = kernelBinarySize;
hwHelper.setSipKernelData(sipKernelBinary, kernelBinarySize);
EXPECT_EQ(oldKernelBinarySize, kernelBinarySize);
EXPECT_EQ(oldSipKernelBinary, sipKernelBinary);
}
HWTEST_F(HwHelperTest, whenIsSipKernelAsHexadecimalArrayPreferredIsCalledThenReturnFalse) {
auto &hwHelper = HwHelper::get(renderCoreFamily);
EXPECT_FALSE(hwHelper.isSipKernelAsHexadecimalArrayPreferred());
}
using isXeHpCoreOrBelow = IsAtMostProduct<IGFX_XE_HP_SDV>;
HWTEST2_F(HwHelperTest, givenXeHPAndBelowPlatformWhenCheckingIfAdditionalPipeControlArgsAreRequiredThenReturnFalse, isXeHpCoreOrBelow) {
const auto &hwHelper = HwHelper::get(renderCoreFamily);

View File

@ -176,7 +176,11 @@ TEST_F(DeviceFactoryTest, givenPointerToHwInfoWhenGetDevicedCalledThenRequiedSur
ASSERT_TRUE(success);
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
EXPECT_EQ(hwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte, hwInfo->capabilityTable.requiredPreemptionSurfaceSize);
const auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
auto expextedSize = static_cast<size_t>(hwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte);
hwHelper.adjustPreemptionSurfaceSize(expextedSize);
EXPECT_EQ(expextedSize, hwInfo->capabilityTable.requiredPreemptionSurfaceSize);
}
TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenPrepareDeviceEnvironmentsIsCalledThenNumberOfReturnedDevicesIsEqualToDebugVariable) {

View File

@ -449,7 +449,9 @@ TEST_F(HwInfoConfigTestLinuxDummy, givenPointerToHwInfoWhenConfigureHwInfoCalled
EXPECT_EQ(MemoryConstants::pageSize, pInHwInfo.capabilityTable.requiredPreemptionSurfaceSize);
int ret = hwConfig.configureHwInfoDrm(&pInHwInfo, &outHwInfo, osInterface);
EXPECT_EQ(0, ret);
EXPECT_EQ(outHwInfo.gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte, outHwInfo.capabilityTable.requiredPreemptionSurfaceSize);
auto expectedSize = static_cast<size_t>(outHwInfo.gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte);
HwHelper::get(outHwInfo.platform.eRenderCoreFamily).adjustPreemptionSurfaceSize(expectedSize);
EXPECT_EQ(expectedSize, outHwInfo.capabilityTable.requiredPreemptionSurfaceSize);
}
TEST_F(HwInfoConfigTestLinuxDummy, givenInstrumentationForHardwareIsEnabledOrDisabledWhenConfiguringHwInfoThenOverrideItUsingHaveInstrumentation) {

View File

@ -22,6 +22,8 @@
HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndDisabledPreemptionWhenFlushTaskIsCalledThenSipKernelIsMadeResident) {
auto mockCsr = createCSR<FamilyType>();
auto sipType = SipKernel::getSipKernelType(device->getDevice());
SipKernel::initSipKernel(sipType, device->getDevice());
CommandQueueHw<FamilyType> commandQueue(nullptr, device.get(), 0, false);
auto &commandStream = commandQueue.getCS(4096u);

View File

@ -111,6 +111,38 @@ bool SipKernel::initRawBinaryFromFileKernel(SipKernelType type, Device &device,
return true;
}
bool SipKernel::initHexadecimalArraySipKernel(SipKernelType type, Device &device) {
uint32_t *sipKernelBinary = nullptr;
size_t kernelBinarySize = 0u;
auto &hwInfo = device.getHardwareInfo();
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
hwHelper.setSipKernelData(sipKernelBinary, kernelBinarySize);
uint32_t sipIndex = static_cast<uint32_t>(type);
uint32_t rootDeviceIndex = device.getRootDeviceIndex();
if (device.getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->sipKernels[sipIndex].get() != nullptr) {
return true;
}
const auto allocType = GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL;
AllocationProperties properties = {rootDeviceIndex, kernelBinarySize, allocType, device.getDeviceBitfield()};
properties.flags.use32BitFrontWindow = false;
auto sipAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
if (sipAllocation == nullptr) {
return false;
}
MemoryTransferHelper::transferMemoryToAllocation(hwHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *sipAllocation),
device, sipAllocation, 0, sipKernelBinary,
kernelBinarySize);
std::vector<char> emptyStateSaveAreaHeader;
device.getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->sipKernels[sipIndex] =
std::make_unique<SipKernel>(type, sipAllocation, std::move(emptyStateSaveAreaHeader));
return true;
}
void SipKernel::freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager) {
for (auto &sipKernel : rootDeviceEnvironment->sipKernels) {
if (sipKernel.get()) {
@ -119,10 +151,12 @@ void SipKernel::freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, Mem
}
}
void SipKernel::selectSipClassType(std::string &fileName) {
void SipKernel::selectSipClassType(std::string &fileName, const HardwareInfo &hwInfo) {
const std::string unknown("unk");
if (fileName.compare(unknown) == 0) {
SipKernel::classType = SipClassType::Builtins;
SipKernel::classType = HwHelper::get(hwInfo.platform.eRenderCoreFamily).isSipKernelAsHexadecimalArrayPreferred()
? SipClassType::HexadecimalHeaderFile
: SipClassType::Builtins;
} else {
SipKernel::classType = SipClassType::RawBinaryFromFile;
}
@ -130,21 +164,28 @@ void SipKernel::selectSipClassType(std::string &fileName) {
bool SipKernel::initSipKernelImpl(SipKernelType type, Device &device) {
std::string fileName = DebugManager.flags.LoadBinarySipFromFile.get();
SipKernel::selectSipClassType(fileName);
SipKernel::selectSipClassType(fileName, *device.getRootDeviceEnvironment().getHardwareInfo());
if (SipKernel::classType == SipClassType::RawBinaryFromFile) {
switch (SipKernel::classType) {
case SipClassType::RawBinaryFromFile:
return SipKernel::initRawBinaryFromFileKernel(type, device, fileName);
case SipClassType::HexadecimalHeaderFile:
return SipKernel::initHexadecimalArraySipKernel(type, device);
default:
return SipKernel::initBuiltinsSipKernel(type, device);
}
return SipKernel::initBuiltinsSipKernel(type, device);
}
const SipKernel &SipKernel::getSipKernelImpl(Device &device) {
auto sipType = SipKernel::getSipKernelType(device);
if (SipKernel::classType == SipClassType::RawBinaryFromFile) {
switch (SipKernel::classType) {
case SipClassType::RawBinaryFromFile:
case SipClassType::HexadecimalHeaderFile:
return *device.getRootDeviceEnvironment().sipKernels[static_cast<uint32_t>(sipType)].get();
default:
return device.getBuiltIns()->getSipKernel(sipType, device);
}
return device.getBuiltIns()->getSipKernel(sipType, device);
}
const SipKernel &SipKernel::getBindlessDebugSipKernel(Device &device) {

View File

@ -52,8 +52,8 @@ class SipKernel {
static bool initBuiltinsSipKernel(SipKernelType type, Device &device);
static bool initRawBinaryFromFileKernel(SipKernelType type, Device &device, std::string &fileName);
static void selectSipClassType(std::string &fileName);
static bool initHexadecimalArraySipKernel(SipKernelType type, Device &device);
static void selectSipClassType(std::string &fileName, const HardwareInfo &hwInfo);
const std::vector<char> stateSaveAreaHeader;
GraphicsAllocation *sipAllocation = nullptr;

View File

@ -121,6 +121,16 @@ macro(macro_for_each_gen)
list(APPEND CORE_SRCS_${GEN_TYPE}_H_BASE ${SRC_FILE})
endif()
set(SRC_FILE "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR}sip_kernels/${GEN_TYPE_LOWER}/sip_kernel_${GEN_TYPE_LOWER}.cpp")
if(EXISTS ${SRC_FILE})
list(APPEND CORE_SRCS_${GEN_TYPE}_CPP_BASE ${SRC_FILE})
endif()
set(SRC_FILE "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR}sip_kernels/${GEN_TYPE_LOWER}/sip_kernel_${GEN_TYPE_LOWER}.h")
if(EXISTS ${SRC_FILE})
list(APPEND CORE_SRCS_${GEN_TYPE}_H_BASE ${SRC_FILE})
endif()
endforeach()
if(EXISTS ${GENERATED_GENX_PREFIX}/hw_cmds_generated_${GEN_TYPE_LOWER}.inl)
list(APPEND CORE_SRCS_${GEN_TYPE}_H_BASE "${GENERATED_GENX_PREFIX}/hw_cmds_generated_${GEN_TYPE_LOWER}.inl")

View File

@ -156,6 +156,10 @@ class HwHelper {
static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo);
static uint32_t getCopyEnginesCount(const HardwareInfo &hwInfo);
virtual bool isSipKernelAsHexadecimalArrayPreferred() const = 0;
virtual void setSipKernelData(uint32_t *&sipKernelBinary, size_t &kernelBinarySize) const = 0;
virtual void adjustPreemptionSurfaceSize(size_t &csrSize) const = 0;
protected:
virtual LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0;
@ -386,6 +390,12 @@ class HwHelperHw : public HwHelper {
bool isEngineTypeRemappingToHwSpecificRequired() const override;
bool isSipKernelAsHexadecimalArrayPreferred() const override;
void setSipKernelData(uint32_t *&sipKernelBinary, size_t &kernelBinarySize) const override;
void adjustPreemptionSurfaceSize(size_t &csrSize) const override;
protected:
LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override;

View File

@ -656,4 +656,17 @@ bool HwHelperHw<GfxFamily>::isEngineTypeRemappingToHwSpecificRequired() const {
return false;
}
template <typename GfxFamily>
bool HwHelperHw<GfxFamily>::isSipKernelAsHexadecimalArrayPreferred() const {
return false;
}
template <typename GfxFamily>
void HwHelperHw<GfxFamily>::setSipKernelData(uint32_t *&sipKernelBinary, size_t &kernelBinarySize) const {
}
template <typename GfxFamily>
void HwHelperHw<GfxFamily>::adjustPreemptionSurfaceSize(size_t &csrSize) const {
}
} // namespace NEO

View File

@ -179,7 +179,9 @@ int HwInfoConfig::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo
static_cast<bool>(outHwInfo->featureTable.ftrGpGpuMidThreadLevelPreempt) && preemption,
static_cast<bool>(outHwInfo->featureTable.ftrGpGpuThreadGroupLevelPreempt) && preemption,
static_cast<bool>(outHwInfo->featureTable.ftrGpGpuMidBatchPreempt) && preemption);
outHwInfo->capabilityTable.requiredPreemptionSurfaceSize = outHwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
hwHelper.adjustPreemptionSurfaceSize(outHwInfo->capabilityTable.requiredPreemptionSurfaceSize);
auto &kmdNotifyProperties = outHwInfo->capabilityTable.kmdNotifyProperties;
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideEnableKmdNotify.get(), kmdNotifyProperties.enableKmdNotify);

View File

@ -35,6 +35,7 @@ int HwInfoConfig::configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo
outHwInfo->gtSystemInfo.CsrSizeInMb = static_cast<uint32_t>(DebugManager.flags.OverridePreemptionSurfaceSizeInMb.get());
}
outHwInfo->capabilityTable.requiredPreemptionSurfaceSize = outHwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte;
hwHelper.adjustPreemptionSurfaceSize(outHwInfo->capabilityTable.requiredPreemptionSurfaceSize);
auto &kmdNotifyProperties = outHwInfo->capabilityTable.kmdNotifyProperties;
KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideEnableKmdNotify.get(), kmdNotifyProperties.enableKmdNotify);

View File

@ -28,7 +28,12 @@ void clearUseFlags() {
bool SipKernel::initSipKernel(SipKernelType type, Device &device) {
if (MockSipData::useMockSip) {
SipKernel::classType = SipClassType::Builtins;
auto &hwHelper = HwHelper::get(device.getRootDeviceEnvironment().getHardwareInfo()->platform.eRenderCoreFamily);
if (hwHelper.isSipKernelAsHexadecimalArrayPreferred()) {
SipKernel::classType = SipClassType::HexadecimalHeaderFile;
} else {
SipKernel::classType = SipClassType::Builtins;
}
MockSipData::calledType = type;
MockSipData::called = true;

View File

@ -9,3 +9,5 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/built_in_tests_shared.inl
${CMAKE_CURRENT_SOURCE_DIR}/sip_tests.cpp
)
add_subdirectories()

View File

@ -225,3 +225,51 @@ TEST_F(RawBinarySipTest, givenRawBinaryFileWhenInitSipKernelTwiceThenSipIsLoaded
EXPECT_EQ(sipKernel, secondSipKernel);
EXPECT_EQ(storedAllocation, secondStoredAllocation);
}
struct HexadecimalHeaderSipKernel : public SipKernel {
using SipKernel::getSipKernelImpl;
using SipKernel::initHexadecimalArraySipKernel;
};
using HexadecimalHeaderSipTest = Test<DeviceFixture>;
TEST_F(HexadecimalHeaderSipTest, whenInitHexadecimalArraySipKernelIsCalledThenSipKernelIsCorrect) {
VariableBackup<SipClassType> backupSipClassType(&SipKernel::classType, SipClassType::HexadecimalHeaderFile);
EXPECT_TRUE(HexadecimalHeaderSipKernel::initHexadecimalArraySipKernel(SipKernelType::Csr, *pDevice));
EXPECT_EQ(SipKernelType::Csr, SipKernel::getSipKernelType(*pDevice));
uint32_t sipIndex = static_cast<uint32_t>(SipKernelType::Csr);
const auto expectedSipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get();
ASSERT_NE(nullptr, expectedSipKernel);
const auto &sipKernel = HexadecimalHeaderSipKernel::getSipKernelImpl(*pDevice);
EXPECT_EQ(expectedSipKernel, &sipKernel);
auto expectedSipAllocation = expectedSipKernel->getSipAllocation();
auto sipAllocation = sipKernel.getSipAllocation();
EXPECT_EQ(expectedSipAllocation, sipAllocation);
}
TEST_F(HexadecimalHeaderSipTest, givenFailMemoryManagerWhenInitHexadecimalArraySipKernelIsCalledThenSipKernelIsNullptr) {
pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(0, *pDevice->executionEnvironment));
EXPECT_FALSE(HexadecimalHeaderSipKernel::initHexadecimalArraySipKernel(SipKernelType::Csr, *pDevice));
uint32_t sipIndex = static_cast<uint32_t>(SipKernelType::Csr);
auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get();
EXPECT_EQ(nullptr, sipKernel);
}
TEST_F(HexadecimalHeaderSipTest, whenInitHexadecimalArraySipKernelIsCalledTwiceThenSipKernelIsCreatedOnce) {
VariableBackup<SipClassType> backupSipClassType(&SipKernel::classType, SipClassType::HexadecimalHeaderFile);
EXPECT_TRUE(HexadecimalHeaderSipKernel::initHexadecimalArraySipKernel(SipKernelType::Csr, *pDevice));
const auto &sipKernel = HexadecimalHeaderSipKernel::getSipKernelImpl(*pDevice);
EXPECT_TRUE(HexadecimalHeaderSipKernel::initHexadecimalArraySipKernel(SipKernelType::Csr, *pDevice));
const auto &sipKernel2 = HexadecimalHeaderSipKernel::getSipKernelImpl(*pDevice);
EXPECT_EQ(&sipKernel, &sipKernel2);
auto sipAllocation = sipKernel.getSipAllocation();
auto sipAllocation2 = sipKernel2.getSipAllocation();
EXPECT_EQ(sipAllocation, sipAllocation2);
}

View File

@ -97,6 +97,9 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterPreemptionTests, GivenDebuggerUsedWhenP
using STATE_SIP = typename FamilyType::STATE_SIP;
device->executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger);
auto sipType = SipKernel::getSipKernelType(*device.get());
SipKernel::initSipKernel(sipType, *device.get());
size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
EXPECT_EQ(sizeof(STATE_SIP), requiredSize);