mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
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:
committed by
Compute-Runtime-Automation
parent
e51c34ed99
commit
cdfe2ce8ad
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user