Skip to content

Commit f4c40c7

Browse files
Flush tag update if any heap was allocated
Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent 42e58fd commit f4c40c7

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,34 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenUpdateTaskCountFromWaitWhenFl
578578
EXPECT_EQ(0u, mockCsr->peekLatestFlushedTaskCount());
579579
}
580580

581+
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenUpdateTaskCountFromWaitEnabledAndHeapAllocationDirtyWhenFlushTaskThenTaskCountIsFlushed) {
582+
DebugManagerStateRestore restorer;
583+
DebugManager.flags.UpdateTaskCountFromWait.set(3);
584+
585+
auto mockCsr = new MockCsrHw2<FamilyType>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
586+
pDevice->resetCommandStreamReceiver(mockCsr);
587+
mockCsr->useNewResourceImplicitFlush = false;
588+
mockCsr->useGpuIdleImplicitFlush = false;
589+
mockCsr->heapStorageReqiuresRecyclingTag = true;
590+
591+
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
592+
dispatchFlags.preemptionMode = PreemptionHelper::getDefaultPreemptionMode(pDevice->getHardwareInfo());
593+
dispatchFlags.guardCommandBufferWithPipeControl = false;
594+
595+
mockCsr->flushTask(commandStream,
596+
0,
597+
&dsh,
598+
&ioh,
599+
&ssh,
600+
taskLevel,
601+
dispatchFlags,
602+
*pDevice);
603+
604+
parseCommands<FamilyType>(commandStream);
605+
auto itorPipeControl = find<typename FamilyType::PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
606+
EXPECT_NE(itorPipeControl, cmdList.end());
607+
}
608+
581609
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInDefaultModeWhenFlushTaskIsCalledThenFlushedTaskCountIsModifed) {
582610
CommandQueueHw<FamilyType> commandQueue(nullptr, pClDevice, 0, false);
583611
auto &commandStream = commandQueue.getCS(4096u);

shared/source/command_stream/command_stream_receiver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ IndirectHeap &CommandStreamReceiver::getIndirectHeap(IndirectHeap::Type heapType
540540
if (heap && heap->getAvailableSpace() < minRequiredSize && heapMemory) {
541541
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
542542
heapMemory = nullptr;
543+
this->heapStorageReqiuresRecyclingTag = true;
543544
}
544545

545546
if (!heapMemory) {

shared/source/command_stream/command_stream_receiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ class CommandStreamReceiver {
481481
bool GSBAFor32BitProgrammed = false;
482482
bool GSBAStateDirty = true;
483483
bool bindingTableBaseAddressRequired = false;
484+
bool heapStorageReqiuresRecyclingTag = false;
484485
bool mediaVfeStateDirty = true;
485486
bool lastVmeSubslicesConfig = false;
486487
bool stallingCommandsOnNextFlushRequired = false;

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
206206
const auto &hwInfo = peekHwInfo();
207207
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
208208

209-
if (dispatchFlags.blocking || dispatchFlags.dcFlush || dispatchFlags.guardCommandBufferWithPipeControl) {
209+
if (dispatchFlags.blocking || dispatchFlags.dcFlush || dispatchFlags.guardCommandBufferWithPipeControl || this->heapStorageReqiuresRecyclingTag) {
210210
if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
211211
// for ImmediateDispatch we will send this right away, therefore this pipe control will close the level
212212
// for BatchedSubmissions it will be nooped and only last ppc in batch will be emitted.
@@ -220,6 +220,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
220220
}
221221
}
222222

223+
this->heapStorageReqiuresRecyclingTag = false;
223224
epiloguePipeControlLocation = ptrOffset(commandStreamTask.getCpuBase(), commandStreamTask.getUsed());
224225

225226
if ((dispatchFlags.outOfOrderExecutionAllowed || timestampPacketWriteEnabled) &&

shared/test/common/mocks/mock_command_stream_receiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class MockCsrHw2 : public CommandStreamReceiverHw<GfxFamily> {
239239
using CommandStreamReceiver::dispatchMode;
240240
using CommandStreamReceiver::feSupportFlags;
241241
using CommandStreamReceiver::globalFenceAllocation;
242+
using CommandStreamReceiver::heapStorageReqiuresRecyclingTag;
242243
using CommandStreamReceiver::isPreambleSent;
243244
using CommandStreamReceiver::latestFlushedTaskCount;
244245
using CommandStreamReceiver::mediaVfeStateDirty;

0 commit comments

Comments
 (0)