mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-26 15:03:02 +08:00
Added support for expectMemory call from aub stream
Change-Id: I8acf27eff8b2f38dcb8d9873e03c35bfab6f3298
This commit is contained in:
@@ -726,6 +726,11 @@ void AUBCommandStreamReceiverHw<GfxFamily>::expectMemoryNotEqual(void *gfxAddres
|
||||
template <typename GfxFamily>
|
||||
void AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(void *gfxAddress, const void *srcAddress,
|
||||
size_t length, uint32_t compareOperation) {
|
||||
if (hardwareContext) {
|
||||
hardwareContext->expectMemory(reinterpret_cast<uint64_t>(gfxAddress), srcAddress, length, compareOperation);
|
||||
return;
|
||||
}
|
||||
|
||||
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset, uint64_t entryBits) {
|
||||
UNRECOVERABLE_IF(offset > length);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ struct HardwareContext {
|
||||
virtual void submit(uint64_t gfxAddress, const void *batchBuffer, size_t size, uint32_t memoryBank) = 0;
|
||||
virtual void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize = 4096) = 0;
|
||||
virtual void freeMemory(uint64_t gfxAddress, size_t size) = 0;
|
||||
virtual void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) = 0;
|
||||
virtual ~HardwareContext() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -146,6 +146,26 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenMakeResidentIsCall
|
||||
EXPECT_TRUE(aubCsr->writeMemoryCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryEqualIsCalledThenItShouldCallTheExpectedFunctions) {
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
aubCsr->expectMemoryEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
|
||||
EXPECT_TRUE(aubCsr->expectMemoryEqualCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryNotEqualIsCalledThenItShouldCallTheExpectedFunctions) {
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
aubCsr->expectMemoryNotEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
|
||||
EXPECT_TRUE(aubCsr->expectMemoryNotEqualCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
@@ -181,6 +201,34 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenMakeResidentIsCall
|
||||
EXPECT_TRUE(mockHardwareContext->writeMemoryCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryEqualIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
aubCsr->expectMemoryEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->expectMemoryCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryNotEqualIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
aubCsr->expectMemoryNotEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->expectMemoryCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenFileStreamShouldBeFlushed) {
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
|
||||
@@ -87,12 +87,22 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
|
||||
AUBCommandStreamReceiverHw<GfxFamily>::pollForCompletion(engineInstance);
|
||||
pollForCompletionCalled = true;
|
||||
}
|
||||
void expectMemoryEqual(void *gfxAddress, const void *srcAddress, size_t length) {
|
||||
AUBCommandStreamReceiverHw<GfxFamily>::expectMemoryEqual(gfxAddress, srcAddress, length);
|
||||
expectMemoryEqualCalled = true;
|
||||
}
|
||||
void expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length) {
|
||||
AUBCommandStreamReceiverHw<GfxFamily>::expectMemoryNotEqual(gfxAddress, srcAddress, length);
|
||||
expectMemoryNotEqualCalled = true;
|
||||
}
|
||||
bool flushBatchedSubmissionsCalled = false;
|
||||
bool initProgrammingFlagsCalled = false;
|
||||
bool initializeEngineCalled = false;
|
||||
bool writeMemoryCalled = false;
|
||||
bool submitBatchBufferCalled = false;
|
||||
bool pollForCompletionCalled = false;
|
||||
bool expectMemoryEqualCalled = false;
|
||||
bool expectMemoryNotEqualCalled = false;
|
||||
|
||||
void initFile(const std::string &fileName) override {
|
||||
fileIsOpen = true;
|
||||
|
||||
@@ -19,12 +19,14 @@ struct MockHardwareContext : public HardwareContext {
|
||||
void submit(uint64_t gfxAddress, const void *batchBuffer, size_t size, uint32_t memoryBank) override { submitCalled = true; }
|
||||
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize = 4096) override { writeMemoryCalled = 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; }
|
||||
|
||||
bool initializeCalled = false;
|
||||
bool pollForCompletionCalled = false;
|
||||
bool submitCalled = false;
|
||||
bool writeMemoryCalled = false;
|
||||
bool freeMemoryCalled = false;
|
||||
bool expectMemoryCalled = false;
|
||||
};
|
||||
|
||||
class MockAubManager : public AubManager {
|
||||
|
||||
Reference in New Issue
Block a user