mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
fix: configure small buffers params based on productHelper
Refactor buffer pool allocator to support configurable SmallBuffersParams based on product helper capabilities. This patch enables setting custom pool parameters instead of using fixed static values. For devices with 2MB local memory alignment enabled (is2MBLocalMemAlignmentEnabled), use larger pool configuration: - Pool size: 16MB (up from 2MB) - Threshold: 2MB (up from 1MB) - Alignment: 64KB (unchanged) - Starting offset: 64KB (unchanged) This improves memory utilization for devices supporting larger memory alignments while maintaining original parameters for other devices. Key changes: - Moved params from static template to instance member - Added SmallBuffersParams struct with default/large configs - Added constructor and setter methods for params configuration Related-To: NEO-12287 Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ef961df421
commit
1eb8e0efd9
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/product_helper.h"
|
||||
#include "shared/source/utilities/buffer_pool_allocator.h"
|
||||
#include "shared/source/utilities/heap_allocator.h"
|
||||
|
||||
@@ -13,9 +14,17 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
inline SmallBuffersParams SmallBuffersParams::getPreferredBufferPoolParams(const ProductHelper &productHelper) {
|
||||
return productHelper.is2MBLocalMemAlignmentEnabled() ? SmallBuffersParams::getLargePagesParams() : SmallBuffersParams::getDefaultParams();
|
||||
}
|
||||
|
||||
template <typename PoolT, typename BufferType, typename BufferParentType>
|
||||
AbstractBuffersPool<PoolT, BufferType, BufferParentType>::AbstractBuffersPool(MemoryManager *memoryManager, OnChunkFreeCallback onChunkFreeCb)
|
||||
: memoryManager{memoryManager}, onChunkFreeCallback{onChunkFreeCb} {
|
||||
: AbstractBuffersPool<PoolT, BufferType, BufferParentType>::AbstractBuffersPool(memoryManager, onChunkFreeCb, SmallBuffersParams::getDefaultParams()) {}
|
||||
|
||||
template <typename PoolT, typename BufferType, typename BufferParentType>
|
||||
AbstractBuffersPool<PoolT, BufferType, BufferParentType>::AbstractBuffersPool(MemoryManager *memoryManager, OnChunkFreeCallback onChunkFreeCb, const SmallBuffersParams ¶ms)
|
||||
: memoryManager{memoryManager}, onChunkFreeCallback{onChunkFreeCb}, params{params} {
|
||||
static_assert(std::is_base_of_v<BufferParentType, BufferType>);
|
||||
}
|
||||
|
||||
@@ -24,7 +33,8 @@ AbstractBuffersPool<PoolT, BufferType, BufferParentType>::AbstractBuffersPool(Ab
|
||||
: memoryManager{bufferPool.memoryManager},
|
||||
mainStorage{std::move(bufferPool.mainStorage)},
|
||||
chunkAllocator{std::move(bufferPool.chunkAllocator)},
|
||||
onChunkFreeCallback{bufferPool.onChunkFreeCallback} {}
|
||||
onChunkFreeCallback{bufferPool.onChunkFreeCallback},
|
||||
params{bufferPool.params} {}
|
||||
|
||||
template <typename PoolT, typename BufferType, typename BufferParentType>
|
||||
void AbstractBuffersPool<PoolT, BufferType, BufferParentType>::tryFreeFromPoolBuffer(BufferParentType *possiblePoolBuffer, size_t offset, size_t size) {
|
||||
@@ -49,7 +59,7 @@ void AbstractBuffersPool<PoolT, BufferType, BufferParentType>::drain() {
|
||||
}
|
||||
}
|
||||
for (auto &chunk : this->chunksToFree) {
|
||||
this->chunkAllocator->free(chunk.first + startingOffset, chunk.second);
|
||||
this->chunkAllocator->free(chunk.first + params.startingOffset, chunk.second);
|
||||
if (static_cast<PoolT *>(this)->onChunkFreeCallback) {
|
||||
(static_cast<PoolT *>(this)->*onChunkFreeCallback)(chunk.first, chunk.second);
|
||||
}
|
||||
@@ -57,6 +67,16 @@ void AbstractBuffersPool<PoolT, BufferType, BufferParentType>::drain() {
|
||||
this->chunksToFree.clear();
|
||||
}
|
||||
|
||||
template <typename BuffersPoolType, typename BufferType, typename BufferParentType>
|
||||
AbstractBuffersAllocator<BuffersPoolType, BufferType, BufferParentType>::AbstractBuffersAllocator(const SmallBuffersParams ¶ms)
|
||||
: params{params} {
|
||||
DEBUG_BREAK_IF(params.aggregatedSmallBuffersPoolSize < params.smallBufferThreshold);
|
||||
}
|
||||
|
||||
template <typename BuffersPoolType, typename BufferType, typename BufferParentType>
|
||||
AbstractBuffersAllocator<BuffersPoolType, BufferType, BufferParentType>::AbstractBuffersAllocator()
|
||||
: AbstractBuffersAllocator(SmallBuffersParams::getDefaultParams()) {}
|
||||
|
||||
template <typename BuffersPoolType, typename BufferType, typename BufferParentType>
|
||||
bool AbstractBuffersAllocator<BuffersPoolType, BufferType, BufferParentType>::isPoolBuffer(const BufferParentType *buffer) const {
|
||||
static_assert(std::is_base_of_v<BufferParentType, BufferType>);
|
||||
|
||||
Reference in New Issue
Block a user