diff --git a/level_zero/core/test/unit_tests/sources/debugger/active_debugger_fixture.h b/level_zero/core/test/unit_tests/sources/debugger/active_debugger_fixture.h index f5ed09c544..f66ff790d8 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/active_debugger_fixture.h +++ b/level_zero/core/test/unit_tests/sources/debugger/active_debugger_fixture.h @@ -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 mockSipCalled{&NEO::MockSipData::called}; + VariableBackup mockSipCalledType{&NEO::MockSipData::calledType}; + VariableBackup backupSipInitType{&MockSipData::useMockSip}; }; } // namespace ult } // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h b/level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h index 0cba29f70d..1e37a33508 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h +++ b/level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h @@ -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 mockSipCalled{&NEO::MockSipData::called}; + VariableBackup mockSipCalledType{&NEO::MockSipData::calledType}; + VariableBackup backupSipInitType{&MockSipData::useMockSip}; }; struct L0DebuggerHwFixture : public L0DebuggerFixture { diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp index 231aa7b3d5..2f9062c6e2 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger.cpp @@ -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(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++) { diff --git a/opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp index 2350f28717..effde0e01a 100644 --- a/opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_hw_tests.cpp @@ -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(MockDevice::create(executionEnvironment, 0u)); + auto sipType = SipKernel::getSipKernelType(device->getDevice()); + SipKernel::initSipKernel(sipType, device->getDevice()); MockCommandQueueHw mockCmdQueueHw1(context, device.get(), nullptr); diff --git a/opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp index e7f7950a79..c931454c21 100644 --- a/opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_debug_kernel_tests.cpp @@ -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; diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp index 46d1339f52..9d9c387012 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp @@ -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, diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index caa3ac63c4..6e5a640272 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -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; HWTEST2_F(HwHelperTest, givenXeHPAndBelowPlatformWhenCheckingIfAdditionalPipeControlArgsAreRequiredThenReturnFalse, isXeHpCoreOrBelow) { const auto &hwHelper = HwHelper::get(renderCoreFamily); diff --git a/opencl/test/unit_test/os_interface/device_factory_tests.cpp b/opencl/test/unit_test/os_interface/device_factory_tests.cpp index 065a4a758e..d310ffc4c5 100644 --- a/opencl/test/unit_test/os_interface/device_factory_tests.cpp +++ b/opencl/test/unit_test/os_interface/device_factory_tests.cpp @@ -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(hwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte); + hwHelper.adjustPreemptionSurfaceSize(expextedSize); + + EXPECT_EQ(expextedSize, hwInfo->capabilityTable.requiredPreemptionSurfaceSize); } TEST_F(DeviceFactoryTest, givenCreateMultipleRootDevicesDebugFlagWhenPrepareDeviceEnvironmentsIsCalledThenNumberOfReturnedDevicesIsEqualToDebugVariable) { diff --git a/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp b/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp index 9a2d9128d5..0f65862fdc 100644 --- a/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp @@ -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(outHwInfo.gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte); + HwHelper::get(outHwInfo.platform.eRenderCoreFamily).adjustPreemptionSurfaceSize(expectedSize); + EXPECT_EQ(expectedSize, outHwInfo.capabilityTable.requiredPreemptionSurfaceSize); } TEST_F(HwInfoConfigTestLinuxDummy, givenInstrumentationForHardwareIsEnabledOrDisabledWhenConfiguringHwInfoThenOverrideItUsingHaveInstrumentation) { diff --git a/opencl/test/unit_test/source_level_debugger/source_level_debugger_csr_tests.cpp b/opencl/test/unit_test/source_level_debugger/source_level_debugger_csr_tests.cpp index 944f527768..149c8df769 100644 --- a/opencl/test/unit_test/source_level_debugger/source_level_debugger_csr_tests.cpp +++ b/opencl/test/unit_test/source_level_debugger/source_level_debugger_csr_tests.cpp @@ -22,6 +22,8 @@ HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndDisabledPreemptionWhenFlushTaskIsCalledThenSipKernelIsMadeResident) { auto mockCsr = createCSR(); + auto sipType = SipKernel::getSipKernelType(device->getDevice()); + SipKernel::initSipKernel(sipType, device->getDevice()); CommandQueueHw commandQueue(nullptr, device.get(), 0, false); auto &commandStream = commandQueue.getCS(4096u); diff --git a/shared/source/built_ins/sip.cpp b/shared/source/built_ins/sip.cpp index f6c099684c..fc26177aae 100644 --- a/shared/source/built_ins/sip.cpp +++ b/shared/source/built_ins/sip.cpp @@ -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(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 emptyStateSaveAreaHeader; + device.getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->sipKernels[sipIndex] = + std::make_unique(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(sipType)].get(); + default: + return device.getBuiltIns()->getSipKernel(sipType, device); } - return device.getBuiltIns()->getSipKernel(sipType, device); } const SipKernel &SipKernel::getBindlessDebugSipKernel(Device &device) { diff --git a/shared/source/built_ins/sip.h b/shared/source/built_ins/sip.h index 0fe654907b..c8a6696c4a 100644 --- a/shared/source/built_ins/sip.h +++ b/shared/source/built_ins/sip.h @@ -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 stateSaveAreaHeader; GraphicsAllocation *sipAllocation = nullptr; diff --git a/shared/source/enable_gens.cmake b/shared/source/enable_gens.cmake index 5384ef901e..8b76730503 100644 --- a/shared/source/enable_gens.cmake +++ b/shared/source/enable_gens.cmake @@ -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") diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index 0d3669e5e2..eb9d10e3da 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -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; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 9b8b2d1c75..3dc5bb579e 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -656,4 +656,17 @@ bool HwHelperHw::isEngineTypeRemappingToHwSpecificRequired() const { return false; } +template +bool HwHelperHw::isSipKernelAsHexadecimalArrayPreferred() const { + return false; +} + +template +void HwHelperHw::setSipKernelData(uint32_t *&sipKernelBinary, size_t &kernelBinarySize) const { +} + +template +void HwHelperHw::adjustPreemptionSurfaceSize(size_t &csrSize) const { +} + } // namespace NEO diff --git a/shared/source/os_interface/linux/hw_info_config_drm.cpp b/shared/source/os_interface/linux/hw_info_config_drm.cpp index e649549f6e..c6fcf8b8f7 100644 --- a/shared/source/os_interface/linux/hw_info_config_drm.cpp +++ b/shared/source/os_interface/linux/hw_info_config_drm.cpp @@ -179,7 +179,9 @@ int HwInfoConfig::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo static_cast(outHwInfo->featureTable.ftrGpGpuMidThreadLevelPreempt) && preemption, static_cast(outHwInfo->featureTable.ftrGpGpuThreadGroupLevelPreempt) && preemption, static_cast(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); diff --git a/shared/source/os_interface/windows/hw_info_config_wddm.cpp b/shared/source/os_interface/windows/hw_info_config_wddm.cpp index e6fb3e4d4b..b200f7af20 100644 --- a/shared/source/os_interface/windows/hw_info_config_wddm.cpp +++ b/shared/source/os_interface/windows/hw_info_config_wddm.cpp @@ -35,6 +35,7 @@ int HwInfoConfig::configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo outHwInfo->gtSystemInfo.CsrSizeInMb = static_cast(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); diff --git a/shared/test/common/helpers/sip_init.cpp b/shared/test/common/helpers/sip_init.cpp index be83b0ce98..c24be33d76 100644 --- a/shared/test/common/helpers/sip_init.cpp +++ b/shared/test/common/helpers/sip_init.cpp @@ -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; diff --git a/shared/test/unit_test/built_ins/CMakeLists.txt b/shared/test/unit_test/built_ins/CMakeLists.txt index 165aceb167..cd17a31280 100644 --- a/shared/test/unit_test/built_ins/CMakeLists.txt +++ b/shared/test/unit_test/built_ins/CMakeLists.txt @@ -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() diff --git a/shared/test/unit_test/built_ins/sip_tests.cpp b/shared/test/unit_test/built_ins/sip_tests.cpp index b0197346ef..3208478156 100644 --- a/shared/test/unit_test/built_ins/sip_tests.cpp +++ b/shared/test/unit_test/built_ins/sip_tests.cpp @@ -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; + +TEST_F(HexadecimalHeaderSipTest, whenInitHexadecimalArraySipKernelIsCalledThenSipKernelIsCorrect) { + VariableBackup backupSipClassType(&SipKernel::classType, SipClassType::HexadecimalHeaderFile); + + EXPECT_TRUE(HexadecimalHeaderSipKernel::initHexadecimalArraySipKernel(SipKernelType::Csr, *pDevice)); + EXPECT_EQ(SipKernelType::Csr, SipKernel::getSipKernelType(*pDevice)); + + uint32_t sipIndex = static_cast(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(SipKernelType::Csr); + auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get(); + EXPECT_EQ(nullptr, sipKernel); +} + +TEST_F(HexadecimalHeaderSipTest, whenInitHexadecimalArraySipKernelIsCalledTwiceThenSipKernelIsCreatedOnce) { + VariableBackup 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); +} diff --git a/shared/test/unit_test/preemption/test_preemption_xehp_and_later.cpp b/shared/test/unit_test/preemption/test_preemption_xehp_and_later.cpp index 60e1268871..9e7ab58e54 100644 --- a/shared/test/unit_test/preemption/test_preemption_xehp_and_later.cpp +++ b/shared/test/unit_test/preemption/test_preemption_xehp_and_later.cpp @@ -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(*device); EXPECT_EQ(sizeof(STATE_SIP), requiredSize);