performance(ocl): program barrier pc in taskStream

Program barrier immediately to task stream.
This will reduce the number of batch buffer starts.

Related-To: NEO-8147

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2023-08-30 15:06:48 +00:00
committed by Compute-Runtime-Automation
parent a38ac3557b
commit 839c2d6737
16 changed files with 163 additions and 40 deletions

View File

@@ -348,7 +348,12 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
void fillCsrDependenciesWithLastBcsPackets(CsrDependencies &csrDeps); void fillCsrDependenciesWithLastBcsPackets(CsrDependencies &csrDeps);
void clearLastBcsPackets(); void clearLastBcsPackets();
void setStallingCommandsOnNextFlush(const bool isStallingCommandsOnNextFlushRequired) { stallingCommandsOnNextFlushRequired = isStallingCommandsOnNextFlushRequired; } void setStallingCommandsOnNextFlush(const bool isStallingCommandsOnNextFlushRequired) {
stallingCommandsOnNextFlushRequired = isStallingCommandsOnNextFlushRequired;
if (!isStallingCommandsOnNextFlushRequired) {
dcFlushRequiredOnStallingCommandsOnNextFlush = false;
}
}
bool isStallingCommandsOnNextFlushRequired() const { return stallingCommandsOnNextFlushRequired; } bool isStallingCommandsOnNextFlushRequired() const { return stallingCommandsOnNextFlushRequired; }
void setDcFlushRequiredOnStallingCommandsOnNextFlush(const bool isDcFlushRequiredOnStallingCommandsOnNextFlush) { dcFlushRequiredOnStallingCommandsOnNextFlush = isDcFlushRequiredOnStallingCommandsOnNextFlush; } void setDcFlushRequiredOnStallingCommandsOnNextFlush(const bool isDcFlushRequiredOnStallingCommandsOnNextFlush) { dcFlushRequiredOnStallingCommandsOnNextFlush = isDcFlushRequiredOnStallingCommandsOnNextFlush; }

View File

