mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Change error return type in clGetMemAllocInfoINTEL
Fix regression. According to specification, NULL need to be returned for specific type of allocation param. Change-Id: I3db25b471075932821c8ffa06ed522d600562720 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
2b269caca9
commit
ded006295f
@ -3618,12 +3618,9 @@ cl_int clGetMemAllocInfoINTEL(
|
||||
return CL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
auto unifiedMemoryAllocation = allocationsManager->getSVMAlloc(ptr);
|
||||
if (!unifiedMemoryAllocation && paramName != CL_MEM_ALLOC_TYPE_INTEL) {
|
||||
return CL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
GetInfoHelper info(paramValue, paramValueSize, paramValueSizeRet);
|
||||
auto unifiedMemoryAllocation = allocationsManager->getSVMAlloc(ptr);
|
||||
|
||||
switch (paramName) {
|
||||
case CL_MEM_ALLOC_TYPE_INTEL: {
|
||||
if (!unifiedMemoryAllocation) {
|
||||
@ -3642,20 +3639,28 @@ cl_int clGetMemAllocInfoINTEL(
|
||||
break;
|
||||
}
|
||||
case CL_MEM_ALLOC_BASE_PTR_INTEL: {
|
||||
retVal = changeGetInfoStatusToCLResultType(info.set<uint64_t>(unifiedMemoryAllocation->gpuAllocation->getGpuAddress()));
|
||||
return retVal;
|
||||
if (!unifiedMemoryAllocation) {
|
||||
return changeGetInfoStatusToCLResultType(info.set<void *>(nullptr));
|
||||
}
|
||||
return changeGetInfoStatusToCLResultType(info.set<uint64_t>(unifiedMemoryAllocation->gpuAllocation->getGpuAddress()));
|
||||
}
|
||||
case CL_MEM_ALLOC_SIZE_INTEL: {
|
||||
retVal = changeGetInfoStatusToCLResultType(info.set<size_t>(unifiedMemoryAllocation->size));
|
||||
return retVal;
|
||||
if (!unifiedMemoryAllocation) {
|
||||
return changeGetInfoStatusToCLResultType(info.set<size_t>(0u));
|
||||
}
|
||||
return changeGetInfoStatusToCLResultType(info.set<size_t>(unifiedMemoryAllocation->size));
|
||||
}
|
||||
case CL_MEM_ALLOC_FLAGS_INTEL: {
|
||||
retVal = changeGetInfoStatusToCLResultType(info.set<cl_mem_alloc_flags_intel>(unifiedMemoryAllocation->allocationFlagsProperty.allAllocFlags));
|
||||
return retVal;
|
||||
if (!unifiedMemoryAllocation) {
|
||||
return changeGetInfoStatusToCLResultType(info.set<cl_mem_alloc_flags_intel>(0u));
|
||||
}
|
||||
return changeGetInfoStatusToCLResultType(info.set<cl_mem_alloc_flags_intel>(unifiedMemoryAllocation->allocationFlagsProperty.allAllocFlags));
|
||||
}
|
||||
case CL_MEM_ALLOC_DEVICE_INTEL: {
|
||||
retVal = changeGetInfoStatusToCLResultType(info.set<cl_device_id>(static_cast<cl_device_id>(unifiedMemoryAllocation->device)));
|
||||
return retVal;
|
||||
if (!unifiedMemoryAllocation) {
|
||||
return changeGetInfoStatusToCLResultType(info.set<cl_device_id>(static_cast<cl_device_id>(nullptr)));
|
||||
}
|
||||
return changeGetInfoStatusToCLResultType(info.set<cl_device_id>(static_cast<cl_device_id>(unifiedMemoryAllocation->device)));
|
||||
}
|
||||
|
||||
default: {
|
||||
|
@ -177,6 +177,48 @@ TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocInfoINTELisCalledWithoutAlloca
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocInfoINTELisCalledWithoutAllocationAndWithPropertiesThenProperValueIsReturned) {
|
||||
MockContext mockContext;
|
||||
cl_int retVal = CL_INVALID_VALUE;
|
||||
size_t paramValueSize = sizeof(void *);
|
||||
size_t paramValueSizeRet = 0;
|
||||
|
||||
{
|
||||
void *paramValue = reinterpret_cast<void *>(0xfeedbac);
|
||||
retVal = clGetMemAllocInfoINTEL(&mockContext, mockContext.getDevice(0), CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(sizeof(void *), paramValueSizeRet);
|
||||
EXPECT_EQ(static_cast<void *>(nullptr), paramValue);
|
||||
}
|
||||
{
|
||||
size_t paramValue = 1;
|
||||
retVal = CL_INVALID_VALUE;
|
||||
paramValueSize = sizeof(size_t);
|
||||
retVal = clGetMemAllocInfoINTEL(&mockContext, mockContext.getDevice(0), CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(sizeof(size_t), paramValueSizeRet);
|
||||
EXPECT_EQ(static_cast<size_t>(0u), paramValue);
|
||||
}
|
||||
{
|
||||
cl_device_id paramValue = mockContext.getDevice(0);
|
||||
retVal = CL_INVALID_VALUE;
|
||||
paramValueSize = sizeof(cl_device_id);
|
||||
retVal = clGetMemAllocInfoINTEL(&mockContext, mockContext.getDevice(0), CL_MEM_ALLOC_DEVICE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(sizeof(cl_device_id), paramValueSizeRet);
|
||||
EXPECT_EQ(static_cast<cl_device_id>(nullptr), paramValue);
|
||||
}
|
||||
{
|
||||
cl_mem_alloc_flags_intel paramValue = 1;
|
||||
retVal = CL_INVALID_VALUE;
|
||||
paramValueSize = sizeof(cl_mem_properties_intel);
|
||||
retVal = clGetMemAllocInfoINTEL(&mockContext, mockContext.getDevice(0), CL_MEM_ALLOC_FLAGS_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(sizeof(cl_mem_properties_intel), paramValueSizeRet);
|
||||
EXPECT_EQ(static_cast<cl_mem_alloc_flags_intel>(0u), paramValue);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocInfoINTELisCalledWithoutSVMAllocationThenInvalidValueIsReturned) {
|
||||
MockContext mockContext;
|
||||
delete mockContext.svmAllocsManager;
|
||||
|
Reference in New Issue
Block a user