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 <mateusz.hoppe@intel.com>
This commit is contained in:
parent
45276d10cc
commit
aa79af46ac
|
@ -87,20 +87,24 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::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<GfxFamily>(commandQueuePreemptionMode,
|
||||
devicePreemption) +
|
||||
NEO::PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*neoDevice);
|
||||
|
||||
if (NEO::Debugger::isDebugEnabled(internalUsage)) {
|
||||
preemptionSize += NEO::PreemptionHelper::getRequiredStateSipCmdSize<GfxFamily>(*neoDevice);
|
||||
}
|
||||
statePreemption = devicePreemption;
|
||||
if (initialPreemptionMode) {
|
||||
preemptionSize += NEO::PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*neoDevice);
|
||||
}
|
||||
|
||||
if ((initialPreemptionMode && devicePreemption == NEO::PreemptionMode::MidThread) ||
|
||||
(neoDevice->getDebugger() && NEO::Debugger::isDebugEnabled(internalUsage))) {
|
||||
preemptionSize += NEO::PreemptionHelper::getRequiredStateSipCmdSize<GfxFamily>(*neoDevice);
|
||||
}
|
||||
|
||||
preemptionSize += NEO::PreemptionHelper::getRequiredCmdStreamSize<GfxFamily>(devicePreemption, commandQueuePreemptionMode);
|
||||
statePreemption = devicePreemption;
|
||||
|
||||
if (NEO::Debugger::isDebugEnabled(internalUsage) && !commandQueueDebugCmdsProgrammed) {
|
||||
debuggerCmdsSize += NEO::PreambleHelper<GfxFamily>::getKernelDebuggingCommandsSize(neoDevice->isDebuggerActive());
|
||||
}
|
||||
|
@ -235,19 +239,22 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
|
|||
programStateBaseAddress(scratchSpaceController->calculateNewGSH(), indirectHeap->getGraphicsAllocation()->isAllocatedInLocalMemoryPool(), child);
|
||||
}
|
||||
|
||||
if (commandQueuePreemptionMode == NEO::PreemptionMode::Initial) {
|
||||
if (initialPreemptionMode) {
|
||||
NEO::PreemptionHelper::programCsrBaseAddress<GfxFamily>(child, *neoDevice, csr->getPreemptionAllocation());
|
||||
if (NEO::Debugger::isDebugEnabled(internalUsage)) {
|
||||
NEO::PreemptionHelper::programStateSip<GfxFamily>(child, *neoDevice);
|
||||
}
|
||||
NEO::PreemptionHelper::programCmdStream<GfxFamily>(child,
|
||||
devicePreemption,
|
||||
commandQueuePreemptionMode,
|
||||
csr->getPreemptionAllocation());
|
||||
commandQueuePreemptionMode = devicePreemption;
|
||||
statePreemption = commandQueuePreemptionMode;
|
||||
}
|
||||
|
||||
if ((initialPreemptionMode && devicePreemption == NEO::PreemptionMode::MidThread) ||
|
||||
(neoDevice->getDebugger() && NEO::Debugger::isDebugEnabled(internalUsage))) {
|
||||
NEO::PreemptionHelper::programStateSip<GfxFamily>(child, *neoDevice);
|
||||
}
|
||||
|
||||
NEO::PreemptionHelper::programCmdStream<GfxFamily>(child,
|
||||
devicePreemption,
|
||||
commandQueuePreemptionMode,
|
||||
csr->getPreemptionAllocation());
|
||||
commandQueuePreemptionMode = devicePreemption;
|
||||
statePreemption = commandQueuePreemptionMode;
|
||||
|
||||
const bool sipKernelUsed = devicePreemption == NEO::PreemptionMode::MidThread ||
|
||||
(neoDevice->getDebugger() != nullptr && NEO::Debugger::isDebugEnabled(internalUsage));
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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 <level_zero/ze_api.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::AnyNumber;
|
||||
using ::testing::Return;
|
||||
|
||||
using CommandQueueExecuteCommandListsGen9 = Test<DeviceFixture>;
|
||||
|
||||
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<MEDIA_VFE_STATE *>(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<PIPELINE_SELECT *>(cmdList.begin(), itorVFE);
|
||||
ASSERT_NE(itorPS, itorVFE);
|
||||
{
|
||||
auto cmd = genCmdCast<PIPELINE_SELECT *>(*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<STATE_BASE_ADDRESS *>(cmdList.begin(), cmdList.end());
|
||||
ASSERT_NE(itorSba, cmdList.end());
|
||||
{
|
||||
auto cmd = genCmdCast<STATE_BASE_ADDRESS *>(*itorSba);
|
||||
EXPECT_TRUE(cmd->getGeneralStateBaseAddressModifyEnable());
|
||||
EXPECT_EQ(0u, cmd->getGeneralStateBaseAddress());
|
||||
EXPECT_TRUE(cmd->getGeneralStateBufferSizeModifyEnable());
|
||||
uint32_t expectedGsbaSize = std::numeric_limits<uint32_t>::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<GPGPU_CSR_BASE_ADDRESS *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(itorCsr, cmdList.end());
|
||||
|
||||
auto itorStateSip = find<STATE_SIP *>(itorCsr, cmdList.end());
|
||||
EXPECT_NE(itorStateSip, cmdList.end());
|
||||
|
||||
auto itorLri = find<MI_LOAD_REGISTER_IMM *>(itorStateSip, cmdList.end());
|
||||
EXPECT_NE(itorLri, cmdList.end());
|
||||
|
||||
MI_LOAD_REGISTER_IMM *lriCmd = static_cast<MI_LOAD_REGISTER_IMM *>(*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<GPGPU_CSR_BASE_ADDRESS *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(itorCsr, cmdList.end());
|
||||
|
||||
auto itorStateSip = find<STATE_SIP *>(itorCsr, cmdList.end());
|
||||
EXPECT_NE(itorStateSip, cmdList.end());
|
||||
|
||||
auto itorLri = find<MI_LOAD_REGISTER_IMM *>(itorStateSip, cmdList.end());
|
||||
EXPECT_NE(itorLri, cmdList.end());
|
||||
|
||||
MI_LOAD_REGISTER_IMM *lriCmd = static_cast<MI_LOAD_REGISTER_IMM *>(*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<MI_BATCH_BUFFER_START *>(itorLri, cmdList.end());
|
||||
EXPECT_NE(itorBBStart, cmdList.end());
|
||||
|
||||
//next should be PIPE_CONTROL and LRI switching to thread-group
|
||||
auto itorPipeControl = find<PIPE_CONTROL *>(itorBBStart, cmdList.end());
|
||||
EXPECT_NE(itorPipeControl, cmdList.end());
|
||||
|
||||
itorLri = find<MI_LOAD_REGISTER_IMM *>(itorPipeControl, cmdList.end());
|
||||
EXPECT_NE(itorLri, cmdList.end());
|
||||
|
||||
lriCmd = static_cast<MI_LOAD_REGISTER_IMM *>(*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<MI_BATCH_BUFFER_START *>(itorLri, cmdList.end());
|
||||
EXPECT_NE(itorBBStart, cmdList.end());
|
||||
|
||||
//next should be PIPE_CONTROL and LRI switching to mid-thread again
|
||||
itorPipeControl = find<PIPE_CONTROL *>(itorBBStart, cmdList.end());
|
||||
EXPECT_NE(itorPipeControl, cmdList.end());
|
||||
|
||||
itorLri = find<MI_LOAD_REGISTER_IMM *>(itorPipeControl, cmdList.end());
|
||||
EXPECT_NE(itorLri, cmdList.end());
|
||||
|
||||
lriCmd = static_cast<MI_LOAD_REGISTER_IMM *>(*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<MI_BATCH_BUFFER_START *>(itorLri, cmdList.end());
|
||||
EXPECT_NE(itorBBStart, cmdList.end());
|
||||
|
||||
commandListMidThread->destroy();
|
||||
commandListThreadGroup->destroy();
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
|
@ -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<bool, 2> 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<STATE_SIP *>(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<STATE_SIP *>(*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<bool, 2> 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<STATE_SIP *>(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<STATE_SIP *>(*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<STATE_SIP *>(cmdList2.begin(), cmdList2.end());
|
||||
EXPECT_EQ(cmdList2.end(), itorSip);
|
||||
|
||||
commandQueue->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
|
|
@ -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<MockCommandQueueHw<gfxCoreFamily>, Deleter> commandQueue(new MockCommandQueueHw<gfxCoreFamily>(deviceL0, device->getDefaultEngine().commandStreamReceiver, &queueDesc));
|
||||
commandQueue->initialize(false, true);
|
||||
EXPECT_TRUE(commandQueue->internalUsage);
|
||||
|
|
Loading…
Reference in New Issue