@@ -272,11 +272,10 @@ cl_int CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
} else if (computeCommandStreamReceiver.peekTimestampPacketWriteEnabled()) { } else if (computeCommandStreamReceiver.peekTimestampPacketWriteEnabled()) {
if (CL_COMMAND_BARRIER == commandType && !isNonStallingIoqBarrier) { if (CL_COMMAND_BARRIER == commandType && !isNonStallingIoqBarrier) {
setStallingCommandsOnNextFlush(true); setStallingCommandsOnNextFlush(true);
if (NEO::DebugManager.flags.SkipDcFlushOnBarrierWithoutEvents.get() == 0 || event) { const bool isDcFlushRequiredOnBarrier = NEO::DebugManager.flags.SkipDcFlushOnBarrierWithoutEvents.get() == 0 || event;
setDcFlushRequiredOnStallingCommandsOnNextFlush(true); setDcFlushRequiredOnStallingCommandsOnNextFlush(isDcFlushRequiredOnBarrier);
}
this->splitBarrierRequired = true;
} }
this->splitBarrierRequired = true;
for (size_t i = 0; i < eventsRequest.numEventsInWaitList; i++) { for (size_t i = 0; i < eventsRequest.numEventsInWaitList; i++) {
auto waitlistEvent = castToObjectOrAbort<Event>(eventsRequest.eventWaitList[i]); auto waitlistEvent = castToObjectOrAbort<Event>(eventsRequest.eventWaitList[i]);
@@ -778,6 +777,18 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueNonBlocked(
UNRECOVERABLE_IF(multiDispatchInfo.empty()); UNRECOVERABLE_IF(multiDispatchInfo.empty());
if (!relaxedOrderingEnabled && !getGpgpuCommandStreamReceiver().isMultiTileOperationEnabled() && isStallingCommandsOnNextFlushRequired() && !isBlitAuxTranslationRequired(multiDispatchInfo)) {
CsrDependencies csrDeps{};
fillCsrDependenciesWithLastBcsPackets(csrDeps);
TimestampPacketHelper::programCsrDependenciesForTimestampPacketContainer<GfxFamily>(commandStream, csrDeps, false);
setupBarrierTimestampForBcsEngines(getGpgpuCommandStreamReceiver().getOsContext().getEngineType(), timestampPacketDependencies);
getGpgpuCommandStreamReceiver().programStallingCommandsForBarrier(commandStream, &timestampPacketDependencies.barrierNodes, isDcFlushRequiredOnStallingCommandsOnNextFlush());
clearLastBcsPackets();
setStallingCommandsOnNextFlush(false);
}
auto implicitFlush = false; auto implicitFlush = false;
if (printfHandler) { if (printfHandler) {
@@ -964,7 +975,6 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueNonBlocked(
if (isHandlingBarrier) { if (isHandlingBarrier) {
clearLastBcsPackets(); clearLastBcsPackets();
setStallingCommandsOnNextFlush(false); setStallingCommandsOnNextFlush(false);
setDcFlushRequiredOnStallingCommandsOnNextFlush(false);
} }
if (gtpinIsGTPinInitialized()) { if (gtpinIsGTPinInitialized()) {
@@ -1185,7 +1195,6 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueCommandWithoutKernel(
if (isHandlingBarrier) { if (isHandlingBarrier) {
clearLastBcsPackets(); clearLastBcsPackets();
setStallingCommandsOnNextFlush(false); setStallingCommandsOnNextFlush(false);
setDcFlushRequiredOnStallingCommandsOnNextFlush(false);
} }
} }

View File

@@ -273,7 +273,6 @@ CompletionStamp &CommandComputeKernel::submit(TaskCountType taskLevel, bool term
if (isHandlingBarrier) { if (isHandlingBarrier) {
commandQueue.clearLastBcsPackets(); commandQueue.clearLastBcsPackets();
commandQueue.setStallingCommandsOnNextFlush(false); commandQueue.setStallingCommandsOnNextFlush(false);
commandQueue.setDcFlushRequiredOnStallingCommandsOnNextFlush(false);
} }
if (kernelOperation->blitPropertiesContainer.size() > 0) { if (kernelOperation->blitPropertiesContainer.size() > 0) {
@@ -434,7 +433,6 @@ CompletionStamp &CommandWithoutKernel::submit(TaskCountType taskLevel, bool term
if (isHandlingBarrier) { if (isHandlingBarrier) {
commandQueue.clearLastBcsPackets(); commandQueue.clearLastBcsPackets();
commandQueue.setStallingCommandsOnNextFlush(false); commandQueue.setStallingCommandsOnNextFlush(false);
commandQueue.setDcFlushRequiredOnStallingCommandsOnNextFlush(false);
} }
if (kernelOperation->blitEnqueue) { if (kernelOperation->blitEnqueue) {

View File

@@ -1186,23 +1186,20 @@ HWTEST_F(OoqCommandQueueHwBlitTest, givenBlitBeforeBarrierWhenEnqueueingCommandT
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr)); EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr));
uint64_t lastBlitNodeAddress = TimestampPacketHelper::getContextEndGpuAddress(*pCmdQ->getTimestampPacketContainer()->peekNodes()[0]); uint64_t lastBlitNodeAddress = TimestampPacketHelper::getContextEndGpuAddress(*pCmdQ->getTimestampPacketContainer()->peekNodes()[0]);
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueKernel(kernel, 1, &offset, &gws, nullptr, 0, nullptr, nullptr)); EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueKernel(kernel, 1, &offset, &gws, nullptr, 0, nullptr, nullptr));
auto ccsStart = pCmdQ->getGpgpuCommandStreamReceiver().getCS().getUsed();
auto bcsStart = pCmdQ->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS)->getCS(0).getUsed(); auto bcsStart = pCmdQ->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS)->getCS(0).getUsed();
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueBarrierWithWaitList(0, nullptr, nullptr)); EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueBarrierWithWaitList(0, nullptr, nullptr));
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueKernel(kernel, 1, &offset, &gws, nullptr, 0, nullptr, nullptr)); EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueKernel(kernel, 1, &offset, &gws, nullptr, 0, nullptr, nullptr));
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr));
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr));
uint64_t barrierNodeAddress = 0u; uint64_t barrierNodeAddress = 0u;
{ {
HardwareParse ccsHwParser; HardwareParse queueHwParser;
ccsHwParser.parseCommands<FamilyType>(pCmdQ->getGpgpuCommandStreamReceiver().getCS(0), ccsStart); queueHwParser.parseCommands<FamilyType>(*pDevice->getUltCommandStreamReceiver<FamilyType>().lastFlushedCommandStream, 0);
const auto semaphoreItor = find<MI_SEMAPHORE_WAIT *>(ccsHwParser.cmdList.begin(), ccsHwParser.cmdList.end()); const auto semaphoreItor = find<MI_SEMAPHORE_WAIT *>(queueHwParser.cmdList.begin(), queueHwParser.cmdList.end());
const auto semaphore = genCmdCast<MI_SEMAPHORE_WAIT *>(*semaphoreItor); const auto semaphore = genCmdCast<MI_SEMAPHORE_WAIT *>(*semaphoreItor);
EXPECT_EQ(lastBlitNodeAddress, semaphore->getSemaphoreGraphicsAddress()); EXPECT_EQ(lastBlitNodeAddress, semaphore->getSemaphoreGraphicsAddress());
const auto pipeControlItor = find<PIPE_CONTROL *>(semaphoreItor, ccsHwParser.cmdList.end()); const auto pipeControlItor = find<PIPE_CONTROL *>(semaphoreItor, queueHwParser.cmdList.end());
const auto pipeControl = genCmdCast<PIPE_CONTROL *>(*pipeControlItor); const auto pipeControl = genCmdCast<PIPE_CONTROL *>(*pipeControlItor);
EXPECT_EQ(PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControl->getPostSyncOperation()); EXPECT_EQ(PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControl->getPostSyncOperation());
barrierNodeAddress = pipeControl->getAddress() | (static_cast<uint64_t>(pipeControl->getAddressHigh()) << 32); barrierNodeAddress = pipeControl->getAddress() | (static_cast<uint64_t>(pipeControl->getAddressHigh()) << 32);
@@ -1211,6 +1208,9 @@ HWTEST_F(OoqCommandQueueHwBlitTest, givenBlitBeforeBarrierWhenEnqueueingCommandT
EXPECT_EQ(pipeControlItor, find<MI_SEMAPHORE_WAIT *>(std::next(semaphoreItor), pipeControlItor)); EXPECT_EQ(pipeControlItor, find<MI_SEMAPHORE_WAIT *>(std::next(semaphoreItor), pipeControlItor));
} }
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr));
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr));
{ {
HardwareParse bcsHwParser; HardwareParse bcsHwParser;
bcsHwParser.parseCommands<FamilyType>(pCmdQ->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS)->getCS(0), bcsStart); bcsHwParser.parseCommands<FamilyType>(pCmdQ->getBcsCommandStreamReceiver(aub_stream::ENGINE_BCS)->getCS(0), bcsStart);

View File

@@ -820,16 +820,18 @@ HWTEST2_F(OoqCommandQueueHwBlitTest, givenBarrierBeforeFirstKernelWhenEnqueueNDR
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr)); EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr));
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr)); EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueReadBuffer(buffer.get(), CL_FALSE, 0, 1u, ptr, nullptr, 0, nullptr, nullptr));
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueBarrierWithWaitList(0, nullptr, nullptr));
auto ccsStart = pCmdQ->getGpgpuCommandStreamReceiver().getCS().getUsed(); auto ccsStart = pCmdQ->getGpgpuCommandStreamReceiver().getCS().getUsed();
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueBarrierWithWaitList(0, nullptr, nullptr));
EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueKernel(kernel, 1, &offset, &gws, nullptr, 0, nullptr, nullptr)); EXPECT_EQ(CL_SUCCESS, pCmdQ->enqueueKernel(kernel, 1, &offset, &gws, nullptr, 0, nullptr, nullptr));
HardwareParse queueHwParser;
queueHwParser.parseCommands<FamilyType>(*pDevice->getUltCommandStreamReceiver<FamilyType>().lastFlushedCommandStream, 0u);
const auto memFenceItor = find<MI_MEM_FENCE *>(queueHwParser.cmdList.begin(), queueHwParser.cmdList.end());
EXPECT_NE(queueHwParser.cmdList.end(), memFenceItor);
HardwareParse ccsHwParser; HardwareParse ccsHwParser;
ccsHwParser.parseCommands<FamilyType>(pCmdQ->getGpgpuCommandStreamReceiver().getCS(0), ccsStart); ccsHwParser.parseCommands<FamilyType>(pCmdQ->getGpgpuCommandStreamReceiver().getCS(0), ccsStart);
const auto memFenceStateItor = find<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(ccsHwParser.cmdList.begin(), ccsHwParser.cmdList.end()); const auto memFenceStateItor = find<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(ccsHwParser.cmdList.begin(), ccsHwParser.cmdList.end());
const auto memFenceItor = find<MI_MEM_FENCE *>(memFenceStateItor, ccsHwParser.cmdList.end());
EXPECT_NE(ccsHwParser.cmdList.end(), memFenceItor);
EXPECT_NE(ccsHwParser.cmdList.end(), memFenceStateItor); EXPECT_NE(ccsHwParser.cmdList.end(), memFenceStateItor);
} }

