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.
Any suggestions?
Solved! Go to Solution.
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
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
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.
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
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);