feature: support explicit memory locking

Added lockMemory in context to explicitly locking memory,
Added a boolean flag in graphics_allocation to indicate the allocation
is locked, and modified memory_operations_handler to add lock().

Related-To: NEO-8277
Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
Young Jin Yoon
2024-03-28 08:06:58 +00:00
committed by Compute-Runtime-Automation
parent 15420aa094
commit d6a14d4ed5
49 changed files with 615 additions and 97 deletions

View File

@@ -21,6 +21,7 @@ class MockMemoryOperationsHandler : public MemoryOperationsHandler {
public:
MockMemoryOperationsHandler() {}
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override { return MemoryOperationsStatus::unsupported; }
MemoryOperationsStatus lock(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override { return MemoryOperationsStatus::unsupported; }
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::unsupported; }
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override { return MemoryOperationsStatus::unsupported; }
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) override { return MemoryOperationsStatus::unsupported; }
@@ -31,6 +32,7 @@ class MockMemoryOperationsHandlerTests : public MemoryOperationsHandler {
public:
MockMemoryOperationsHandlerTests() {}
ADDMETHOD_NOBASE(makeResident, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (Device * device, ArrayRef<GraphicsAllocation *> gfxAllocations));
ADDMETHOD_NOBASE(lock, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (Device * device, ArrayRef<GraphicsAllocation *> gfxAllocations));
ADDMETHOD_NOBASE(evict, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (Device * device, GraphicsAllocation &gfxAllocation));
ADDMETHOD_NOBASE(isResident, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (Device * device, GraphicsAllocation &gfxAllocation));
ADDMETHOD_NOBASE(makeResidentWithinOsContext, MemoryOperationsStatus, MemoryOperationsStatus::unsupported, (OsContext * osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable));
@@ -52,6 +54,12 @@ class MockMemoryOperations : public MemoryOperationsHandler {
}
return MemoryOperationsStatus::success;
}
MemoryOperationsStatus lock(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override {
lockCalledCount++;
return MemoryOperationsStatus::success;
}
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override {
evictCalledCount++;
if (captureGfxAllocationsForMakeResident) {
@@ -98,6 +106,7 @@ class MockMemoryOperations : public MemoryOperationsHandler {
int makeResidentCalledCount = 0;
int evictCalledCount = 0;
uint32_t isResidentCalledCount = 0;
uint32_t lockCalledCount = 0;
uint32_t makeResidentContextId = std::numeric_limits<uint32_t>::max();
bool captureGfxAllocationsForMakeResident = false;
};