Extended AUB fixtures with expect compressed memory

Related-To: NEO-5577

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2021-02-22 12:02:08 +00:00
committed by Compute-Runtime-Automation
parent 4d59d5fd50
commit 905ed9e5bf
17 changed files with 123 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -52,6 +52,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override;
bool writeMemory(GraphicsAllocation &gfxAllocation) override;
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
void writeMMIO(uint32_t offset, uint32_t value) override;
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue);
bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override;

View File

@@ -677,6 +677,15 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(AllocationView &allocati
return writeMemory(gfxAllocation);
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::writeMMIO(uint32_t offset, uint32_t value) {
auto streamLocked = getAubStream()->lockStream();
if (hardwareContextController) {
return hardwareContextController->writeMMIO(offset, value);
}
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::expectMMIO(uint32_t mmioRegister, uint32_t expectedValue) {
if (hardwareContextController) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -51,11 +51,13 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
void setupContext(OsContext &osContext) override;
virtual bool expectMemoryEqual(void *gfxAddress, const void *srcAddress, size_t length);
virtual bool expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length);
virtual bool expectMemoryCompressed(void *gfxAddress, const void *srcAddress, size_t length);
virtual void pollForCompletion() = 0;
virtual void pollForCompletionImpl(){};
virtual bool writeMemory(GraphicsAllocation &gfxAllocation) = 0;
virtual void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) = 0;
virtual void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) = 0;
virtual void writeMMIO(uint32_t offset, uint32_t value) = 0;
virtual void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation) = 0;
virtual bool isAubWritable(GraphicsAllocation &graphicsAllocation) const = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -74,6 +74,11 @@ bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::expectMemoryNotEqual(voi
return this->expectMemory(gfxAddress, srcAddress, length,
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual);
}
template <typename GfxFamily>
bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::expectMemoryCompressed(void *gfxAddress, const void *srcAddress, size_t length) {
return this->expectMemory(gfxAddress, srcAddress, length,
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual);
}
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::freeEngineInfo(AddressMapper &gttRemap) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -52,6 +52,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override;
bool writeMemory(GraphicsAllocation &gfxAllocation) override;
void writeMMIO(uint32_t offset, uint32_t value) override;
bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override;
AubSubCaptureStatus checkAndActivateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;

View File

@@ -442,6 +442,13 @@ bool TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
return true;
}
template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::writeMMIO(uint32_t offset, uint32_t value) {
if (hardwareContextController) {
hardwareContextController->writeMMIO(offset, value);
}
}
template <typename GfxFamily>
bool TbxCommandStreamReceiverHw<GfxFamily>::expectMemory(const void *gfxAddress, const void *srcAddress,
size_t length, uint32_t compareOperation) {

View File

@@ -67,6 +67,10 @@ void HardwareContextController::writeMemory(aub_stream::AllocationParams &alloca
}
}
void HardwareContextController::writeMMIO(uint32_t offset, uint32_t value) {
hardwareContexts[0]->writeMMIO(offset, value);
}
void HardwareContextController::dumpBufferBIN(uint64_t gfxAddress, size_t size) {
hardwareContexts[0]->dumpBufferBIN(gfxAddress, size);
}

View File

@@ -26,6 +26,7 @@ class HardwareContextController {
void expectMemory(uint64_t gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation);
void submit(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits, bool overrideRingHead);
void writeMemory(aub_stream::AllocationParams &allocationParams);
void writeMMIO(uint32_t offset, uint32_t value);
void dumpBufferBIN(uint64_t gfxAddress, size_t size);
void dumpSurface(const aub_stream::SurfaceInfo &surfaceInfo);

View File

@@ -84,6 +84,14 @@ class AUBFixture : public CommandQueueHwFixture {
}
}
template <typename FamilyType>
void writeMMIO(uint32_t offset, uint32_t value) {
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>();
if (csrSimulated) {
csrSimulated->writeMMIO(offset, value);
}
}
template <typename FamilyType>
void expectNotEqualMemory(void *gfxAddress, const void *srcAddress, size_t length) {
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>();
@@ -100,6 +108,22 @@ class AUBFixture : public CommandQueueHwFixture {
}
}
template <typename FamilyType>
void expectCompressedMemory(void *gfxAddress, const void *srcAddress, size_t length) {
CommandStreamReceiverSimulatedCommonHw<FamilyType> *csrSimulated = getSimulatedCsr<FamilyType>();
if (testMode == TestMode::AubTestsWithTbx) {
auto tbxCsr = csrSimulated;
EXPECT_TRUE(tbxCsr->expectMemoryCompressed(gfxAddress, srcAddress, length));
csrSimulated = static_cast<CommandStreamReceiverSimulatedCommonHw<FamilyType> *>(
static_cast<CommandStreamReceiverWithAUBDump<TbxCommandStreamReceiverHw<FamilyType>> *>(csr)->aubCSR.get());
}
if (csrSimulated) {
csrSimulated->expectMemoryCompressed(gfxAddress, srcAddress, length);
}
}
static void *getGpuPointer(GraphicsAllocation *allocation) {
return reinterpret_cast<void *>(allocation->getGpuAddress());
}

View File

