From bb58c9fc2f7c6ee9ee4df4ba58b966cda8bcdbab Mon Sep 17 00:00:00 2001 From: "Milczarek, Slawomir" Date: Thu, 1 Mar 2018 15:18:54 +0100 Subject: [PATCH] AUB CSR flush to process residency in standalone mode only This commit eliminates redundancy in calling processResidency() for AUB CSR twice in the HW CSR with AUB dump configuration. Change-Id: Ib49c80fa9d81a495dfb7261ff76e0b9b1422e42d --- .../aub_command_stream_receiver_hw.inl | 3 +- .../aub_command_stream_receiver_tests.cpp | 74 +++++++++++++------ 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index ad92a09289..ee0e45363f 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -219,10 +219,9 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer allocationsForResidency->push_back(batchBuffer.commandBufferAllocation); batchBuffer.commandBufferAllocation->residencyTaskCount = this->taskCount; } + processResidency(allocationsForResidency); } - processResidency(allocationsForResidency); - // Write our batch buffer auto pBatchBuffer = ptrOffset(batchBuffer.commandBufferAllocation->getUnderlyingBuffer(), batchBuffer.startOffset); auto currentOffset = batchBuffer.usedSize; 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 a4a017d543..a840f74c6c 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp @@ -118,7 +118,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC aubCsr->setMemoryManager(nullptr); } -HWTEST_F(AubCommandStreamReceiverTests, flushShouldLeaveProperRingTailAlignment) { +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldLeaveProperRingTailAlignment) { auto aubCsr = new AUBCommandStreamReceiverHw(*platformDevices[0], true); auto memoryManager = aubCsr->createMemoryManager(false); @@ -146,7 +146,7 @@ HWTEST_F(AubCommandStreamReceiverTests, flushShouldLeaveProperRingTailAlignment) delete memoryManager; } -HWTEST_F(AubCommandStreamReceiverTests, flushShouldCallMakeResidentOnCommandBufferAllocation) { +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnCommandBufferAllocation) { std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); std::unique_ptr memoryManager(aubCsr->createMemoryManager(false)); @@ -173,7 +173,28 @@ HWTEST_F(AubCommandStreamReceiverTests, flushShouldCallMakeResidentOnCommandBuff aubCsr->setMemoryManager(nullptr); } -HWTEST_F(AubCommandStreamReceiverTests, flushShouldCallMakeResidentOnResidencyAllocations) { +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) { + std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], false)); + std::unique_ptr memoryManager(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + auto engineType = OCLRT::ENGINE_RCS; + + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + + aubCsr->flush(batchBuffer, engineType, nullptr); + + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + + memoryManager->freeGraphicsMemoryImpl(commandBuffer); + aubCsr->setMemoryManager(nullptr); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnResidencyAllocations) { std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); std::unique_ptr memoryManager(aubCsr->createMemoryManager(false)); auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false); @@ -208,6 +229,32 @@ HWTEST_F(AubCommandStreamReceiverTests, flushShouldCallMakeResidentOnResidencyAl aubCsr->setMemoryManager(nullptr); } +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnResidencyAllocations) { + std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], false)); + std::unique_ptr memoryManager(aubCsr->createMemoryManager(false)); + auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + auto engineType = OCLRT::ENGINE_RCS; + ResidencyContainer allocationsForResidency = {gfxAllocation}; + + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + + aubCsr->flush(batchBuffer, engineType, &allocationsForResidency); + + EXPECT_EQ(ObjectNotResident, gfxAllocation->residencyTaskCount); + EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); + + memoryManager->freeGraphicsMemoryImpl(commandBuffer); + memoryManager->freeGraphicsMemoryImpl(gfxAllocation); + aubCsr->setMemoryManager(nullptr); +} + HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationIsCreatedThenItDoesntHaveTypeNonAubWritable) { std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); std::unique_ptr memoryManager(aubCsr->createMemoryManager(false)); @@ -284,27 +331,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic EXPECT_FALSE(aubCsr->writeMemory(gfxAllocation)); } -HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) { - std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], false)); - std::unique_ptr memoryManager(aubCsr->createMemoryManager(false)); - - GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); - ASSERT_NE(nullptr, commandBuffer); - LinearStream cs(commandBuffer); - - BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; - auto engineType = OCLRT::ENGINE_RCS; - - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); - - aubCsr->flush(batchBuffer, engineType, nullptr); - - EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount); - - memoryManager->freeGraphicsMemoryImpl(commandBuffer); - aubCsr->setMemoryManager(nullptr); -} - class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryManager { public: GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override {