Add support for unrestricted size flag in the USM

Resolves: NEO-3960

Change-Id: Ie3557de70702b5aee53cc7c08ed602e580282979
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz
2019-12-19 12:59:48 +01:00
committed by sys_ocldev
parent 9bba2ccd6b
commit 2ef557bf68
2 changed files with 96 additions and 17 deletions

View File

@@ -3450,11 +3450,6 @@ void *clHostMemAllocINTEL(
return nullptr;
}
if (size > neoContext->getDevice(0u)->getDeviceInfo().maxMemAllocSize) {
err.set(CL_INVALID_BUFFER_SIZE);
return nullptr;
}
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY);
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
@@ -3464,6 +3459,11 @@ void *clHostMemAllocINTEL(
return nullptr;
}
if (size > neoContext->getDevice(0u)->getDeviceInfo().maxMemAllocSize && !unifiedMemoryProperties.allocationFlags.flags.allowUnrestrictedSize) {
err.set(CL_INVALID_BUFFER_SIZE);
return nullptr;
}
if (isValueSet(unifiedMemoryProperties.allocationFlags.allAllocFlags, CL_MEM_ALLOC_WRITE_COMBINED_INTEL)) {
err.set(CL_INVALID_VALUE);
return nullptr;
@@ -3491,11 +3491,6 @@ void *clDeviceMemAllocINTEL(
return nullptr;
}
if (size > neoDevice->getDeviceInfo().maxMemAllocSize) {
err.set(CL_INVALID_BUFFER_SIZE);
return nullptr;
}
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY);
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
@@ -3504,6 +3499,12 @@ void *clDeviceMemAllocINTEL(
err.set(CL_INVALID_VALUE);
return nullptr;
}
if (size > neoContext->getDevice(0u)->getDeviceInfo().maxMemAllocSize && !unifiedMemoryProperties.allocationFlags.flags.allowUnrestrictedSize) {
err.set(CL_INVALID_BUFFER_SIZE);
return nullptr;
}
unifiedMemoryProperties.device = device;
unifiedMemoryProperties.subdeviceBitfield = neoDevice->getDefaultEngine().osContext->getDeviceBitfield();
@@ -3529,11 +3530,6 @@ void *clSharedMemAllocINTEL(
return nullptr;
}
if (size > neoDevice->getDeviceInfo().maxMemAllocSize) {
err.set(CL_INVALID_BUFFER_SIZE);
return nullptr;
}
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY);
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
@@ -3542,14 +3538,20 @@ void *clSharedMemAllocINTEL(
err.set(CL_INVALID_VALUE);
return nullptr;
}
unifiedMemoryProperties.device = device;
unifiedMemoryProperties.subdeviceBitfield = neoDevice->getDefaultEngine().osContext->getDeviceBitfield();
if (size > neoContext->getDevice(0u)->getDeviceInfo().maxMemAllocSize && !unifiedMemoryProperties.allocationFlags.flags.allowUnrestrictedSize) {
err.set(CL_INVALID_BUFFER_SIZE);
return nullptr;
}
if (isValueSet(unifiedMemoryProperties.allocationFlags.allAllocFlags, CL_MEM_ALLOC_WRITE_COMBINED_INTEL)) {
err.set(CL_INVALID_VALUE);
return nullptr;
}
unifiedMemoryProperties.device = device;
unifiedMemoryProperties.subdeviceBitfield = neoDevice->getDefaultEngine().osContext->getDeviceBitfield();
return neoContext->getSVMAllocsManager()->createSharedUnifiedMemoryAllocation(neoContext->getDevice(0)->getRootDeviceIndex(), size, unifiedMemoryProperties, neoContext->getSpecialQueue());
}