From aa79af46acf4274a1d49e40e9fbe2c998dc58516 Mon Sep 17 00:00:00 2001 From: Mateusz Hoppe Date: Wed, 27 Jan 2021 18:59:10 +0100 Subject: [PATCH] Fix state sip programming - STATE_SIP should be added once for MidThread preemption or when debugger is used for non internal cmdQs Signed-off-by: Mateusz Hoppe --- .../core/source/cmdqueue/cmdqueue_hw.inl | 43 +-- .../core/test/unit_tests/gen9/CMakeLists.txt | 3 +- .../test_cmdqueue_enqueuecommandlist_gen9.cpp | 261 ++++++++++++++++++ .../test_cmdqueue_enqueuecommandlist.cpp | 119 ++++++++ .../debugger/test_source_level_debugger.cpp | 4 +- 5 files changed, 410 insertions(+), 20 deletions(-) create mode 100644 level_zero/core/test/unit_tests/gen9/test_cmdqueue_enqueuecommandlist_gen9.cpp diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl index 6b30b1a7b6..fed277d819 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl @@ -87,20 +87,24 @@ ze_result_t CommandQueueHw::executeCommandLists( constexpr size_t residencyContainerSpaceForFence = 1; constexpr size_t residencyContainerSpaceForTagWrite = 1; + const bool initialPreemptionMode = commandQueuePreemptionMode == NEO::PreemptionMode::Initial; + NEO::Device *neoDevice = device->getNEODevice(); NEO::PreemptionMode statePreemption = commandQueuePreemptionMode; auto devicePreemption = device->getDevicePreemptionMode(); - if (commandQueuePreemptionMode == NEO::PreemptionMode::Initial) { - preemptionSize += NEO::PreemptionHelper::getRequiredCmdStreamSize(commandQueuePreemptionMode, - devicePreemption) + - NEO::PreemptionHelper::getRequiredPreambleSize(*neoDevice); - if (NEO::Debugger::isDebugEnabled(internalUsage)) { - preemptionSize += NEO::PreemptionHelper::getRequiredStateSipCmdSize(*neoDevice); - } - statePreemption = devicePreemption; + if (initialPreemptionMode) { + preemptionSize += NEO::PreemptionHelper::getRequiredPreambleSize(*neoDevice); } + if ((initialPreemptionMode && devicePreemption == NEO::PreemptionMode::MidThread) || + (neoDevice->getDebugger() && NEO::Debugger::isDebugEnabled(internalUsage))) { + preemptionSize += NEO::PreemptionHelper::getRequiredStateSipCmdSize(*neoDevice); + } + + preemptionSize += NEO::PreemptionHelper::getRequiredCmdStreamSize(devicePreemption, commandQueuePreemptionMode); + statePreemption = devicePreemption; + if (NEO::Debugger::isDebugEnabled(internalUsage) && !commandQueueDebugCmdsProgrammed) { debuggerCmdsSize += NEO::PreambleHelper::getKernelDebuggingCommandsSize(neoDevice->isDebuggerActive()); } @@ -235,19 +239,22 @@ ze_result_t CommandQueueHw::executeCommandLists( programStateBaseAddress(scratchSpaceController->calculateNewGSH(), indirectHeap->getGraphicsAllocation()->isAllocatedInLocalMemoryPool(), child); } - if (commandQueuePreemptionMode == NEO::PreemptionMode::Initial) { + if (initialPreemptionMode) { NEO::PreemptionHelper::programCsrBaseAddress(child, *neoDevice, csr->getPreemptionAllocation()); - if (NEO::Debugger::isDebugEnabled(internalUsage)) { - NEO::PreemptionHelper::programStateSip(child, *neoDevice); - } - NEO::PreemptionHelper::programCmdStream(child, - devicePreemption, - commandQueuePreemptionMode, - csr->getPreemptionAllocation()); - commandQueuePreemptionMode = devicePreemption; - statePreemption = commandQueuePreemptionMode; } + if ((initialPreemptionMode && devicePreemption == NEO::PreemptionMode::MidThread) || + (neoDevice->getDebugger() && NEO::Debugger::isDebugEnabled(internalUsage))) { + NEO::PreemptionHelper::programStateSip(child, *neoDevice); + } + + NEO::PreemptionHelper::programCmdStream(child, + devicePreemption, + commandQueuePreemptionMode, + csr->getPreemptionAllocation()); + commandQueuePreemptionMode = devicePreemption; + statePreemption = commandQueuePreemptionMode; + const bool sipKernelUsed = devicePreemption == NEO::PreemptionMode::MidThread || (neoDevice->getDebugger() != nullptr && NEO::Debugger::isDebugEnabled(internalUsage)); diff --git a/level_zero/core/test/unit_tests/gen9/CMakeLists.txt b/level_zero/core/test/unit_tests/gen9/CMakeLists.txt index 68a02e8bc1..d659bbaae6 100644 --- a/level_zero/core/test/unit_tests/gen9/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/gen9/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 Intel Corporation +# Copyright (C) 2020-2021 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -10,6 +10,7 @@ if(TESTS_GEN9) ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/enable_l0_mocks_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_launch_kernel_gen9.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdqueue_enqueuecommandlist_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdqueue_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_device_gen9.cpp ) diff --git a/level_zero/core/test/unit_tests/gen9/test_cmdqueue_enqueuecommandlist_gen9.cpp b/level_zero/core/test/unit_tests/gen9/test_cmdqueue_enqueuecommandlist_gen9.cpp new file mode 100644 index 0000000000..2de65105c4 --- /dev/null +++ b/level_zero/core/test/unit_tests/gen9/test_cmdqueue_enqueuecommandlist_gen9.cpp @@ -0,0 +1,261 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/linear_stream.h" +#include "shared/source/command_stream/preemption.h" +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/memory_manager/graphics_allocation.h" +#include "shared/test/unit_test/cmd_parse/gen_cmd_parse.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" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" +#include "level_zero/core/test/unit_tests/mocks/mock_device.h" +#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h" +#include + +#include "gtest/gtest.h" + +#include + +namespace L0 { +namespace ult { + +using ::testing::_; +using ::testing::AnyNumber; +using ::testing::Return; + +using CommandQueueExecuteCommandListsGen9 = Test; + +GEN9TEST_F(CommandQueueExecuteCommandListsGen9, WhenExecutingCmdListsThenPipelineSelectAndVfeStateAreAddedToCmdBuffer) { + const ze_command_queue_desc_t desc = {}; + ze_result_t returnValue; + auto commandQueue = whitebox_cast(CommandQueue::create( + productFamily, + device, neoDevice->getDefaultEngine().commandStreamReceiver, &desc, false, false, returnValue)); + ASSERT_NE(nullptr, commandQueue->commandStream); + auto usedSpaceBefore = commandQueue->commandStream->getUsed(); + + ze_command_list_handle_t commandLists[] = { + CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue)->toHandle()}; + uint32_t numCommandLists = sizeof(commandLists) / sizeof(commandLists[0]); + auto result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true); + + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + auto usedSpaceAfter = commandQueue->commandStream->getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(commandQueue->commandStream->getCpuBase(), 0), usedSpaceAfter)); + + using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE; + auto itorVFE = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(itorVFE, cmdList.end()); + + // Should have a PS before a VFE + using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; + auto itorPS = find(cmdList.begin(), itorVFE); + ASSERT_NE(itorPS, itorVFE); + { + auto cmd = genCmdCast(*itorPS); + EXPECT_EQ(cmd->getMaskBits() & 3u, 3u); + EXPECT_EQ(cmd->getPipelineSelection(), PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU); + } + + CommandList::fromHandle(commandLists[0])->destroy(); + commandQueue->destroy(); +} + +GEN9TEST_F(CommandQueueExecuteCommandListsGen9, WhenExecutingCmdListsThenStateBaseAddressForGeneralStateBaseAddressIsAdded) { + const ze_command_queue_desc_t desc = {}; + ze_result_t returnValue; + auto commandQueue = whitebox_cast(CommandQueue::create( + productFamily, + device, neoDevice->getDefaultEngine().commandStreamReceiver, &desc, false, false, returnValue)); + ASSERT_NE(nullptr, commandQueue->commandStream); + auto usedSpaceBefore = commandQueue->commandStream->getUsed(); + + ze_command_list_handle_t commandLists[] = { + CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue)->toHandle()}; + uint32_t numCommandLists = sizeof(commandLists) / sizeof(commandLists[0]); + auto result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true); + + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + auto usedSpaceAfter = commandQueue->commandStream->getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(commandQueue->commandStream->getCpuBase(), 0), usedSpaceAfter)); + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + + auto itorSba = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(itorSba, cmdList.end()); + { + auto cmd = genCmdCast(*itorSba); + EXPECT_TRUE(cmd->getGeneralStateBaseAddressModifyEnable()); + EXPECT_EQ(0u, cmd->getGeneralStateBaseAddress()); + EXPECT_TRUE(cmd->getGeneralStateBufferSizeModifyEnable()); + uint32_t expectedGsbaSize = std::numeric_limits::max(); + expectedGsbaSize >>= 12; + EXPECT_EQ(expectedGsbaSize, cmd->getGeneralStateBufferSize()); + + EXPECT_TRUE(cmd->getInstructionBaseAddressModifyEnable()); + EXPECT_TRUE(cmd->getInstructionBufferSizeModifyEnable()); + EXPECT_EQ(MemoryConstants::sizeOf4GBinPageEntities, cmd->getInstructionBufferSize()); + EXPECT_EQ(device->getDriverHandle()->getMemoryManager()->getInternalHeapBaseAddress(0, false), + cmd->getInstructionBaseAddress()); + EXPECT_EQ(commandQueue->getDevice()->getNEODevice()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER), + cmd->getInstructionMemoryObjectControlState()); + } + + CommandList::fromHandle(commandLists[0])->destroy(); + commandQueue->destroy(); +} + +GEN9TEST_F(CommandQueueExecuteCommandListsGen9, WhenExecutingCmdListsThenMidThreadPreemptionForFirstExecuteIsConfigured) { + const ze_command_queue_desc_t desc = {}; + ze_result_t returnValue; + auto commandQueue = whitebox_cast(CommandQueue::create( + productFamily, + device, neoDevice->getDefaultEngine().commandStreamReceiver, &desc, false, false, returnValue)); + ASSERT_NE(nullptr, commandQueue->commandStream); + auto usedSpaceBefore = commandQueue->commandStream->getUsed(); + + auto commandList = whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue)); + commandList->commandListPreemptionMode = NEO::PreemptionMode::MidThread; + + ze_command_list_handle_t commandLists[] = {commandList->toHandle()}; + uint32_t numCommandLists = sizeof(commandLists) / sizeof(commandLists[0]); + + auto result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true); + + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + auto usedSpaceAfter = commandQueue->commandStream->getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(commandQueue->commandStream->getCpuBase(), 0), usedSpaceAfter)); + using STATE_SIP = typename FamilyType::STATE_SIP; + using GPGPU_CSR_BASE_ADDRESS = typename FamilyType::GPGPU_CSR_BASE_ADDRESS; + using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; + + auto itorCsr = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(itorCsr, cmdList.end()); + + auto itorStateSip = find(itorCsr, cmdList.end()); + EXPECT_NE(itorStateSip, cmdList.end()); + + auto itorLri = find(itorStateSip, cmdList.end()); + EXPECT_NE(itorLri, cmdList.end()); + + MI_LOAD_REGISTER_IMM *lriCmd = static_cast(*itorLri); + EXPECT_EQ(0x2580u, lriCmd->getRegisterOffset()); + uint32_t data = ((1 << 1) | (1 << 2)) << 16; + EXPECT_EQ(data, lriCmd->getDataDword()); + + commandList->destroy(); + commandQueue->destroy(); +} + +GEN9TEST_F(CommandQueueExecuteCommandListsGen9, GivenCmdListsWithDifferentPreemptionModesWhenExecutingThenQueuePreemptionIsSwitchedFromMidThreadToThreadGroupAndMidThread) { + const ze_command_queue_desc_t desc = {}; + ze_result_t returnValue; + auto commandQueue = whitebox_cast(CommandQueue::create( + productFamily, + device, neoDevice->getDefaultEngine().commandStreamReceiver, &desc, false, false, returnValue)); + ASSERT_NE(nullptr, commandQueue->commandStream); + auto usedSpaceBefore = commandQueue->commandStream->getUsed(); + + auto commandListMidThread = whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue)); + commandListMidThread->commandListPreemptionMode = NEO::PreemptionMode::MidThread; + + auto commandListThreadGroup = whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue)); + commandListThreadGroup->commandListPreemptionMode = NEO::PreemptionMode::ThreadGroup; + + ze_command_list_handle_t commandLists[] = {commandListMidThread->toHandle(), + commandListThreadGroup->toHandle(), + commandListMidThread->toHandle()}; + uint32_t numCommandLists = sizeof(commandLists) / sizeof(commandLists[0]); + auto result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true); + + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + auto usedSpaceAfter = commandQueue->commandStream->getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, commandQueue->commandStream->getCpuBase(), usedSpaceAfter)); + using STATE_SIP = typename FamilyType::STATE_SIP; + using GPGPU_CSR_BASE_ADDRESS = typename FamilyType::GPGPU_CSR_BASE_ADDRESS; + using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; + using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + + auto itorCsr = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(itorCsr, cmdList.end()); + + auto itorStateSip = find(itorCsr, cmdList.end()); + EXPECT_NE(itorStateSip, cmdList.end()); + + auto itorLri = find(itorStateSip, cmdList.end()); + EXPECT_NE(itorLri, cmdList.end()); + + MI_LOAD_REGISTER_IMM *lriCmd = static_cast(*itorLri); + EXPECT_EQ(0x2580u, lriCmd->getRegisterOffset()); + uint32_t data = ((1 << 1) | (1 << 2)) << 16; + EXPECT_EQ(data, lriCmd->getDataDword()); + + //next should be BB_START to 1st Mid-Thread Cmd List + auto itorBBStart = find(itorLri, cmdList.end()); + EXPECT_NE(itorBBStart, cmdList.end()); + + //next should be PIPE_CONTROL and LRI switching to thread-group + auto itorPipeControl = find(itorBBStart, cmdList.end()); + EXPECT_NE(itorPipeControl, cmdList.end()); + + itorLri = find(itorPipeControl, cmdList.end()); + EXPECT_NE(itorLri, cmdList.end()); + + lriCmd = static_cast(*itorLri); + EXPECT_EQ(0x2580u, lriCmd->getRegisterOffset()); + data = (1 << 1) | (((1 << 1) | (1 << 2)) << 16); + EXPECT_EQ(data, lriCmd->getDataDword()); + //start of thread-group command list + itorBBStart = find(itorLri, cmdList.end()); + EXPECT_NE(itorBBStart, cmdList.end()); + + //next should be PIPE_CONTROL and LRI switching to mid-thread again + itorPipeControl = find(itorBBStart, cmdList.end()); + EXPECT_NE(itorPipeControl, cmdList.end()); + + itorLri = find(itorPipeControl, cmdList.end()); + EXPECT_NE(itorLri, cmdList.end()); + + lriCmd = static_cast(*itorLri); + EXPECT_EQ(0x2580u, lriCmd->getRegisterOffset()); + data = ((1 << 1) | (1 << 2)) << 16; + EXPECT_EQ(data, lriCmd->getDataDword()); + //start of thread-group command list + itorBBStart = find(itorLri, cmdList.end()); + EXPECT_NE(itorBBStart, cmdList.end()); + + commandListMidThread->destroy(); + commandListThreadGroup->destroy(); + commandQueue->destroy(); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_enqueuecommandlist.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_enqueuecommandlist.cpp index 7a1bb61a52..2be715574c 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_enqueuecommandlist.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_enqueuecommandlist.cpp @@ -258,5 +258,124 @@ HWTEST2_F(CommandQueueExecuteCommandLists, givenCommandQueueHaving2CommandListsT commandQueue->destroy(); } +HWTEST_F(CommandQueueExecuteCommandLists, givenMidThreadPreemptionWhenCommandsAreExecutedThenStateSipIsAdded) { + using STATE_SIP = typename FamilyType::STATE_SIP; + using PARSE = typename FamilyType::PARSE; + + ze_command_queue_desc_t desc{}; + desc.ordinal = 0u; + desc.index = 0u; + desc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; + + std::array testedInternalFlags = {true, false}; + + for (auto flagInternal : testedInternalFlags) { + ze_result_t returnValue; + auto commandQueue = whitebox_cast(CommandQueue::create(productFamily, + device, + neoDevice->getDefaultEngine().commandStreamReceiver, + &desc, + false, + flagInternal, + returnValue)); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + + ASSERT_NE(nullptr, commandQueue->commandStream); + + auto usedSpaceBefore = commandQueue->commandStream->getUsed(); + + auto result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + auto usedSpaceAfter = commandQueue->commandStream->getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(PARSE::parseCommandBuffer(cmdList, ptrOffset(commandQueue->commandStream->getCpuBase(), 0), usedSpaceAfter)); + + auto itorSip = find(cmdList.begin(), cmdList.end()); + + auto preemptionMode = neoDevice->getPreemptionMode(); + if (preemptionMode == NEO::PreemptionMode::MidThread) { + EXPECT_NE(cmdList.end(), itorSip); + + auto sipAllocation = SipKernel::getSipKernelAllocation(*neoDevice); + STATE_SIP *stateSipCmd = reinterpret_cast(*itorSip); + EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer()); + } else { + EXPECT_EQ(cmdList.end(), itorSip); + } + commandQueue->destroy(); + } +} + +HWTEST_F(CommandQueueExecuteCommandLists, givenMidThreadPreemptionWhenCommandsAreExecutedTwoTimesThenStateSipIsAddedOnlyTheFirstTime) { + using STATE_SIP = typename FamilyType::STATE_SIP; + using PARSE = typename FamilyType::PARSE; + + ze_command_queue_desc_t desc{}; + desc.ordinal = 0u; + desc.index = 0u; + desc.priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL; + + std::array testedInternalFlags = {true, false}; + + for (auto flagInternal : testedInternalFlags) { + ze_result_t returnValue; + auto commandQueue = whitebox_cast(CommandQueue::create(productFamily, + device, + neoDevice->getDefaultEngine().commandStreamReceiver, + &desc, + false, + flagInternal, + returnValue)); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + + ASSERT_NE(nullptr, commandQueue->commandStream); + + auto usedSpaceBefore = commandQueue->commandStream->getUsed(); + + auto result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + result = commandQueue->synchronize(0); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + auto usedSpaceAfter = commandQueue->commandStream->getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + + GenCmdList cmdList; + ASSERT_TRUE(PARSE::parseCommandBuffer(cmdList, ptrOffset(commandQueue->commandStream->getCpuBase(), 0), usedSpaceAfter)); + + auto itorSip = find(cmdList.begin(), cmdList.end()); + + auto preemptionMode = neoDevice->getPreemptionMode(); + if (preemptionMode == NEO::PreemptionMode::MidThread) { + EXPECT_NE(cmdList.end(), itorSip); + + auto sipAllocation = SipKernel::getSipKernelAllocation(*neoDevice); + STATE_SIP *stateSipCmd = reinterpret_cast(*itorSip); + EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), stateSipCmd->getSystemInstructionPointer()); + } else { + EXPECT_EQ(cmdList.end(), itorSip); + } + + result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + result = commandQueue->synchronize(0); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + + auto usedSpaceAfterSecondExec = commandQueue->commandStream->getUsed(); + GenCmdList cmdList2; + ASSERT_TRUE(PARSE::parseCommandBuffer(cmdList2, ptrOffset(commandQueue->commandStream->getCpuBase(), usedSpaceAfter), usedSpaceAfterSecondExec)); + + itorSip = find(cmdList2.begin(), cmdList2.end()); + EXPECT_EQ(cmdList2.end(), itorSip); + + commandQueue->destroy(); + } +} + } // namespace ult } // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp index e16107af7c..afaa5a4840 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_source_level_debugger.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -170,6 +170,8 @@ HWTEST2_F(SLDebuggerInternalUsageTest, givenDebuggingEnabledWhenInternalCmdQIsUs } }; + device->setPreemptionMode(NEO::PreemptionMode::Disabled); + std::unique_ptr, Deleter> commandQueue(new MockCommandQueueHw(deviceL0, device->getDefaultEngine().commandStreamReceiver, &queueDesc)); commandQueue->initialize(false, true); EXPECT_TRUE(commandQueue->internalUsage);