mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Check for max allocation size while allocating USM.
Change-Id: I870ffd5d8716dc50ac064666b54f5fa92d8beca3 Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
16f7b9af16
commit
6646bd81a7
@@ -3412,6 +3412,11 @@ 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);
|
||||
if (!MemObjHelper::parseUnifiedMemoryProperties(properties, unifiedMemoryProperties)) {
|
||||
err.set(CL_INVALID_VALUE);
|
||||
@@ -3429,23 +3434,29 @@ void *clDeviceMemAllocINTEL(
|
||||
cl_uint alignment,
|
||||
cl_int *errcodeRet) {
|
||||
Context *neoContext = nullptr;
|
||||
Device *neoDevice = nullptr;
|
||||
|
||||
ErrorCodeHelper err(errcodeRet, CL_SUCCESS);
|
||||
|
||||
auto retVal = validateObjects(WithCastToInternal(context, &neoContext));
|
||||
auto retVal = validateObjects(WithCastToInternal(context, &neoContext), WithCastToInternal(device, &neoDevice));
|
||||
|
||||
if (retVal != CL_SUCCESS) {
|
||||
err.set(retVal);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (size > neoDevice->getDeviceInfo().maxMemAllocSize) {
|
||||
err.set(CL_INVALID_BUFFER_SIZE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY);
|
||||
if (!MemObjHelper::parseUnifiedMemoryProperties(properties, unifiedMemoryProperties)) {
|
||||
err.set(CL_INVALID_VALUE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(neoContext->getDevice(0)->getRootDeviceIndex(), size, unifiedMemoryProperties);
|
||||
return neoContext->getSVMAllocsManager()->createUnifiedMemoryAllocation(neoDevice->getRootDeviceIndex(), size, unifiedMemoryProperties);
|
||||
}
|
||||
|
||||
void *clSharedMemAllocINTEL(
|
||||
@@ -3456,16 +3467,22 @@ void *clSharedMemAllocINTEL(
|
||||
cl_uint alignment,
|
||||
cl_int *errcodeRet) {
|
||||
Context *neoContext = nullptr;
|
||||
Device *neoDevice = nullptr;
|
||||
|
||||
ErrorCodeHelper err(errcodeRet, CL_SUCCESS);
|
||||
|
||||
auto retVal = validateObjects(WithCastToInternal(context, &neoContext));
|
||||
auto retVal = validateObjects(WithCastToInternal(context, &neoContext), WithCastToInternal(device, &neoDevice));
|
||||
|
||||
if (retVal != CL_SUCCESS) {
|
||||
err.set(retVal);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (size > neoDevice->getDeviceInfo().maxMemAllocSize) {
|
||||
err.set(CL_INVALID_BUFFER_SIZE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY);
|
||||
if (!MemObjHelper::parseUnifiedMemoryProperties(properties, unifiedMemoryProperties)) {
|
||||
err.set(CL_INVALID_VALUE);
|
||||
|
||||
Reference in New Issue
Block a user