mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Handle OS-managed allocations in clGetMemAllocInfoINTEL
Change-Id: I9750bcc05f01aef3973cfac4f10e7d4d9d667bed Related-To: NEO-3524
This commit is contained in:

committed by
sys_ocldev

parent
d9e02697bf
commit
eea2a4451a
@ -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_int>(CL_MEM_TYPE_UNKNOWN_INTEL);
|
||||
return retVal;
|
||||
} else if (unifiedMemoryAllocation->memoryType == InternalMemoryType::HOST_UNIFIED_MEMORY) {
|
||||
retVal = info.set<cl_int>(CL_MEM_TYPE_HOST_INTEL);
|
||||
return retVal;
|
||||
} else if (unifiedMemoryAllocation->memoryType == InternalMemoryType::DEVICE_UNIFIED_MEMORY) {
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user