fix: configure UsmMemAllocPool params based on productHelper

When is2MBLocalMemAlignmentEnabled() returns true,
increase device USM pool parameters:
- Pool size from 2MB to 16MB
- Max serviced size from 1MB to 2MB

Host USM pool parameters remain unchanged.

Related-To: NEO-12287

Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
This commit is contained in:
Fabian Zwoliński
2025-02-10 20:38:40 +00:00
committed by Compute-Runtime-Automation
parent 9d353b5e9b
commit 4b0473718e
4 changed files with 146 additions and 6 deletions

View File

@@ -515,6 +515,29 @@ bool Context::isSingleDeviceContext() {
return getNumDevices() == 1 && devices[0]->getNumGenericSubDevices() == 0;
}
Context::UsmPoolParams Context::getUsmHostPoolParams() const {
return {
.poolSize = 2 * MemoryConstants::megaByte,
.minServicedSize = 0u,
.maxServicedSize = 1 * MemoryConstants::megaByte};
}
Context::UsmPoolParams Context::getUsmDevicePoolParams() const {
const auto &productHelper = devices[0]->getDevice().getProductHelper();
if (productHelper.is2MBLocalMemAlignmentEnabled()) {
return {
.poolSize = 16 * MemoryConstants::megaByte,
.minServicedSize = 0u,
.maxServicedSize = 2 * MemoryConstants::megaByte};
}
return {
.poolSize = 2 * MemoryConstants::megaByte,
.minServicedSize = 0u,
.maxServicedSize = 1 * MemoryConstants::megaByte};
}
void Context::initializeUsmAllocationPools() {
if (this->usmPoolInitialized) {
return;
@@ -531,10 +554,11 @@ void Context::initializeUsmAllocationPools() {
auto &productHelper = getDevices()[0]->getProductHelper();
bool enabled = ApiSpecificConfig::isDeviceUsmPoolingEnabled() && productHelper.isUsmPoolAllocatorSupported();
size_t poolSize = 2 * MemoryConstants::megaByte;
auto usmDevicePoolParams = getUsmDevicePoolParams();
if (debugManager.flags.EnableDeviceUsmAllocationPool.get() != -1) {
enabled = debugManager.flags.EnableDeviceUsmAllocationPool.get() > 0;
poolSize = debugManager.flags.EnableDeviceUsmAllocationPool.get() * MemoryConstants::megaByte;
usmDevicePoolParams.poolSize = debugManager.flags.EnableDeviceUsmAllocationPool.get() * MemoryConstants::megaByte;
}
if (enabled) {
auto subDeviceBitfields = getDeviceBitfields();
@@ -543,14 +567,14 @@ void Context::initializeUsmAllocationPools() {
SVMAllocsManager::UnifiedMemoryProperties memoryProperties(InternalMemoryType::deviceUnifiedMemory, MemoryConstants::pageSize2M,
getRootDeviceIndices(), subDeviceBitfields);
memoryProperties.device = &neoDevice;
usmDeviceMemAllocPool.initialize(svmMemoryManager, memoryProperties, poolSize, 0u, 1 * MemoryConstants::megaByte);
usmDeviceMemAllocPool.initialize(svmMemoryManager, memoryProperties, usmDevicePoolParams.poolSize, usmDevicePoolParams.minServicedSize, usmDevicePoolParams.maxServicedSize);
}
enabled = ApiSpecificConfig::isHostUsmPoolingEnabled() && productHelper.isUsmPoolAllocatorSupported();
poolSize = 2 * MemoryConstants::megaByte;
auto usmHostPoolParams = getUsmHostPoolParams();
if (debugManager.flags.EnableHostUsmAllocationPool.get() != -1) {
enabled = debugManager.flags.EnableHostUsmAllocationPool.get() > 0;
poolSize = debugManager.flags.EnableHostUsmAllocationPool.get() * MemoryConstants::megaByte;
usmHostPoolParams.poolSize = debugManager.flags.EnableHostUsmAllocationPool.get() * MemoryConstants::megaByte;
}
if (enabled) {
auto subDeviceBitfields = getDeviceBitfields();
@@ -558,7 +582,7 @@ void Context::initializeUsmAllocationPools() {
subDeviceBitfields[neoDevice.getRootDeviceIndex()] = neoDevice.getDeviceBitfield();
SVMAllocsManager::UnifiedMemoryProperties memoryProperties(InternalMemoryType::hostUnifiedMemory, MemoryConstants::pageSize2M,
getRootDeviceIndices(), subDeviceBitfields);
usmHostMemAllocPool.initialize(svmMemoryManager, memoryProperties, poolSize, 0u, 1 * MemoryConstants::megaByte);
usmHostMemAllocPool.initialize(svmMemoryManager, memoryProperties, usmHostPoolParams.poolSize, usmHostPoolParams.minServicedSize, usmHostPoolParams.maxServicedSize);
}
this->usmPoolInitialized = true;
}