fix: write memory for resident allocations in simulation mode

- refactor and call proceesFlushResdiency() on memoryOperationsHandler
- call free() to remove allocation from resident allocations when
graphics allocation is released

Related-To: NEO-11719

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2024-06-14 14:15:14 +00:00
committed by Compute-Runtime-Automation
parent 9954002db1
commit b3d72ddd3d
15 changed files with 285 additions and 73 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -93,6 +93,10 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(gpuAddress, cpuAddress, size, memoryBank, entryBits);
writeMemoryCalled = true;
}
bool writeMemory(GraphicsAllocation &gfxAllocation) override {
writeMemoryGfxAllocCalled = true;
return AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(gfxAllocation);
}
void writeMMIO(uint32_t offset, uint32_t value) override {
AUBCommandStreamReceiverHw<GfxFamily>::writeMMIO(offset, value);
writeMMIOCalled = true;
@@ -146,6 +150,7 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
bool initProgrammingFlagsCalled = false;
bool initializeEngineCalled = false;
bool writeMemoryCalled = false;
bool writeMemoryGfxAllocCalled = false;
bool writeMemoryWithAubManagerCalled = false;
bool writeMMIOCalled = false;
bool submitBatchBufferCalled = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2023-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -46,11 +46,17 @@ struct MockAubMemoryOperationsHandler : public AubMemoryOperationsHandler {
return AubMemoryOperationsHandler::evictWithinOsContext(osContext, gfxAllocation);
}
MemoryOperationsStatus free(Device *device, GraphicsAllocation &gfxAllocation) override {
freeCalled = true;
return AubMemoryOperationsHandler::free(device, gfxAllocation);
}
bool makeResidentCalled = false;
bool evictCalled = false;
bool isResidentCalled = false;
bool makeResidentWithinOsContextCalled = false;
bool evictWithinOsContextCalled = false;
bool freeCalled = false;
};
} // namespace NEO

View File

@@ -102,9 +102,23 @@ class MockMemoryOperations : public MemoryOperationsHandler {
return MemoryOperationsStatus::success;
}
MemoryOperationsStatus free(Device *device, GraphicsAllocation &gfxAllocation) override {
freeCalledCount++;
if (captureGfxAllocationsForMakeResident) {
auto itor = std::find(gfxAllocationsForMakeResident.begin(), gfxAllocationsForMakeResident.end(), &gfxAllocation);
if (itor != gfxAllocationsForMakeResident.end()) {
gfxAllocationsForMakeResident.erase(itor, itor + 1);
}
}
return MemoryOperationsStatus::success;
}
std::vector<GraphicsAllocation *> gfxAllocationsForMakeResident{};
int makeResidentCalledCount = 0;
int evictCalledCount = 0;
int freeCalledCount = 0;
uint32_t isResidentCalledCount = 0;
uint32_t lockCalledCount = 0;
uint32_t makeResidentContextId = std::numeric_limits<uint32_t>::max();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -42,6 +42,11 @@ class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(gpuAddress, cpuAddress, size, memoryBank, entryBits);
writeMemoryCalled = true;
}
bool writeMemory(GraphicsAllocation &graphicsAllocation) override {
writeMemoryGfxAllocCalled = true;
return TbxCommandStreamReceiverHw<GfxFamily>::writeMemory(graphicsAllocation);
}
void submitBatchBufferTbx(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits, bool overrideRingHead) override {
TbxCommandStreamReceiverHw<GfxFamily>::submitBatchBufferTbx(batchBufferGpuAddress, batchBuffer, batchBufferSize, memoryBank, entryBits, overrideRingHead);
overrideRingHeadPassed = overrideRingHead;
@@ -62,6 +67,7 @@ class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
bool initializeEngineCalled = false;
bool writeMemoryWithAubManagerCalled = false;
bool writeMemoryCalled = false;
bool writeMemoryGfxAllocCalled = false;
bool submitBatchBufferCalled = false;
bool overrideRingHeadPassed = false;
bool pollForCompletionCalled = false;