diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 066bcbc3be..539cc5fdf6 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -3481,14 +3481,17 @@ cl_int clGetMemAllocInfoINTEL( } auto unifiedMemoryAllocation = allocationsManager->getSVMAlloc(ptr); - if (!unifiedMemoryAllocation) { + if (!unifiedMemoryAllocation && paramName != CL_MEM_ALLOC_TYPE_INTEL) { return CL_INVALID_VALUE; } GetInfoHelper info(paramValue, paramValueSize, paramValueSizeRet); switch (paramName) { case CL_MEM_ALLOC_TYPE_INTEL: { - if (unifiedMemoryAllocation->memoryType == InternalMemoryType::HOST_UNIFIED_MEMORY) { + if (!unifiedMemoryAllocation) { + retVal = info.set(CL_MEM_TYPE_UNKNOWN_INTEL); + return retVal; + } else if (unifiedMemoryAllocation->memoryType == InternalMemoryType::HOST_UNIFIED_MEMORY) { retVal = info.set(CL_MEM_TYPE_HOST_INTEL); return retVal; } else if (unifiedMemoryAllocation->memoryType == InternalMemoryType::DEVICE_UNIFIED_MEMORY) { diff --git a/unit_tests/api/cl_unified_shared_memory_tests.inl b/unit_tests/api/cl_unified_shared_memory_tests.inl index 6155598ce8..9bd6b384c9 100644 --- a/unit_tests/api/cl_unified_shared_memory_tests.inl +++ b/unit_tests/api/cl_unified_shared_memory_tests.inl @@ -149,6 +149,20 @@ TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocInfoINTELisCalledWithoutSVMAll EXPECT_EQ(CL_INVALID_VALUE, retVal); } +TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocInfoINTELisCalledWithAllocationTypeParamNameAndWithoutUnifiedSharedMemoryAllocationThenProperFieldsAreSet) { + MockContext mockContext; + cl_int retVal = CL_SUCCESS; + size_t paramValueSize = sizeof(cl_int); + cl_int paramValue = 0; + size_t paramValueSizeRet = 0; + + retVal = clGetMemAllocInfoINTEL(&mockContext, nullptr, CL_MEM_ALLOC_TYPE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet); + + EXPECT_EQ(CL_MEM_TYPE_UNKNOWN_INTEL, paramValue); + EXPECT_EQ(sizeof(cl_int), paramValueSizeRet); + EXPECT_EQ(CL_SUCCESS, retVal); +} + TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocInfoINTELisCalledWithValidUnifiedMemoryHostAllocationThenProperFieldsAreSet) { MockContext mockContext; cl_int retVal = CL_SUCCESS;