View File

@@ -26,7 +26,9 @@ using BarrierTest = Test<CommandEnqueueFixture>;
HWTEST_F(BarrierTest, givenCsrWithHigherLevelThenCommandQueueWhenEnqueueBarrierIsCalledThenCommandQueueAlignsToCsrWithoutSendingAnyCommands) { HWTEST_F(BarrierTest, givenCsrWithHigherLevelThenCommandQueueWhenEnqueueBarrierIsCalledThenCommandQueueAlignsToCsrWithoutSendingAnyCommands) {
auto pCmdQ = this->pCmdQ; auto pCmdQ = this->pCmdQ;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>(); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (commandStreamReceiver.peekTimestampPacketWriteEnabled()) {
GTEST_SKIP();
}
// Set task levels to known values. // Set task levels to known values.
uint32_t originalCSRLevel = 2; uint32_t originalCSRLevel = 2;
commandStreamReceiver.taskLevel = originalCSRLevel; commandStreamReceiver.taskLevel = originalCSRLevel;
@@ -69,7 +71,9 @@ HWTEST_F(BarrierTest, GivenCsrTaskLevelGreaterThenCmdqTaskLevelWhenEnqueingBarri
auto pCmdQ = this->pCmdQ; auto pCmdQ = this->pCmdQ;
auto pCmdBuffer = this->pCmdBuffer; auto pCmdBuffer = this->pCmdBuffer;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>(); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (commandStreamReceiver.peekTimestampPacketWriteEnabled()) {
GTEST_SKIP();
}
commandStreamReceiver.setMediaVFEStateDirty(false); commandStreamReceiver.setMediaVFEStateDirty(false);
// Set task levels to known values. // Set task levels to known values.
@@ -202,7 +206,7 @@ HWTEST_F(BarrierTest, WhenEnqueingBarrierWithWaitListThenDependenciesShouldSync)
auto pEvent = castToObject<Event>(event); auto pEvent = castToObject<Event>(event);
auto &csr = pCmdQ->getGpgpuCommandStreamReceiver(); auto &csr = pCmdQ->getGpgpuCommandStreamReceiver();
// in this case only cmdQ raises the taskLevel why csr stay intact // in this case only cmdQ raises the taskLevel while csr stays intact
EXPECT_EQ(8u, pCmdQ->taskLevel); EXPECT_EQ(8u, pCmdQ->taskLevel);
if (csr.peekTimestampPacketWriteEnabled()) { if (csr.peekTimestampPacketWriteEnabled()) {
EXPECT_EQ(pCmdQ->taskLevel + 1, commandStreamReceiver.peekTaskLevel()); EXPECT_EQ(pCmdQ->taskLevel + 1, commandStreamReceiver.peekTaskLevel());

View File

@@ -5,7 +5,9 @@
* *
*/ */
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/mocks/mock_csr.h" #include "shared/test/common/mocks/mock_csr.h"
#include "shared/test/common/test_macros/test_checks_shared.h" #include "shared/test/common/test_macros/test_checks_shared.h"
#include "shared/test/common/utilities/base_object_utils.h" #include "shared/test/common/utilities/base_object_utils.h"
@@ -368,7 +370,7 @@ HWTEST_F(OOQTaskTests, givenSkipDcFlushOnBarrierWithEventsEnabledWhenEnqueingBar
outEvent->release(); outEvent->release();
} }
HWTEST_F(OOQTaskTests, givenSkipDcFlushOnBarrierWithoutEventsDisableddWhenEnqueingBarrierWithWaitListThenDcFlushSet) { HWTEST_F(OOQTaskTests, givenSkipDcFlushOnBarrierWithoutEventsDisabledWhenEnqueingBarrierWithWaitListThenDcFlushSet) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>(); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (false == commandStreamReceiver.peekTimestampPacketWriteEnabled()) { if (false == commandStreamReceiver.peekTimestampPacketWriteEnabled()) {
GTEST_SKIP(); GTEST_SKIP();
@@ -388,7 +390,7 @@ HWTEST_F(OOQTaskTests, givenSkipDcFlushOnBarrierWithoutEventsDisableddWhenEnquei
EXPECT_TRUE(pCmdQ->isDcFlushRequiredOnStallingCommandsOnNextFlush()); EXPECT_TRUE(pCmdQ->isDcFlushRequiredOnStallingCommandsOnNextFlush());
} }
HWTEST_F(OOQTaskTests, givenEnqueueMarkerWithWaitListWhenIsMarkerWithPostSyncWriteThenBcsTimestapLastBarrierToWaitForIsNotEmpty) { HWTEST_F(OOQTaskTests, givenEnqueueMarkerWithWaitListWhenIsMarkerWithPostSyncWriteThenBcsTimestampLastBarrierToWaitForIsNotEmpty) {
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>(); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
if (false == commandStreamReceiver.peekTimestampPacketWriteEnabled()) { if (false == commandStreamReceiver.peekTimestampPacketWriteEnabled()) {
GTEST_SKIP(); GTEST_SKIP();

View File

@@ -1755,7 +1755,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, UltCommandStreamReceiverTest, givenBarrierNodeSetWhe
size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands(dispatchFlags); size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands(dispatchFlags);
EXPECT_EQ(expectedCmdSize, estimatedCmdSize); EXPECT_EQ(expectedCmdSize, estimatedCmdSize);
commandStreamReceiver->programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags); commandStreamReceiver->programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags.barrierTimestampPacketNodes, false);
EXPECT_EQ(estimatedCmdSize, commandStreamCSR.getUsed()); EXPECT_EQ(estimatedCmdSize, commandStreamCSR.getUsed());
parseCommands<FamilyType>(commandStreamCSR, 0); parseCommands<FamilyType>(commandStreamCSR, 0);

View File

@@ -945,7 +945,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWh
size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands(dispatchFlags); size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands(dispatchFlags);
EXPECT_EQ(expectedCmdSize, estimatedCmdSize); EXPECT_EQ(expectedCmdSize, estimatedCmdSize);
commandStreamReceiver->programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags); commandStreamReceiver->programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags.barrierTimestampPacketNodes, false);
EXPECT_EQ(estimatedCmdSize, commandStreamCSR.getUsed()); EXPECT_EQ(estimatedCmdSize, commandStreamCSR.getUsed());
parseCommands<FamilyType>(commandStreamCSR, 0); parseCommands<FamilyType>(commandStreamCSR, 0);
@@ -992,7 +992,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionDisabledW
size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands(dispatchFlags); size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands(dispatchFlags);
EXPECT_EQ(expectedCmdSize, estimatedCmdSize); EXPECT_EQ(expectedCmdSize, estimatedCmdSize);
commandStreamReceiver->programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags); commandStreamReceiver->programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags.barrierTimestampPacketNodes, false);
EXPECT_EQ(estimatedCmdSize, commandStreamCSR.getUsed()); EXPECT_EQ(estimatedCmdSize, commandStreamCSR.getUsed());
parseCommands<FamilyType>(commandStreamCSR, 0); parseCommands<FamilyType>(commandStreamCSR, 0);
@@ -1045,7 +1045,7 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWh
size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands(dispatchFlags); size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands(dispatchFlags);
EXPECT_EQ(expectedSize, estimatedCmdSize); EXPECT_EQ(expectedSize, estimatedCmdSize);
commandStreamReceiver->programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags); commandStreamReceiver->programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags.barrierTimestampPacketNodes, false);
EXPECT_EQ(estimatedCmdSize, commandStreamCSR.getUsed()); EXPECT_EQ(estimatedCmdSize, commandStreamCSR.getUsed());
EXPECT_EQ(2u, tagNode->getPacketsUsed()); EXPECT_EQ(2u, tagNode->getPacketsUsed());

View File

@@ -591,6 +591,8 @@ class CommandStreamReceiverMock : public CommandStreamReceiver {
size_t getCmdsSizeForComputeBarrierCommand() const override { size_t getCmdsSizeForComputeBarrierCommand() const override {
return 0; return 0;
} }
void programStallingCommandsForBarrier(LinearStream &cmdStream, TimestampPacketContainer *barrierTimestampPacketNodes, const bool isDcFlushRequired) override {
}
GraphicsAllocation *getClearColorAllocation() override { return nullptr; } GraphicsAllocation *getClearColorAllocation() override { return nullptr; }
bool createPreemptionAllocation() override { bool createPreemptionAllocation() override {

View File

@@ -811,7 +811,7 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenPipeControlRequestWhenDispatchingBlitEnq
} }
} }
HWTEST_TEMPLATED_F(BcsBufferTests, givenBarrierWithEmptyWaitlistWhenReleasingMultipleBlockedEnqueuesThenProgramBarrierOnce) { HWTEST_TEMPLATED_F(BcsBufferTests, givenStallingCommandsOnNextFlushWhenReleasingMultipleBlockedEnqueuesThenProgramBarrierOnce) {
DebugManager.flags.OptimizeIoqBarriersHandling.set(0); DebugManager.flags.OptimizeIoqBarriersHandling.set(0);
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
@@ -827,7 +827,7 @@ HWTEST_TEMPLATED_F(BcsBufferTests, givenBarrierWithEmptyWaitlistWhenReleasingMul
cl_event waitlist0[] = {&userEvent0}; cl_event waitlist0[] = {&userEvent0};
cl_event waitlist1[] = {&userEvent1}; cl_event waitlist1[] = {&userEvent1};
cmdQ->enqueueBarrierWithWaitList(0, nullptr, nullptr); cmdQ->setStallingCommandsOnNextFlush(true);
cmdQ->enqueueWriteBuffer(buffer.get(), false, 0, 1, hostPtr, nullptr, 1, waitlist0, nullptr); cmdQ->enqueueWriteBuffer(buffer.get(), false, 0, 1, hostPtr, nullptr, 1, waitlist0, nullptr);
cmdQ->enqueueWriteBuffer(buffer.get(), false, 0, 1, hostPtr, nullptr, 1, waitlist1, nullptr); cmdQ->enqueueWriteBuffer(buffer.get(), false, 0, 1, hostPtr, nullptr, 1, waitlist1, nullptr);

View File

@@ -359,6 +359,8 @@ class CommandStreamReceiver {
virtual void programComputeBarrierCommand(LinearStream &cmdStream) = 0; virtual void programComputeBarrierCommand(LinearStream &cmdStream) = 0;
virtual size_t getCmdsSizeForComputeBarrierCommand() const = 0; virtual size_t getCmdsSizeForComputeBarrierCommand() const = 0;
virtual void programStallingCommandsForBarrier(LinearStream &cmdStream, TimestampPacketContainer *barrierTimestampPacketNodes, const bool isDcFlushRequired) = 0;
const HardwareInfo &peekHwInfo() const; const HardwareInfo &peekHwInfo() const;
const RootDeviceEnvironment &peekRootDeviceEnvironment() const; const RootDeviceEnvironment &peekRootDeviceEnvironment() const;

View File

@@ -162,6 +162,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
size_t getCmdsSizeForComputeBarrierCommand() const override { size_t getCmdsSizeForComputeBarrierCommand() const override {
return getCmdSizeForStallingNoPostSyncCommands(); return getCmdSizeForStallingNoPostSyncCommands();
} }
void programStallingCommandsForBarrier(LinearStream &cmdStream, TimestampPacketContainer *barrierTimestampPacketNodes, const bool isDcFlushRequired) override;
SubmissionStatus initializeDeviceWithFirstSubmission() override; SubmissionStatus initializeDeviceWithFirstSubmission() override;
HeapDirtyState &getDshState() { HeapDirtyState &getDshState() {
@@ -187,7 +188,6 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
void programPerDssBackedBuffer(LinearStream &scr, Device &device, DispatchFlags &dispatchFlags); void programPerDssBackedBuffer(LinearStream &scr, Device &device, DispatchFlags &dispatchFlags);
void programStateSip(LinearStream &cmdStream, Device &device); void programStateSip(LinearStream &cmdStream, Device &device);
void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t maxFrontEndThreads); void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t maxFrontEndThreads);
void programStallingCommandsForBarrier(LinearStream &cmdStream, DispatchFlags &dispatchFlags);
void programStallingNoPostSyncCommandsForBarrier(LinearStream &cmdStream); void programStallingNoPostSyncCommandsForBarrier(LinearStream &cmdStream);
void programStallingPostSyncCommandsForBarrier(LinearStream &cmdStream, TagNodeBase &tagNode, bool dcFlushRequired); void programStallingPostSyncCommandsForBarrier(LinearStream &cmdStream, TagNodeBase &tagNode, bool dcFlushRequired);
void programEngineModeCommands(LinearStream &csr, const DispatchFlags &dispatchFlags); void programEngineModeCommands(LinearStream &csr, const DispatchFlags &dispatchFlags);

View File

@@ -508,9 +508,9 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
if (dispatchFlags.isStallingCommandsOnNextFlushRequired) { if (dispatchFlags.isStallingCommandsOnNextFlushRequired) {
if (DebugManager.flags.ProgramBarrierInCommandStreamTask.get() == 1) { if (DebugManager.flags.ProgramBarrierInCommandStreamTask.get() == 1) {
programStallingCommandsForBarrier(commandStreamTask, dispatchFlags); programStallingCommandsForBarrier(commandStreamTask, dispatchFlags.barrierTimestampPacketNodes, dispatchFlags.isDcFlushRequiredOnStallingCommandsOnNextFlush);
} else { } else {
programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags); programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags.barrierTimestampPacketNodes, dispatchFlags.isDcFlushRequiredOnStallingCommandsOnNextFlush);
} }
} }
@@ -744,12 +744,9 @@ void CommandStreamReceiverHw<GfxFamily>::programComputeMode(LinearStream &stream
} }
template <typename GfxFamily> template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::programStallingCommandsForBarrier(LinearStream &cmdStream, DispatchFlags &dispatchFlags) { inline void CommandStreamReceiverHw<GfxFamily>::programStallingCommandsForBarrier(LinearStream &cmdStream, TimestampPacketContainer *barrierTimestampPacketNodes, const bool isDcFlushRequired) {
auto barrierTimestampPacketNodes = dispatchFlags.barrierTimestampPacketNodes;
if (barrierTimestampPacketNodes && barrierTimestampPacketNodes->peekNodes().size() != 0) { if (barrierTimestampPacketNodes && barrierTimestampPacketNodes->peekNodes().size() != 0) {
programStallingPostSyncCommandsForBarrier(cmdStream, *barrierTimestampPacketNodes->peekNodes()[0], dispatchFlags.isDcFlushRequiredOnStallingCommandsOnNextFlush); programStallingPostSyncCommandsForBarrier(cmdStream, *barrierTimestampPacketNodes->peekNodes()[0], isDcFlushRequired);
barrierTimestampPacketNodes->makeResident(*this); barrierTimestampPacketNodes->makeResident(*this);
} else { } else {
programStallingNoPostSyncCommandsForBarrier(cmdStream); programStallingNoPostSyncCommandsForBarrier(cmdStream);

View File

@@ -166,6 +166,9 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
size_t getCmdsSizeForComputeBarrierCommand() const override { size_t getCmdsSizeForComputeBarrierCommand() const override {
return 0; return 0;
} }
void programStallingCommandsForBarrier(LinearStream &cmdStream, TimestampPacketContainer *barrierTimestampPacketNodes, const bool isDcFlushRequired) override {
programStallingCommandsForBarrierCalled = true;
}
bool createPreemptionAllocation() override { bool createPreemptionAllocation() override {
if (createPreemptionAllocationParentCall) { if (createPreemptionAllocationParentCall) {
@@ -214,6 +217,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
bool createPreemptionAllocationReturn = true; bool createPreemptionAllocationReturn = true;
bool createPreemptionAllocationParentCall = false; bool createPreemptionAllocationParentCall = false;
bool programComputeBarrierCommandCalled = false; bool programComputeBarrierCommandCalled = false;
bool programStallingCommandsForBarrierCalled = false;
std::optional<bool> isGpuHangDetectedReturnValue{}; std::optional<bool> isGpuHangDetectedReturnValue{};
std::optional<bool> testTaskCountReadyReturnValue{}; std::optional<bool> testTaskCountReadyReturnValue{};
WaitStatus waitForCompletionWithTimeoutReturnValue{WaitStatus::Ready}; WaitStatus waitForCompletionWithTimeoutReturnValue{WaitStatus::Ready};

View File

@@ -9,11 +9,14 @@
#include "shared/source/command_stream/command_stream_receiver_simulated_hw.h" #include "shared/source/command_stream/command_stream_receiver_simulated_hw.h"
#include "shared/source/helpers/array_count.h" #include "shared/source/helpers/array_count.h"
#include "shared/source/helpers/hardware_context_controller.h" #include "shared/source/helpers/hardware_context_controller.h"
#include "shared/source/helpers/timestamp_packet.h"
#include "shared/source/memory_manager/memory_pool.h" #include "shared/source/memory_manager/memory_pool.h"
#include "shared/source/os_interface/os_context.h" #include "shared/source/os_interface/os_context.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h" #include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/helpers/gfx_core_helper_tests.h" #include "shared/test/common/helpers/gfx_core_helper_tests.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/mocks/mock_aub_manager.h" #include "shared/test/common/mocks/mock_aub_manager.h"
#include "shared/test/common/mocks/mock_gmm.h" #include "shared/test/common/mocks/mock_gmm.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h" #include "shared/test/common/mocks/mock_graphics_allocation.h"
@@ -595,3 +598,98 @@ HWTEST_F(CommandStreamSimulatedTests, givenSpecificMemoryPoolAllocationWhenWrite
} }
} }
} }
HWTEST_F(CommandStreamSimulatedTests, givenBarrierNodesWhenProgramStallingCommandsForBarrierCalledThenPostSyncWritePipeControlIsProgrammed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
auto csr = std::make_unique<MockSimulatedCsrHw<FamilyType>>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor());
csr->setupContext(osContext);
TagAllocatorBase *allocator = pDevice->getGpgpuCommandStreamReceiver().getTimestampPacketAllocator();
auto barrierNode = allocator->getTag();
const auto barrierNodeAddress = TimestampPacketHelper::getContextEndGpuAddress(*barrierNode);
TimestampPacketContainer barrierNodes{};
barrierNodes.add(barrierNode);
{
MockGraphicsAllocation streamAllocation{};
uint32_t streamBuffer[100] = {};
LinearStream linearStream(&streamAllocation, streamBuffer, sizeof(streamBuffer));
csr->programStallingCommandsForBarrier(linearStream, &barrierNodes, false);
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(linearStream);
auto pipeControlItor = find<PIPE_CONTROL *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*pipeControlItor);
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(hardwareInfo)) {
auto nextPipeControlItor = find<PIPE_CONTROL *>(++pipeControlItor, hwParser.cmdList.end());
pipeControl = genCmdCast<PIPE_CONTROL *>(*nextPipeControlItor);
}
ASSERT_NE(nullptr, pipeControl);
EXPECT_EQ(PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControl->getPostSyncOperation());
EXPECT_FALSE(pipeControl->getDcFlushEnable());
EXPECT_EQ(barrierNodeAddress, UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*pipeControl));
}
{
MockGraphicsAllocation streamAllocation{};
uint32_t streamBuffer[100] = {};
LinearStream linearStream(&streamAllocation, streamBuffer, sizeof(streamBuffer));
csr->programStallingCommandsForBarrier(linearStream, &barrierNodes, true);
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(linearStream);
auto pipeControlItor = find<PIPE_CONTROL *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*pipeControlItor);
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(hardwareInfo)) {
auto nextPipeControlItor = find<PIPE_CONTROL *>(++pipeControlItor, hwParser.cmdList.end());
pipeControl = genCmdCast<PIPE_CONTROL *>(*nextPipeControlItor);
}
ASSERT_NE(nullptr, pipeControl);
EXPECT_EQ(PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControl->getPostSyncOperation());
EXPECT_EQ(csr->getDcFlushSupport(), pipeControl->getDcFlushEnable());
EXPECT_EQ(barrierNodeAddress, UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*pipeControl));
}
}
HWTEST_F(CommandStreamSimulatedTests, givenEmptyBarrierNodesWhenProgramStallingCommandsForBarrierCalledThenNoWritePipeControlIsProgrammed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
auto csr = std::make_unique<MockSimulatedCsrHw<FamilyType>>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor());
csr->setupContext(osContext);
{
TimestampPacketContainer barrierNodes{};
MockGraphicsAllocation streamAllocation{};
uint32_t streamBuffer[100] = {};
LinearStream linearStream(&streamAllocation, streamBuffer, sizeof(streamBuffer));
csr->programStallingCommandsForBarrier(linearStream, &barrierNodes, false);
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(linearStream);
const auto pipeControlItor = find<PIPE_CONTROL *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
const auto pipeControl = genCmdCast<PIPE_CONTROL *>(*pipeControlItor);
ASSERT_NE(nullptr, pipeControl);
EXPECT_EQ(PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_NO_WRITE, pipeControl->getPostSyncOperation());
EXPECT_EQ(0u, UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*pipeControl));
}
{
MockGraphicsAllocation streamAllocation{};
uint32_t streamBuffer[100] = {};
LinearStream linearStream(&streamAllocation, streamBuffer, sizeof(streamBuffer));
csr->programStallingCommandsForBarrier(linearStream, nullptr, false);
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(linearStream);
const auto pipeControlItor = find<PIPE_CONTROL *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
const auto pipeControl = genCmdCast<PIPE_CONTROL *>(*pipeControlItor);
ASSERT_NE(nullptr, pipeControl);
EXPECT_EQ(PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_NO_WRITE, pipeControl->getPostSyncOperation());
EXPECT_EQ(0u, UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress(*pipeControl));
}
}