diff --git a/opencl/test/unit_test/mocks/mock_compilers.cpp b/opencl/test/unit_test/mocks/mock_compilers.cpp index ded117553c..d4b5b17a09 100644 --- a/opencl/test/unit_test/mocks/mock_compilers.cpp +++ b/opencl/test/unit_test/mocks/mock_compilers.cpp @@ -492,6 +492,8 @@ bool MockIgcOclDeviceCtx::GetSystemRoutine(IGC::SystemRoutineType::SystemRoutine CIF::Builtins::BufferSimple *stateSaveAreaHeaderInit) { MockCompilerDebugVars &debugVars = *NEO::igcDebugVars; debugVars.typeOfSystemRoutine = typeOfSystemRoutine; + debugVars.receivedSipAddressingType = bindless ? MockCompilerDebugVars::SipAddressingType::bindless : MockCompilerDebugVars::SipAddressingType::bindful; + const char mockData[64] = {'C', 'T', 'N', 'I'}; if (debugVars.forceBuildFailure || typeOfSystemRoutine == IGC::SystemRoutineType::undefined) { diff --git a/opencl/test/unit_test/mocks/mock_compilers.h b/opencl/test/unit_test/mocks/mock_compilers.h index 7b1d1dbdfe..c3c1ec3cd6 100644 --- a/opencl/test/unit_test/mocks/mock_compilers.h +++ b/opencl/test/unit_test/mocks/mock_compilers.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2020 Intel Corporation + * Copyright (C) 2017-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -21,6 +21,11 @@ namespace NEO { struct MockCompilerDebugVars { + enum class SipAddressingType { + unknown, + bindful, + bindless + }; bool forceBuildFailure = false; bool forceCreateFailure = false; bool forceRegisterFail = false; @@ -35,6 +40,7 @@ struct MockCompilerDebugVars { bool failCreateIgcFeWaInterface = false; int64_t overrideFclDeviceCtxVersion = -1; IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine = IGC::SystemRoutineType::undefined; + SipAddressingType receivedSipAddressingType = SipAddressingType::unknown; std::string *receivedInternalOptionsOutput = nullptr; std::string *receivedInput = nullptr; diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index a401775812..484782529e 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -219,3 +219,4 @@ DisableDeepBind = 0 GpuScratchRegWriteAfterWalker = -1 GpuScratchRegWriteRegisterData = 0 GpuScratchRegWriteRegisterOffset = 0 +UseBindlessDebugSip = 0 diff --git a/shared/source/compiler_interface/compiler_interface.cpp b/shared/source/compiler_interface/compiler_interface.cpp index cb74860339..d5eefa6b0c 100644 --- a/shared/source/compiler_interface/compiler_interface.cpp +++ b/shared/source/compiler_interface/compiler_interface.cpp @@ -309,22 +309,25 @@ TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device & } IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine = IGC::SystemRoutineType::undefined; + bool debugSip = false; switch (type) { case SipKernelType::Csr: typeOfSystemRoutine = IGC::SystemRoutineType::contextSaveRestore; break; case SipKernelType::DbgCsr: typeOfSystemRoutine = IGC::SystemRoutineType::debug; + debugSip = true; break; case SipKernelType::DbgCsrLocal: typeOfSystemRoutine = IGC::SystemRoutineType::debugSlm; + debugSip = true; break; default: break; } auto deviceCtx = getIgcDeviceCtx(device); - const bool bindlessSip = false; + bool bindlessSip = debugSip ? DebugManager.flags.UseBindlessDebugSip.get() : false; auto systemRoutineBuffer = igcMain.get()->CreateBuiltin(); auto stateSaveAreaBuffer = igcMain.get()->CreateBuiltin(); diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 40137993fd..5f6672ffa4 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -54,6 +54,7 @@ DECLARE_DEBUG_VARIABLE(bool, ForcePipeControlPriorToWalker, false, "Allows to fo DECLARE_DEBUG_VARIABLE(bool, ZebinAppendElws, false, "Append crossthread data with enqueue local work size") DECLARE_DEBUG_VARIABLE(bool, ZebinIgnoreIcbeVersion, false, "Ignore IGC\'s ICBE version") DECLARE_DEBUG_VARIABLE(bool, UseExternalAllocatorForSshAndDsh, false, "Use 32 bit external Allocator for ssh and dsh in Level Zero") +DECLARE_DEBUG_VARIABLE(bool, UseBindlessDebugSip, false, "Use bindless debug system routine") DECLARE_DEBUG_VARIABLE(std::string, ForceDeviceId, std::string("unk"), "DeviceId selected for testing") DECLARE_DEBUG_VARIABLE(int32_t, ForceL1Caching, -1, "-1: default, 0: disable, 1: enable, When set to true driver will program L1 cache policy for surface state and stateless accessess") DECLARE_DEBUG_VARIABLE(int32_t, ForceAuxTranslationEnabled, -1, "-1: default, 0: disabled, 1: enabled") 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 4143a052d4..153bd3ec3d 100644 --- a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp +++ b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp @@ -1054,7 +1054,34 @@ TEST_F(CompilerInterfaceTest, whenRequestingSipKernelBinaryThenProperSystemRouti gEnvironment->igcPopDebugVars(); } -TEST_F(CompilerInterfaceTest, whenRequestingIvalidSipKernelBinaryThenErrorIsReturned) { +TEST_F(CompilerInterfaceTest, givenUseBindlessDebugSipWhenRequestingSipKernelBinaryThenProperSystemRoutineIsSelectedFromCompiler) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.UseBindlessDebugSip.set(true); + MockCompilerDebugVars igcDebugVars; + gEnvironment->igcPushDebugVars(igcDebugVars); + std::vector sipBinary; + auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary); + 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); + 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); + EXPECT_EQ(TranslationOutput::ErrorCode::Success, err); + EXPECT_NE(0U, sipBinary.size()); + EXPECT_EQ(IGC::SystemRoutineType::debugSlm, getIgcDebugVars().typeOfSystemRoutine); + EXPECT_EQ(MockCompilerDebugVars::SipAddressingType::bindless, getIgcDebugVars().receivedSipAddressingType); + + gEnvironment->igcPopDebugVars(); +} + +TEST_F(CompilerInterfaceTest, whenRequestingInvalidSipKernelBinaryThenErrorIsReturned) { MockCompilerDebugVars igcDebugVars; gEnvironment->igcPushDebugVars(igcDebugVars); std::vector sipBinary;