diff --git a/level_zero/core/test/unit_tests/mocks/mock_built_ins.cpp b/level_zero/core/test/unit_tests/mocks/mock_built_ins.cpp index 0752f78d4d..9269a8cb34 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_built_ins.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_built_ins.cpp @@ -12,7 +12,7 @@ namespace L0 { namespace ult { -const NEO::SipKernel &MockBuiltins::getSipKernel(NEO::SipKernelType type, NEO::Device &device) { +const NEO::SipKernel &MockBuiltins::getSipKernel(NEO::SipKernelType type, bool bindlessSip, NEO::Device &device) { if (!(sipKernel && sipKernel->getType() == type)) { sipKernel.reset(new NEO::SipKernel(type, allocation.get(), stateSaveAreaHeader)); } diff --git a/level_zero/core/test/unit_tests/mocks/mock_built_ins.h b/level_zero/core/test/unit_tests/mocks/mock_built_ins.h index d50c974120..13dee2c8e4 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_built_ins.h +++ b/level_zero/core/test/unit_tests/mocks/mock_built_ins.h @@ -17,7 +17,7 @@ class MockBuiltins : public NEO::BuiltIns { 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, bool bindlessSip, NEO::Device &device) override; std::unique_ptr sipKernel; std::unique_ptr allocation; std::vector stateSaveAreaHeader{'s', 's', 'a', 'h'}; diff --git a/opencl/test/unit_test/built_ins/sip_tests.cpp b/opencl/test/unit_test/built_ins/sip_tests.cpp index 30bd40602c..c3d21bd6cb 100644 --- a/opencl/test/unit_test/built_ins/sip_tests.cpp +++ b/opencl/test/unit_test/built_ins/sip_tests.cpp @@ -67,4 +67,14 @@ TEST(DebugSip, givenBuiltInsWhenDbgCsrSipIsRequestedThenCorrectSipKernelIsReturn EXPECT_EQ(SipKernelType::DbgCsr, sipKernel.getType()); } +TEST(DebugBindlessSip, givenBindlessDebugSipIsRequestedThenCorrectSipKernelIsReturned) { + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); + EXPECT_NE(nullptr, mockDevice); + + auto &sipKernel = NEO::SipKernel::getBindlessDebugSipKernel(*mockDevice); + + EXPECT_NE(nullptr, &sipKernel); + EXPECT_LE(SipKernelType::DbgCsr, sipKernel.getType()); + EXPECT_FALSE(sipKernel.getStateSaveAreaHeader().empty()); +} } // namespace SipKernelTests diff --git a/shared/source/built_ins/built_ins.cpp b/shared/source/built_ins/built_ins.cpp index a3ca0eab01..13046cdfd1 100644 --- a/shared/source/built_ins/built_ins.cpp +++ b/shared/source/built_ins/built_ins.cpp @@ -31,6 +31,10 @@ BuiltIns::BuiltIns() { BuiltIns::~BuiltIns() = default; const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) { + return getSipKernel(type, false, device); +} + +const SipKernel &BuiltIns::getSipKernel(SipKernelType type, bool bindlessSip, Device &device) { uint32_t kernelId = static_cast(type); UNRECOVERABLE_IF(kernelId >= static_cast(SipKernelType::COUNT)); auto &sipBuiltIn = this->sipKernels[kernelId]; @@ -41,7 +45,7 @@ const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) { auto compilerInteface = device.getCompilerInterface(); UNRECOVERABLE_IF(compilerInteface == nullptr); - auto ret = compilerInteface->getSipKernelBinary(device, type, sipBinary, stateSaveAreaHeader); + auto ret = compilerInteface->getSipKernelBinary(device, type, bindlessSip, sipBinary, stateSaveAreaHeader); UNRECOVERABLE_IF(ret != TranslationOutput::ErrorCode::Success); UNRECOVERABLE_IF(sipBinary.size() == 0); diff --git a/shared/source/built_ins/built_ins.h b/shared/source/built_ins/built_ins.h index cf78898d22..6355ca2ebe 100644 --- a/shared/source/built_ins/built_ins.h +++ b/shared/source/built_ins/built_ins.h @@ -157,6 +157,7 @@ class BuiltIns { virtual ~BuiltIns(); MOCKABLE_VIRTUAL const SipKernel &getSipKernel(SipKernelType type, Device &device); + MOCKABLE_VIRTUAL const SipKernel &getSipKernel(SipKernelType type, bool bindlessSip, Device &device); MOCKABLE_VIRTUAL void freeSipKernels(MemoryManager *memoryManager); BuiltinsLib &getBuiltinsLib() { diff --git a/shared/source/built_ins/sip.cpp b/shared/source/built_ins/sip.cpp index 2137227e22..f6c099684c 100644 --- a/shared/source/built_ins/sip.cpp +++ b/shared/source/built_ins/sip.cpp @@ -42,6 +42,10 @@ const std::vector &SipKernel::getStateSaveAreaHeader() const { SipKernelType SipKernel::getSipKernelType(Device &device) { bool debuggingEnabled = device.getDebugger() != nullptr || device.isDebuggerActive(); + return getSipKernelType(device, debuggingEnabled); +} + +SipKernelType SipKernel::getSipKernelType(Device &device, bool debuggingEnabled) { auto &hwHelper = HwHelper::get(device.getHardwareInfo().platform.eRenderCoreFamily); return hwHelper.getSipKernelType(debuggingEnabled); } @@ -143,4 +147,9 @@ const SipKernel &SipKernel::getSipKernelImpl(Device &device) { return device.getBuiltIns()->getSipKernel(sipType, device); } +const SipKernel &SipKernel::getBindlessDebugSipKernel(Device &device) { + auto debugSipType = SipKernel::getSipKernelType(device, true); + return device.getBuiltIns()->getSipKernel(debugSipType, true, device); +} + } // namespace NEO diff --git a/shared/source/built_ins/sip.h b/shared/source/built_ins/sip.h index 9e73bc14d5..0fe654907b 100644 --- a/shared/source/built_ins/sip.h +++ b/shared/source/built_ins/sip.h @@ -39,7 +39,9 @@ class SipKernel { static void freeSipKernels(RootDeviceEnvironment *rootDeviceEnvironment, MemoryManager *memoryManager); static const SipKernel &getSipKernel(Device &device); + static const SipKernel &getBindlessDebugSipKernel(Device &device); static SipKernelType getSipKernelType(Device &device); + static SipKernelType getSipKernelType(Device &device, bool debuggingEnable); static const size_t maxDbgSurfaceSize; static SipClassType classType; diff --git a/shared/source/compiler_interface/compiler_interface.cpp b/shared/source/compiler_interface/compiler_interface.cpp index 2725c0a6a5..e1d0ac19ee 100644 --- a/shared/source/compiler_interface/compiler_interface.cpp +++ b/shared/source/compiler_interface/compiler_interface.cpp @@ -300,7 +300,7 @@ TranslationOutput::ErrorCode CompilerInterface::createLibrary( return TranslationOutput::ErrorCode::Success; } -TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device &device, SipKernelType type, std::vector &retBinary, +TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device &device, SipKernelType type, bool bindlessSip, std::vector &retBinary, std::vector &stateSaveAreaHeader) { if (false == isIgcAvailable()) { return TranslationOutput::ErrorCode::CompilerNotAvailable; @@ -325,7 +325,7 @@ TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device & } auto deviceCtx = getIgcDeviceCtx(device); - bool bindlessSip = debugSip ? DebugManager.flags.UseBindlessDebugSip.get() : false; + bindlessSip |= debugSip ? DebugManager.flags.UseBindlessDebugSip.get() : false; auto systemRoutineBuffer = igcMain.get()->CreateBuiltin(); auto stateSaveAreaBuffer = igcMain.get()->CreateBuiltin(); diff --git a/shared/source/compiler_interface/compiler_interface.h b/shared/source/compiler_interface/compiler_interface.h index a07c06a992..9b351ae1e9 100644 --- a/shared/source/compiler_interface/compiler_interface.h +++ b/shared/source/compiler_interface/compiler_interface.h @@ -133,7 +133,7 @@ class CompilerInterface { const TranslationInput &input, TranslationOutput &output); - MOCKABLE_VIRTUAL TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, std::vector &retBinary, + MOCKABLE_VIRTUAL TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, bool bindlessSip, std::vector &retBinary, std::vector &stateSaveAreaHeader); protected: diff --git a/shared/test/common/mocks/mock_compiler_interface.h b/shared/test/common/mocks/mock_compiler_interface.h index 6a7637a0cc..3287bb8bca 100644 --- a/shared/test/common/mocks/mock_compiler_interface.h +++ b/shared/test/common/mocks/mock_compiler_interface.h @@ -114,14 +114,14 @@ class MockCompilerInterface : public CompilerInterface { return this->fclBaseTranslationCtx.get(); } - TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, std::vector &retBinary, + TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, bool bindlessSip, std::vector &retBinary, std::vector &stateAreaHeader) override { if (this->sipKernelBinaryOverride.size() > 0) { retBinary = this->sipKernelBinaryOverride; this->requestedSipKernel = type; return TranslationOutput::ErrorCode::Success; } else { - return CompilerInterface::getSipKernelBinary(device, type, retBinary, stateAreaHeader); + return CompilerInterface::getSipKernelBinary(device, type, bindlessSip, retBinary, stateAreaHeader); } } diff --git a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp index 1621f1557f..54321c3c89 100644 --- a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp +++ b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp @@ -1004,7 +1004,7 @@ TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenGetSipKernelBinaryFa pCompilerInterface->igcMain.reset(); std::vector sipBinary; std::vector stateAreaHeader; - auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader); + auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::CompilerNotAvailable, err); EXPECT_EQ(0U, sipBinary.size()); } @@ -1016,7 +1016,7 @@ TEST_F(CompilerInterfaceTest, whenIgcReturnsErrorThenGetSipKernelBinaryFailsGrac std::vector sipBinary; std::vector stateAreaHeader; - auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader); + auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::UnknownError, err); EXPECT_EQ(0U, sipBinary.size()); @@ -1029,7 +1029,7 @@ TEST_F(CompilerInterfaceTest, whenEverythingIsOkThenGetSipKernelReturnsIgcsOutpu gEnvironment->igcPushDebugVars(igcDebugVars); std::vector sipBinary; std::vector stateAreaHeader; - auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader); + auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::Success, err); EXPECT_NE(0U, sipBinary.size()); @@ -1041,17 +1041,17 @@ TEST_F(CompilerInterfaceTest, whenRequestingSipKernelBinaryThenProperSystemRouti gEnvironment->igcPushDebugVars(igcDebugVars); std::vector sipBinary; std::vector stateAreaHeader; - auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader); + auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::Success, err); EXPECT_NE(0U, sipBinary.size()); EXPECT_EQ(IGC::SystemRoutineType::contextSaveRestore, getIgcDebugVars().typeOfSystemRoutine); - err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsr, sipBinary, stateAreaHeader); + err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsr, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::Success, err); EXPECT_NE(0U, sipBinary.size()); EXPECT_EQ(IGC::SystemRoutineType::debug, getIgcDebugVars().typeOfSystemRoutine); - err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, sipBinary, stateAreaHeader); + err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::Success, err); EXPECT_NE(0U, sipBinary.size()); EXPECT_EQ(IGC::SystemRoutineType::debugSlm, getIgcDebugVars().typeOfSystemRoutine); @@ -1066,19 +1066,19 @@ TEST_F(CompilerInterfaceTest, givenUseBindlessDebugSipWhenRequestingSipKernelBin gEnvironment->igcPushDebugVars(igcDebugVars); std::vector sipBinary; std::vector stateAreaHeader; - auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary, stateAreaHeader); + auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::Success, err); EXPECT_NE(0U, sipBinary.size()); EXPECT_EQ(IGC::SystemRoutineType::contextSaveRestore, getIgcDebugVars().typeOfSystemRoutine); EXPECT_EQ(MockCompilerDebugVars::SipAddressingType::bindful, getIgcDebugVars().receivedSipAddressingType); - err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsr, sipBinary, stateAreaHeader); + err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsr, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::Success, err); EXPECT_NE(0U, sipBinary.size()); EXPECT_EQ(IGC::SystemRoutineType::debug, getIgcDebugVars().typeOfSystemRoutine); EXPECT_EQ(MockCompilerDebugVars::SipAddressingType::bindless, getIgcDebugVars().receivedSipAddressingType); - err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, sipBinary, stateAreaHeader); + err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::Success, err); EXPECT_NE(0U, sipBinary.size()); EXPECT_EQ(IGC::SystemRoutineType::debugSlm, getIgcDebugVars().typeOfSystemRoutine); @@ -1092,7 +1092,7 @@ TEST_F(CompilerInterfaceTest, whenRequestingInvalidSipKernelBinaryThenErrorIsRet gEnvironment->igcPushDebugVars(igcDebugVars); std::vector sipBinary; std::vector stateAreaHeader; - auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::COUNT, sipBinary, stateAreaHeader); + auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::COUNT, false, sipBinary, stateAreaHeader); EXPECT_EQ(TranslationOutput::ErrorCode::UnknownError, err); EXPECT_EQ(0U, sipBinary.size()); EXPECT_EQ(IGC::SystemRoutineType::undefined, getIgcDebugVars().typeOfSystemRoutine);