@@ -1379,6 +1379,22 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
EXPECT_EQ(2u, mockHwContext1->memoryBanksPassed);
}
TEST_F(HardwareContextContainerTests, givenHwContextWhenWriteMMIOIsCalledThenUseFirstContext) {
MockAubManager aubManager;
MockOsContext osContext(1, 0b1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled,
false, false, false);
HardwareContextController hwContextContainer(aubManager, osContext, 0);
EXPECT_EQ(1u, hwContextContainer.hardwareContexts.size());
auto mockHwContext = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
EXPECT_FALSE(mockHwContext->writeMMIOCalled);
hwContextContainer.writeMMIO(0x01234567, 0x89ABCDEF);
EXPECT_TRUE(mockHwContext->writeMMIOCalled);
}
TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCalledThenUseFirstContext) {
MockAubManager aubManager;
MockOsContext osContext(1, 0b11, aub_stream::ENGINE_RCS, PreemptionMode::Disabled,

View File

@@ -920,6 +920,31 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenPhysica
ASSERT_NE(nullptr, allocator);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWithoutHardwareContextControllerWhenCallingWriteMMIOThenDontRedirectToHardwareContextController) {
MockAubCsr<FamilyType> aubCsr("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
MockOsContext osContext(0, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled,
false, false, false);
EXPECT_EQ(nullptr, aubCsr.hardwareContextController);
aubCsr.writeMMIO(0x11111111, 0x22222222);
EXPECT_TRUE(aubCsr.writeMMIOCalled);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWithHardwareContextControllerWhenCallingWriteMMIOThenRedirectToHardwareContextController) {
MockAubCsr<FamilyType> aubCsr("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
MockOsContext osContext(0, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled,
false, false, false);
aubCsr.setupContext(osContext);
EXPECT_NE(nullptr, aubCsr.hardwareContextController);
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
aubCsr.writeMMIO(0x11111111, 0x22222222);
EXPECT_TRUE(mockHardwareContext->writeMMIOCalled);
}
HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpAllocationIsCalledAndDumpFormatIsSpecifiedThenGraphicsAllocationShouldBeDumped) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.AUBDumpBufferFormat.set("BIN");

View File

@@ -569,6 +569,15 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryNotEqu
EXPECT_TRUE(aubCsr->expectMemoryNotEqualCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryCompressedIsCalledThenItShouldCallTheExpectedFunctions) {
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
aubCsr->expectMemoryCompressed(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
EXPECT_TRUE(aubCsr->expectMemoryCompressedCalled);
}
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
MockAubCsr<FamilyType> aubCsr("", true, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
MockOsContext osContext(0, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled,

View File

@@ -1281,6 +1281,7 @@ struct MockSimulatedCsrHw : public CommandStreamReceiverSimulatedHw<FamilyType>
void pollForCompletion() override {}
bool writeMemory(GraphicsAllocation &gfxAllocation) override { return true; }
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override {}
void writeMMIO(uint32_t offset, uint32_t value) override {}
void dumpAllocation(GraphicsAllocation &gfxAllocation) override {}
};

View File

@@ -25,6 +25,7 @@ class MockSimulatedCsrHw : public CommandStreamReceiverSimulatedHw<FamilyType> {
void pollForCompletion() override {}
bool writeMemory(GraphicsAllocation &gfxAllocation) override { return true; }
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override {}
void writeMMIO(uint32_t offset, uint32_t value) override {}
void dumpAllocation(GraphicsAllocation &gfxAllocation) override {}
};

View File

@@ -87,6 +87,10 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(gpuAddress, cpuAddress, size, memoryBank, entryBits);
writeMemoryCalled = true;
}
void writeMMIO(uint32_t offset, uint32_t value) override {
AUBCommandStreamReceiverHw<GfxFamily>::writeMMIO(offset, value);
writeMMIOCalled = true;
}
void submitBatchBuffer(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits) override {
AUBCommandStreamReceiverHw<GfxFamily>::submitBatchBuffer(batchBufferGpuAddress, batchBuffer, batchBufferSize, memoryBank, entryBits);
submitBatchBufferCalled = true;
@@ -109,6 +113,10 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
expectMemoryNotEqualCalled = true;
return AUBCommandStreamReceiverHw<GfxFamily>::expectMemoryNotEqual(gfxAddress, srcAddress, length);
}
bool expectMemoryCompressed(void *gfxAddress, const void *srcAddress, size_t length) override {
expectMemoryCompressedCalled = true;
return AUBCommandStreamReceiverHw<GfxFamily>::expectMemoryCompressed(gfxAddress, srcAddress, length);
}
bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) override {
return true;
}
@@ -129,10 +137,12 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
bool initializeEngineCalled = false;
bool writeMemoryCalled = false;
bool writeMemoryWithAubManagerCalled = false;
bool writeMMIOCalled = false;
bool submitBatchBufferCalled = false;
bool pollForCompletionCalled = false;
bool expectMemoryEqualCalled = false;
bool expectMemoryNotEqualCalled = false;
bool expectMemoryCompressedCalled = false;
bool addAubCommentCalled = false;
bool dumpAllocationCalled = false;

View File

@@ -36,6 +36,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
storedAllocationParams.push_back(allocationParams);
}
}
void writeMMIO(uint32_t offset, uint32_t value) override { writeMMIOCalled = true; }
void freeMemory(uint64_t gfxAddress, size_t size) override { freeMemoryCalled = true; }
void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) override { expectMemoryCalled = true; }
void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBank, size_t pageSize) override { readMemoryCalled = true; }
@@ -52,6 +53,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
bool freeMemoryCalled = false;
bool expectMemoryCalled = false;
bool readMemoryCalled = false;
bool writeMMIOCalled = false;
bool dumpBufferBINCalled = false;
bool dumpSurfaceCalled = false;

View File

@@ -27,6 +27,7 @@ struct HardwareContext {
virtual void dumpSurface(const SurfaceInfo &surfaceInfo) = 0;
virtual ~HardwareContext() = default;
virtual void writeMemory2(AllocationParams allocationParams) = 0;
virtual void writeMMIO(uint32_t offset, uint32_t value) = 0;
};
} // namespace aub_stream