Connect UnifiedMemoryProperties with MemoryPropertiesFlags

-Add support to SvmAllocationData
-Refactor parseMemoryProperties
-Add allocation flags

Related-To: NEO-4011
Change-Id: I3728d2319aeef983dbcc3f8702da9a303a4e2b9c
Signed-off-by: Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Gibala
2019-12-05 10:32:42 +01:00
committed by sys_ocldev
parent ac0471adc5
commit 5ac1d1258c
59 changed files with 318 additions and 267 deletions

View File

@@ -611,7 +611,7 @@ cl_mem CL_API_CALL clCreateBuffer(cl_context context,
cl_mem buffer = nullptr;
ErrorCodeHelper err(errcodeRet, CL_SUCCESS);
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0);
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0);
if (isFieldValid(flags, MemObjHelper::validFlagsForBuffer)) {
Buffer::validateInputAndCreateBuffer(context, memoryProperties, flags, 0, size, hostPtr, retVal, buffer);
} else {
@@ -643,7 +643,8 @@ cl_mem CL_API_CALL clCreateBufferWithPropertiesINTEL(cl_context context,
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
if (MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::BUFFER)) {
cl_mem_alloc_flags_intel allocflags = 0;
if (MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::BUFFER)) {
Buffer::validateInputAndCreateBuffer(context, memoryProperties, flags, flagsIntel, size, hostPtr, retVal, buffer);
} else {
retVal = CL_INVALID_VALUE;
@@ -786,7 +787,7 @@ cl_mem CL_API_CALL clCreateImage(cl_context context,
retVal = validateObjects(WithCastToInternal(context, &pContext));
if (retVal == CL_SUCCESS) {
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0);
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0);
if (isFieldValid(flags, MemObjHelper::validFlagsForImage)) {
image = Image::validateAndCreateImage(pContext, memoryProperties, flags, 0, imageFormat, imageDesc, hostPtr, retVal);
} else {
@@ -825,10 +826,11 @@ cl_mem CL_API_CALL clCreateImageWithPropertiesINTEL(cl_context context,
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
retVal = validateObjects(WithCastToInternal(context, &pContext));
if (retVal == CL_SUCCESS) {
if (MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE)) {
if (MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE)) {
image = Image::validateAndCreateImage(pContext, memoryProperties, flags, flagsIntel, imageFormat, imageDesc, hostPtr, retVal);
} else {
retVal = CL_INVALID_VALUE;
@@ -875,7 +877,7 @@ cl_mem CL_API_CALL clCreateImage2D(cl_context context,
retVal = validateObjects(WithCastToInternal(context, &pContext));
if (retVal == CL_SUCCESS) {
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0);
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0);
image2D = Image::validateAndCreateImage(pContext, memoryProperties, flags, 0, imageFormat, &imageDesc, hostPtr, retVal);
}
@@ -926,7 +928,7 @@ cl_mem CL_API_CALL clCreateImage3D(cl_context context,
retVal = validateObjects(WithCastToInternal(context, &pContext));
if (retVal == CL_SUCCESS) {
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0);
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0);
image3D = Image::validateAndCreateImage(pContext, memoryProperties, flags, 0, imageFormat, &imageDesc, hostPtr, retVal);
}
@@ -1088,7 +1090,7 @@ cl_int CL_API_CALL clGetImageParamsINTEL(cl_context context,
}
if (CL_SUCCESS == retVal) {
surfaceFormat = (SurfaceFormatInfo *)Image::getSurfaceFormatFromTable(memFlags, imageFormat);
retVal = Image::validate(pContext, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memFlags, 0), surfaceFormat, imageDesc, nullptr);
retVal = Image::validate(pContext, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(memFlags, 0, 0), surfaceFormat, imageDesc, nullptr);
}
if (CL_SUCCESS == retVal) {
retVal = Image::getImageParams(pContext, memFlags, surfaceFormat, imageDesc, imageRowPitch, imageSlicePitch);
@@ -3445,7 +3447,10 @@ void *clHostMemAllocINTEL(
}
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY);
if (!MemObjHelper::parseUnifiedMemoryProperties(properties, unifiedMemoryProperties)) {
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN)) {
err.set(CL_INVALID_VALUE);
return nullptr;
}
@@ -3478,7 +3483,10 @@ void *clDeviceMemAllocINTEL(
}
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY);
if (!MemObjHelper::parseUnifiedMemoryProperties(properties, unifiedMemoryProperties)) {
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN)) {
err.set(CL_INVALID_VALUE);
return nullptr;
}
@@ -3512,7 +3520,10 @@ void *clSharedMemAllocINTEL(
}
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::SHARED_UNIFIED_MEMORY);
if (!MemObjHelper::parseUnifiedMemoryProperties(properties, unifiedMemoryProperties)) {
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN)) {
err.set(CL_INVALID_VALUE);
return nullptr;
}
@@ -3595,7 +3606,7 @@ cl_int clGetMemAllocInfoINTEL(
return retVal;
}
case CL_MEM_ALLOC_FLAGS_INTEL: {
retVal = info.set<uint64_t>(unifiedMemoryAllocation->allocationFlagsProperty);
retVal = info.set<uint32_t>(unifiedMemoryAllocation->allocationFlagsProperty.allAllocFlags);
return retVal;
}
case CL_MEM_ALLOC_DEVICE_INTEL: {