Refactor SBA handling + fix unit tests

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2022-06-28 18:52:33 +00:00
committed by Compute-Runtime-Automation
parent 8351fc9f14
commit f2bbd63d37
32 changed files with 222 additions and 177 deletions

View File

@@ -40,7 +40,7 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
NEO::EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(commandStream, hwInfo, isRcs);
NEO::EncodeWA<GfxFamily>::encodeAdditionalPipelineSelect(commandStream, {}, true, hwInfo, isRcs);
auto pSbaCmd = static_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS)));
auto sbaCmdBuf = static_cast<STATE_BASE_ADDRESS *>(NEO::StateBaseAddressHelper<GfxFamily>::getSpaceForSbaCmd(commandStream));
STATE_BASE_ADDRESS sbaCmd;
bool useGlobalSshAndDsh = NEO::ApiSpecificConfig::getBindlessConfiguration();
@@ -69,7 +69,7 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
NEO::MemoryCompressionState::NotApplicable,
false,
1u);
*pSbaCmd = sbaCmd;
*sbaCmdBuf = sbaCmd;
csr->setGSBAStateDirty(false);
if (NEO::Debugger::isDebugEnabled(internalUsage) && device->getL0Debugger()) {

View File

@@ -31,7 +31,8 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
bool isRcs = this->getCsr()->isRcs();
NEO::EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(commandStream, hwInfo, isRcs);
auto pSbaCmd = static_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS)));
auto sbaCmdBuf = static_cast<STATE_BASE_ADDRESS *>(NEO::StateBaseAddressHelper<GfxFamily>::getSpaceForSbaCmd(commandStream));
STATE_BASE_ADDRESS sbaCmd;
bool multiOsContextCapable = device->isImplicitScalingCapable();
NEO::StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(&sbaCmd,
@@ -51,12 +52,12 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
NEO::MemoryCompressionState::NotApplicable,
false,
1u);
*pSbaCmd = sbaCmd;
*sbaCmdBuf = sbaCmd;
auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
if (hwInfoConfig.isAdditionalStateBaseAddressWARequired(hwInfo)) {
pSbaCmd = static_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS)));
*pSbaCmd = sbaCmd;
sbaCmdBuf = static_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS)));
*sbaCmdBuf = sbaCmd;
}
if (NEO::Debugger::isDebugEnabled(internalUsage) && device->getL0Debugger()) {

View File

@@ -861,8 +861,14 @@ HWTEST2_F(HostPointerManagerCommandListTest, givenCommandListWhenMemoryFillWithS
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed()));
auto itor = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itor);
auto pc = genCmdCast<PIPE_CONTROL *>(*cmdList.rbegin());
if (NEO::MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, device->getHwInfo())) {
EXPECT_NE(nullptr, pc);
EXPECT_TRUE(pc->getDcFlushEnable());
} else {
EXPECT_EQ(nullptr, pc);
}
}
using SupportedPlatformsSklIcllp = IsWithinProducts<IGFX_SKYLAKE, IGFX_ICELAKE>;

View File

@@ -594,6 +594,8 @@ HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenAppendWaitEventsWith
HWTEST_F(CommandListCreate, givenCommandListyWhenAppendWaitEventsWithDcFlushThenPipeControlIsProgrammed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue));
auto &commandContainer = commandList->commandContainer;
@@ -605,9 +607,19 @@ HWTEST_F(CommandListCreate, givenCommandListyWhenAppendWaitEventsWithDcFlushThen
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed()));
auto itor = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
auto itor = find<SEMAPHORE_WAIT *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itor);
if (NEO::MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, device->getHwInfo())) {
itor--;
EXPECT_NE(nullptr, genCmdCast<PIPE_CONTROL *>(*itor));
} else {
if (cmdList.begin() != itor) {
itor--;
EXPECT_EQ(nullptr, genCmdCast<PIPE_CONTROL *>(*itor));
}
}
}
HWTEST_F(CommandListCreate, givenCommandListWhenAppendWaitEventsWithDcFlushThenPipeControlIsProgrammedOnlyOnce) {
@@ -627,11 +639,18 @@ HWTEST_F(CommandListCreate, givenCommandListWhenAppendWaitEventsWithDcFlushThenP
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed()));
auto itor = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
auto itor = find<SEMAPHORE_WAIT *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itor);
itor++;
auto itor2 = find<SEMAPHORE_WAIT *>(itor, cmdList.end());
EXPECT_NE(cmdList.end(), itor2);
if (NEO::MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, device->getHwInfo())) {
itor--;
EXPECT_NE(nullptr, genCmdCast<PIPE_CONTROL *>(*itor));
} else {
if (cmdList.begin() != itor) {
itor--;
EXPECT_EQ(nullptr, genCmdCast<PIPE_CONTROL *>(*itor));
}
}
}
HWTEST_F(CommandListCreate, givenAsyncCmdQueueAndImmediateCommandListWhenAppendWaitEventsWithHostScopeThenPipeControlAndSemWaitAreAddedFromCommandList) {

View File

@@ -452,14 +452,15 @@ HWTEST2_F(CommandListCreate, givenCommandListAndHostPointersWhenMemoryCopyCalled
GenCmdList genCmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
genCmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed()));
auto itor = find<PIPE_CONTROL *>(genCmdList.begin(), genCmdList.end());
ASSERT_NE(genCmdList.end(), itor);
PIPE_CONTROL *cmd = nullptr;
while (itor != genCmdList.end()) {
cmd = genCmdCast<PIPE_CONTROL *>(*itor);
itor = find<PIPE_CONTROL *>(++itor, genCmdList.end());
auto pc = genCmdCast<PIPE_CONTROL *>(*genCmdList.rbegin());
if (NEO::MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, device->getHwInfo())) {
EXPECT_NE(nullptr, pc);
EXPECT_TRUE(pc->getDcFlushEnable());
} else {
EXPECT_EQ(nullptr, pc);
}
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, *defaultHwInfo), cmd->getDcFlushEnable()); // NOLINT(clang-analyzer-core.CallAndMessage)
}
} // namespace ult

