IMX8MP: OpenCL extension 'cl_khr_external_memory_dma_buf' missing?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

IMX8MP: OpenCL extension 'cl_khr_external_memory_dma_buf' missing?

跳至解决方案
339 次查看
pete_sensoray
Contributor II

I need to use the OpenCL extension 'cl_khr_external_memory_dma_buf' for processing a video buffer using zero-copy, but the extension isn't listed in the string returned from CL_DEVICE_EXTENSIONS:

CL_DEVICE_NAME: Vivante OpenCL Device GC7000UL.6204.0000
CL_DEVICE_VENDOR: Vivante Corporation
CL_DRIVER_VERSION: OpenCL 3.0 V6.4.11.p2.745085
CL_DEVICE_PROFILE: FULL_PROFILE
CL_DEVICE_VERSION: OpenCL 3.0
CL_DEVICE_EXTENSIONS: cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_il_program cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_icd cl_khr_command_buffer

 

UG10159 says should be supported with this SW version 6.4.11, which is what appears in the driver version.

pete_sensoray_1-1754528249478.png

Any suggestions?

标记 (3)
0 项奖励
回复
1 解答
263 次查看
joanxie
NXP TechSupport
NXP TechSupport

confirmed that imx8mp can support this, suggest customer to call the driver directly, to check if the return value is correct or not, don't need to check this print information

在原帖中查看解决方案

0 项奖励
回复
4 回复数
329 次查看
joanxie
NXP TechSupport
NXP TechSupport

I checked the cl_ext.h under the /usr/include/CL, this extension already exists, I attached the header file 

/***************************************************************
* cl_khr_external_memory_dma_buf
***************************************************************/
#define cl_khr_external_memory_dma_buf 1

/* cl_external_memory_handle_type_khr */
#define CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR 0x2067

 

 

0 项奖励
回复
319 次查看
pete_sensoray
Contributor II

Sorry, that's not how extension detection works. The presence of the extension in the driver is not indicated by the cl_ext.h header file -- all possible extensions are listed there and detection happens during program execution.  An extension is supported when it is returned in the string from the glGetDeviceInfo function call:

char extensions[1024];
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, sizeof(extensions), extensions, NULL);
printf("CL_DEVICE_EXTENSIONS: %s\n", extensions);
if (strstr(extensions, "cl_khr_external_memory_dma_buf") == NULL) {
// Handle error: DMA-BUF extension not supported
}

Either the documentation is wrong, or the extensions list in the driver is wrong.

0 项奖励
回复
264 次查看
joanxie
NXP TechSupport
NXP TechSupport

confirmed that imx8mp can support this, suggest customer to call the driver directly, to check if the return value is correct or not, don't need to check this print information

0 项奖励
回复
254 次查看
pete_sensoray
Contributor II

Thanks for following up.  It does appear to work.  For anyone else trying to do this, this is how the buffer is created:

cl_mem_properties extMemProperties[] =
{
	CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR, (cl_mem_properties)buf->dma_fd,
	0
};
cl_mem buffer_YUYV = clCreateBufferWithProperties(
	/*context*/          context,
	/*properties*/       extMemProperties,
	/*flags*/            CL_MEM_READ_ONLY,
	/*size*/             buf->size,
	/*host_ptr*/         NULL,
	/*errcode_ret*/      &err);
		

 

0 项奖励
回复