mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
performance(ocl): calculate max buffer pool count
Set max buffer pool count to use at most 2 percent of device total memory. Related-To: NEO-9690 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
da16dad344
commit
dcab4863d5
@@ -595,6 +595,10 @@ Buffer *Context::BufferPool::allocate(const MemoryProperties &memoryProperties,
|
||||
|
||||
void Context::BufferPoolAllocator::initAggregatedSmallBuffers(Context *context) {
|
||||
this->context = context;
|
||||
const auto &device = context->getDevice(0)->getDevice();
|
||||
const auto bitfield = device.getDeviceBitfield();
|
||||
const auto deviceMemory = device.getGlobalMemorySize(static_cast<uint32_t>(bitfield.to_ulong()));
|
||||
this->maxPoolCount = this->calculateMaxPoolCount(deviceMemory, 2);
|
||||
this->addNewBufferPool(Context::BufferPool{this->context});
|
||||
}
|
||||
|
||||
@@ -624,7 +628,7 @@ Buffer *Context::BufferPoolAllocator::allocateBufferFromPool(const MemoryPropert
|
||||
return bufferFromPool;
|
||||
}
|
||||
|
||||
if (this->bufferPools.size() < BufferPoolAllocator::maxPoolCount) {
|
||||
if (this->bufferPools.size() < this->maxPoolCount) {
|
||||
this->addNewBufferPool(BufferPool{this->context});
|
||||
return this->allocateFromPools(memoryProperties, flags, flagsIntel, requestedSize, hostPtr, errcodeRet);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -86,8 +86,13 @@ class Context : public BaseObject<_cl_context> {
|
||||
size_t requestedSize,
|
||||
void *hostPtr,
|
||||
cl_int &errcodeRet);
|
||||
static inline size_t calculateMaxPoolCount(uint64_t totalMemory, size_t percentOfMemory) {
|
||||
const auto maxPoolCount = static_cast<size_t>(totalMemory * (percentOfMemory / 100.0) / BufferPoolAllocator::aggregatedSmallBuffersPoolSize);
|
||||
return maxPoolCount ? maxPoolCount : 1u;
|
||||
}
|
||||
|
||||
Context *context{nullptr};
|
||||
size_t maxPoolCount{1u};
|
||||
};
|
||||
|
||||
static const cl_ulong objectMagic = 0xA4234321DC002130LL;
|
||||
|
||||
Reference in New Issue
Block a user