diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index ff69fd4c3d..d0532fc4b7 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -352,8 +352,8 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer allocationsForResidency.push_back(batchBuffer.commandBufferAllocation); batchBuffer.commandBufferAllocation->residencyTaskCount[this->deviceIndex] = this->taskCount; } - processResidency(allocationsForResidency, osContext); } + processResidency(allocationsForResidency, osContext); if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) { addGUCStartMessage(static_cast(reinterpret_cast(pBatchBuffer)), engineType); addPatchInfoComments(); diff --git a/runtime/command_stream/command_stream_receiver_with_aub_dump.h b/runtime/command_stream/command_stream_receiver_with_aub_dump.h index 816bff8938..db5d20b5fa 100644 --- a/runtime/command_stream/command_stream_receiver_with_aub_dump.h +++ b/runtime/command_stream/command_stream_receiver_with_aub_dump.h @@ -20,7 +20,6 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR { CommandStreamReceiverWithAUBDump &operator=(const CommandStreamReceiverWithAUBDump &) = delete; FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineOrdinal, ResidencyContainer &allocationsForResidency, OsContext &osContext) override; - void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override; void makeNonResident(GraphicsAllocation &gfxAllocation) override; void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override; diff --git a/runtime/command_stream/command_stream_receiver_with_aub_dump.inl b/runtime/command_stream/command_stream_receiver_with_aub_dump.inl index f081886498..dda9bc4a7a 100644 --- a/runtime/command_stream/command_stream_receiver_with_aub_dump.inl +++ b/runtime/command_stream/command_stream_receiver_with_aub_dump.inl @@ -25,21 +25,13 @@ CommandStreamReceiverWithAUBDump::~CommandStreamReceiverWithAUBDump() { template FlushStamp CommandStreamReceiverWithAUBDump::flush(BatchBuffer &batchBuffer, EngineType engineOrdinal, ResidencyContainer &allocationsForResidency, OsContext &osContext) { - FlushStamp flushStamp = BaseCSR::flush(batchBuffer, engineOrdinal, allocationsForResidency, osContext); if (aubCSR) { aubCSR->flush(batchBuffer, engineOrdinal, allocationsForResidency, osContext); } + FlushStamp flushStamp = BaseCSR::flush(batchBuffer, engineOrdinal, allocationsForResidency, osContext); return flushStamp; } -template -void CommandStreamReceiverWithAUBDump::processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) { - BaseCSR::processResidency(allocationsForResidency, osContext); - if (aubCSR) { - aubCSR->processResidency(allocationsForResidency, osContext); - } -} - template void CommandStreamReceiverWithAUBDump::makeNonResident(GraphicsAllocation &gfxAllocation) { int residencyTaskCount = gfxAllocation.residencyTaskCount[this->deviceIndex]; diff --git a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp index 82c5b738f3..e88bd406b1 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp @@ -426,7 +426,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); } -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) { +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) { auto aubExecutionEnvironment = getEnvironment>(false, true, false); auto aubCsr = aubExecutionEnvironment->template getCsr>(); auto allocationsForResidency = aubCsr->getResidencyAllocations(); @@ -476,7 +476,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon memoryManager->freeGraphicsMemory(gfxAllocation); } -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnResidencyAllocations) { +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNonStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnResidencyAllocations) { auto aubExecutionEnvironment = getEnvironment>(true, true, false); auto aubCsr = aubExecutionEnvironment->template getCsr>(); auto memoryManager = aubExecutionEnvironment->executionEnvironment->memoryManager.get(); @@ -494,7 +494,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand aubCsr->flush(batchBuffer, engineType, allocationsForResidency, *pDevice->getOsContext()); - EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount[0u]); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount[0u]); memoryManager->freeGraphicsMemoryImpl(gfxAllocation); diff --git a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index f141eb8201..38655fb63e 100644 --- a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -26,6 +26,7 @@ struct MyMockCsr : UltCommandStreamReceiver { flushParametrization.receivedBatchBuffer = &batchBuffer; flushParametrization.receivedEngine = engineOrdinal; flushParametrization.receivedAllocationsForResidency = &allocationsForResidency; + processResidency(allocationsForResidency, osContext); return flushParametrization.flushStampToReturn; } @@ -174,13 +175,20 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub memoryManager->freeGraphicsMemoryImpl(gfxAllocation); } -HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenProcessResidencyIsCalledThenBothBaseAndAubCsrProcessResidencyIsCalled) { +HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenFlushIsCalledThenBothBaseAndAubCsrProcessResidencyIsCalled) { + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + auto engineType = OCLRT::ENGINE_RCS; + auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false); ASSERT_NE(nullptr, gfxAllocation); - ResidencyContainer allocationsForResidency = {gfxAllocation}; OsContext osContext(nullptr, 0u); - csrWithAubDump->processResidency(allocationsForResidency, osContext); + + FlushStamp flushStamp = csrWithAubDump->flush(batchBuffer, engineType, allocationsForResidency, osContext); + EXPECT_EQ(flushStamp, csrWithAubDump->flushParametrization.flushStampToReturn); EXPECT_TRUE(csrWithAubDump->processResidencyParameterization.wasCalled); EXPECT_EQ(&allocationsForResidency, csrWithAubDump->processResidencyParameterization.receivedAllocationsForResidency); @@ -191,6 +199,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub } memoryManager->freeGraphicsMemoryImpl(gfxAllocation); + memoryManager->freeGraphicsMemoryImpl(commandBuffer); } HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenMakeNonResidentIsCalledThenBothBaseAndAubCsrMakeNonResidentIsCalled) {