performance: redesign usm alloc reuse mechanism

Dedicated pools for different allocations size ranges.
Additional reused allocations will create their own pools.
Do not reuse allocations >256MB.

Related-To: NEO-6893, NEO-12299, NEO-12349

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2024-09-10 15:50:05 +00:00
committed by Compute-Runtime-Automation
parent dfbad8029b
commit b2fc7345cf
20 changed files with 976 additions and 60 deletions

View File

@@ -172,6 +172,9 @@ GraphicsAllocation *MockMemoryManager::allocateGraphicsMemoryInDevicePool(const
}
GraphicsAllocation *MockMemoryManager::allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) {
if (returnMockGAFromHostPool) {
return mockGa;
}
if (failInAllocateWithSizeAndAlignment) {
return nullptr;
}

View File

@@ -58,6 +58,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
using MemoryManager::isAllocationTypeToCapture;
using MemoryManager::isCopyRequired;
using MemoryManager::latestContextId;
using MemoryManager::localMemAllocsSize;
using MemoryManager::localMemorySupported;
using MemoryManager::reservedMemory;
using MemoryManager::secondaryEngines;
@@ -279,6 +280,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
bool callBaseAllocateGraphicsMemoryForNonSvmHostPtr = true;
bool failMapPhysicalToVirtualMemory = false;
bool returnMockGAFromDevicePool = false;
bool returnMockGAFromHostPool = false;
std::unique_ptr<MockExecutionEnvironment> mockExecutionEnvironment;
DeviceBitfield recentlyPassedDeviceBitfield{};
std::unique_ptr<MultiGraphicsAllocation> waitAllocations = nullptr;

View File

@@ -23,5 +23,6 @@ struct MockProductHelper : ProductHelperHw<IGFX_UNKNOWN> {
ADDMETHOD_CONST_NOBASE(isBlitCopyRequiredForLocalMemory, bool, true, (const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation));
ADDMETHOD_CONST_NOBASE(isDeviceUsmAllocationReuseSupported, bool, false, ());
ADDMETHOD_CONST_NOBASE(isHostUsmAllocationReuseSupported, bool, false, ());
ADDMETHOD_CONST_NOBASE(isUsmPoolAllocatorSupported, bool, false, ());
};
} // namespace NEO

View File

@@ -12,9 +12,30 @@ namespace NEO {
class MockUsmMemAllocPool : public UsmMemAllocPool {
public:
using UsmMemAllocPool::allocations;
using UsmMemAllocPool::maxServicedSize;
using UsmMemAllocPool::minServicedSize;
using UsmMemAllocPool::pool;
using UsmMemAllocPool::poolEnd;
using UsmMemAllocPool::poolMemoryType;
using UsmMemAllocPool::poolSize;
};
class MockUsmMemAllocPoolsManager : public UsmMemAllocPoolsManager {
public:
using UsmMemAllocPoolsManager::canBePooled;
using UsmMemAllocPoolsManager::device;
using UsmMemAllocPoolsManager::getPoolContainingAlloc;
using UsmMemAllocPoolsManager::memoryManager;
using UsmMemAllocPoolsManager::pools;
using UsmMemAllocPoolsManager::totalSize;
using UsmMemAllocPoolsManager::UsmMemAllocPoolsManager;
uint64_t getFreeMemory() override {
if (callBaseGetFreeMemory) {
return UsmMemAllocPoolsManager::getFreeMemory();
}
return mockFreeMemory;
}
uint64_t mockFreeMemory = 0u;
bool callBaseGetFreeMemory = false;
};
} // namespace NEO

View File

@@ -625,4 +625,5 @@ DeferStateInitSubmissionToFirstRegularUsage = -1
WaitForPagingFenceInController = -1
DirectSubmissionPrintSemaphoreUsage = -1
ForceNonCoherentModeForTimestamps = 0
ExperimentalUSMAllocationReuseVersion = -1
# Please don't edit below this line