performance(ocl): add usm allocation pooling flag

EnableDeviceUsmAllocationPool and EnableHostUsmAllocationPool for device
and host allocations respectively.

Pool size will be set to flag value * MB.

Allocation size threshold to be pooled is 1MB.

Pools are created per context.

Related-To: NEO-9700

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2023-12-22 14:26:30 +00:00
committed by Compute-Runtime-Automation
parent 047438850d
commit 2fe3804cc2
25 changed files with 562 additions and 35 deletions

View File

@@ -3903,6 +3903,11 @@ CL_API_ENTRY void *CL_API_CALL clHostMemAllocINTEL(
return nullptr;
}
auto allocationFromPool = neoContext->getHostMemAllocPool().createUnifiedMemoryAllocation(size, unifiedMemoryProperties);
if (allocationFromPool) {
return allocationFromPool;
}
return neoContext->getSVMAllocsManager()->createHostUnifiedMemoryAllocation(size, unifiedMemoryProperties);
}
@@ -3952,6 +3957,11 @@ CL_API_ENTRY void *CL_API_CALL clDeviceMemAllocINTEL(
unifiedMemoryProperties.device = &neoDevice->getDevice();
auto allocationFromPool = neoContext->getDeviceMemAllocPool().createUnifiedMemoryAllocation(size, unifiedMemoryProperties);
if (allocationFromPool) {
return allocationFromPool;
}
return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(size, unifiedMemoryProperties);
}
@@ -4025,6 +4035,14 @@ CL_API_ENTRY cl_int CL_API_CALL clMemFreeCommon(cl_context context,
return retVal;
}
if (ptr && neoContext->getDeviceMemAllocPool().freeSVMAlloc(const_cast<void *>(ptr), blocking)) {
return CL_SUCCESS;
}
if (ptr && neoContext->getHostMemAllocPool().freeSVMAlloc(const_cast<void *>(ptr), blocking)) {
return CL_SUCCESS;
}
if (ptr && !neoContext->getSVMAllocsManager()->freeSVMAlloc(const_cast<void *>(ptr), blocking)) {
return CL_INVALID_VALUE;
}
@@ -4978,6 +4996,9 @@ cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel,
const auto allocationsCounter = svmManager->allocationsCounter.load();
if (allocationsCounter > 0) {
if (allocationsCounter == multiDeviceKernel->getKernelArguments()[argIndex].allocIdMemoryManagerCounter) {
// manager count is not being incremented when allocation is from pool
// 1) add check for allocation from pool
// 2) increment when allocation is from pool
reuseFromCache = true;
} else {
const auto svmData = svmManager->getSVMAlloc(argValue);
@@ -5041,7 +5062,6 @@ cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel kernel,
allocId = svmData->getAllocId();
}
}
retVal = multiDeviceKernel->setArgSvmAlloc(argIndex, const_cast<void *>(argValue), svmAllocs, allocId);
TRACING_EXIT(ClSetKernelArgSvmPointer, &retVal);
return retVal;