AUB CSR to update hardware tag in standalone mode

This commit introduces a software controlled HW Tag
in the configuration of AUB CSR in standalone mode
(i.e. with no execution on real HW).

Change-Id: Ic470957d58e6568b13dda3d61cb230498d8f2691
This commit is contained in:
Milczarek, Slawomir 2018-03-14 21:49:55 +01:00
parent 756aafe3dd
commit f997b45145
3 changed files with 64 additions and 6 deletions

View File

@ -378,6 +378,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
if (this->standalone) {
pollForCompletion(engineType);
*this->tagAddress = this->peekLatestSentTaskCount();
}
return 0;
}

View File

@ -46,7 +46,6 @@ CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo) {
pHwInfo->pWaTable,
pHwInfo->pSysInfo);
commandStreamReceiver = AUBCommandStreamReceiver::create(*pHwInfo, "aubfile", true);
initialHardwareTag = -1;
break;
case CSR_TBX:
Gmm::initContext(pHwInfo->pPlatform,

View File

@ -55,6 +55,14 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
return this->dispatchMode;
}
GraphicsAllocation *getTagAllocation() const {
return this->tagAllocation;
}
void setLatestSentTaskCount(uint32_t latestSentTaskCount) {
this->latestSentTaskCount = latestSentTaskCount;
}
MOCK_METHOD2(flattenBatchBuffer, void *(BatchBuffer &batchBuffer, size_t &sizeBatchBuffer));
};
@ -125,9 +133,12 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldLeaveProperRingTailAlignment) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@ -150,11 +161,42 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldUpdateHwTagWithLatestSentTaskCount) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto commandBuffer = memoryManager->allocateGraphicsMemory(4096, 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;
ResidencyContainer allocationsForResidency = {};
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
EXPECT_EQ(initialHardwareTag, *aubCsr->getTagAddress());
aubCsr->setLatestSentTaskCount(aubCsr->peekTaskCount() + 1);
EXPECT_NE(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
aubCsr->flush(batchBuffer, engineType, &allocationsForResidency);
EXPECT_EQ(aubCsr->peekLatestSentTaskCount(), *aubCsr->getTagAddress());
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnCommandBufferAllocation) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@ -201,10 +243,14 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnResidencyAllocations) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
ASSERT_NE(nullptr, gfxAllocation);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
@ -387,11 +433,14 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDefaultDebugConfigThenExpectxpectFlattenBatchBufferIsNotCalled) {
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDefaultDebugConfigThenExpectFlattenBatchBufferIsNotCalled) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@ -415,6 +464,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@ -436,7 +488,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
memoryManager->freeGraphicsMemory(chainedBatchBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedFlattenBatchBufferAndImmediateDispatchModeAndTheresNoChainedBatchBufferThenExpectFlattenBatchBufferIsCalledAnyway) {
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedFlattenBatchBufferAndImmediateDispatchModeAndThereIsNoChainedBatchBufferThenExpectFlattenBatchBufferIsCalledAnyway) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.FlattenBatchBufferForAUBDump.set(true);
DebugManager.flags.CsrDispatchMode.set(CommandStreamReceiver::DispatchMode::ImmediateDispatch);
@ -445,6 +497,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
@ -467,6 +522,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDispatc
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->overrideDispatchPolicy(CommandStreamReceiver::DispatchMode::BatchedDispatch);
aubCsr->setTagAllocation(pDevice->getTagAllocation());
ASSERT_NE(nullptr, aubCsr->getTagAllocation());
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);