fix: initialize engine in AubMemoryOperationsHandler::makeResident

Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwoliński
2024-08-13 17:11:57 +00:00
committed by Compute-Runtime-Automation
parent a32bb4d9a4
commit f4ad45eafd
5 changed files with 51 additions and 1 deletions

View File

@@ -88,6 +88,10 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
writeMemoryAubCalled++;
}
void initializeEngine() override {
initializeEngineCalled++;
}
bool isMultiOsContextCapable() const override { return multiOsContextCapable; }
bool isGpuHangDetected() const override {
@@ -252,6 +256,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
uint32_t waitForCompletionWithTimeoutCalled = 0;
uint32_t fillReusableAllocationsListCalled = 0;
uint32_t writeMemoryAubCalled = 0;
uint32_t initializeEngineCalled = 0;
uint32_t makeResidentCalledTimes = 0;
uint32_t downloadAllocationsCalledCount = 0;
uint32_t submitDependencyUpdateCalledTimes = 0;

View File

@@ -152,6 +152,46 @@ TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerAndAllocationInLocalMemor
device->getDefaultEngine().commandStreamReceiver = oldCsr;
}
TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledThenInitializeEngineBeforeWriteMemory) {
DeviceBitfield deviceBitfield(1);
const auto csr = std::make_unique<MockCommandStreamReceiver>(*device->getExecutionEnvironment(), 0, deviceBitfield);
csr->localMemoryEnabled = true;
auto oldCsr = device->getDefaultEngine().commandStreamReceiver;
device->getDefaultEngine().commandStreamReceiver = csr.get();
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
auto result = memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::success);
EXPECT_EQ(1u, csr->initializeEngineCalled);
auto itor = std::find(memoryOperationsInterface->residentAllocations.begin(), memoryOperationsInterface->residentAllocations.end(), allocPtr);
EXPECT_NE(memoryOperationsInterface->residentAllocations.end(), itor);
EXPECT_EQ(1u, memoryOperationsInterface->residentAllocations.size());
device->getDefaultEngine().commandStreamReceiver = oldCsr;
}
TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledWithNullDeviceThenDoNotInitializeEngineBeforeWriteMemory) {
DeviceBitfield deviceBitfield(1);
const auto csr = std::make_unique<MockCommandStreamReceiver>(*device->getExecutionEnvironment(), 0, deviceBitfield);
csr->localMemoryEnabled = true;
auto oldCsr = device->getDefaultEngine().commandStreamReceiver;
device->getDefaultEngine().commandStreamReceiver = csr.get();
MockAubManager aubManager;
getMemoryOperationsHandler()->setAubManager(&aubManager);
auto memoryOperationsInterface = getMemoryOperationsHandler();
auto result = memoryOperationsInterface->makeResident(nullptr, ArrayRef<GraphicsAllocation *>(&allocPtr, 1));
EXPECT_EQ(result, MemoryOperationsStatus::success);
EXPECT_EQ(0u, csr->initializeEngineCalled);
device->getDefaultEngine().commandStreamReceiver = oldCsr;
}
TEST_F(AubMemoryOperationsHandlerTests, givenAubManagerWhenMakeResidentCalledOnCompressedAllocationThenPassCorrectParams) {
MockAubManager aubManager;
aubManager.storeAllocationParams = true;