View File

@@ -106,14 +106,15 @@ HWTEST2_F(AppendMemoryCopy, givenCommandListAndHostPointersWhenMemoryCopyRegionC
GenCmdList genCmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
genCmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), commandContainer.getCommandStream()->getUsed()));
auto itor = find<PIPE_CONTROL *>(genCmdList.begin(), genCmdList.end());
ASSERT_NE(genCmdList.end(), itor);
PIPE_CONTROL *cmd = nullptr;
while (itor != genCmdList.end()) {
cmd = genCmdCast<PIPE_CONTROL *>(*itor);
itor = find<PIPE_CONTROL *>(++itor, genCmdList.end());
auto pc = genCmdCast<PIPE_CONTROL *>(*genCmdList.rbegin());
if (NEO::MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, device->getHwInfo())) {
EXPECT_NE(nullptr, pc);
EXPECT_TRUE(pc->getDcFlushEnable());
} else {
EXPECT_EQ(nullptr, pc);
}
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, *defaultHwInfo), cmd->getDcFlushEnable()); // NOLINT(clang-analyzer-core.CallAndMessage)
}
HWTEST2_F(AppendMemoryCopy, givenImmediateCommandListWhenAppendingMemoryCopyThenSuccessIsReturned, IsAtLeastSkl) {

View File

@@ -112,6 +112,7 @@ HWTEST_F(CommandListAppendWaitOnEvent, WhenAppendingWaitOnEventsThenEventGraphic
HWTEST_F(CommandListAppendWaitOnEvent, givenEventWithWaitScopeFlagDeviceWhenAppendingWaitOnEventThenPCWithDcFlushIsGenerated) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
auto usedSpaceBefore = commandList->commandContainer.getCommandStream()->getUsed();
const ze_event_desc_t eventDesc = {
@@ -134,14 +135,21 @@ HWTEST_F(CommandListAppendWaitOnEvent, givenEventWithWaitScopeFlagDeviceWhenAppe
ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0),
usedSpaceAfter));
auto itorPC = findAll<PIPE_CONTROL *>(cmdList.begin(), cmdList.end()).back();
ASSERT_NE(cmdList.end(), itorPC);
{
auto cmd = genCmdCast<PIPE_CONTROL *>(*itorPC);
ASSERT_NE(cmd, nullptr);
auto itor = find<MI_SEMAPHORE_WAIT *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itor);
if (NEO::MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, device->getHwInfo())) {
itor--;
auto cmd = genCmdCast<PIPE_CONTROL *>(*itor);
ASSERT_NE(nullptr, cmd);
EXPECT_TRUE(cmd->getCommandStreamerStallEnable());
EXPECT_EQ(MemorySynchronizationCommands<FamilyType>::getDcFlushEnable(true, *defaultHwInfo), cmd->getDcFlushEnable());
EXPECT_TRUE(cmd->getDcFlushEnable());
} else {
if (cmdList.begin() != itor) {
itor--;
EXPECT_EQ(nullptr, genCmdCast<PIPE_CONTROL *>(*itor));
}
}
}