Feature: Flag for device usm allocation reusing

With flag enabled, when app calls freeSVMAlloc on device usm allocation,
don't free it immediately but save it,
and try to use it on subsequent allocations.

This allocation cache will be trimmed if an allocation fails.

Related-To: NEO-6893

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2022-04-14 15:23:52 +00:00
committed by Compute-Runtime-Automation
parent e51c34ed99
commit cdfe2ce8ad
9 changed files with 491 additions and 32 deletions

View File

@@ -392,4 +392,23 @@ class MockMemoryManagerOsAgnosticContext : public MockMemoryManager {
}
};
class MockMemoryManagerWithCapacity : public MockMemoryManager {
public:
MockMemoryManagerWithCapacity(NEO::ExecutionEnvironment &executionEnvironment) : MockMemoryManager(executionEnvironment) {}
GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) override {
if (this->capacity >= properties.size) {
this->capacity -= properties.size;
return MockMemoryManager::allocateGraphicsMemoryWithProperties(properties);
}
return nullptr;
}
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override {
this->capacity += gfxAllocation->getUnderlyingBufferSize();
MockMemoryManager::freeGraphicsMemoryImpl(gfxAllocation);
};
size_t capacity = 0u;
};
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,11 +8,14 @@
#pragma once
#include "shared/source/memory_manager/unified_memory_manager.h"
namespace NEO {
struct MockSVMAllocsManager : SVMAllocsManager {
struct MockSVMAllocsManager : public SVMAllocsManager {
public:
using SVMAllocsManager::memoryManager;
using SVMAllocsManager::multiOsContextSupport;
using SVMAllocsManager::SVMAllocs;
using SVMAllocsManager::SVMAllocsManager;
using SVMAllocsManager::svmMapOperations;
using SVMAllocsManager::usmDeviceAllocationsCache;
using SVMAllocsManager::usmDeviceAllocationsCacheEnabled;
};
} // namespace NEO