To enqueue a command to execute a kernel on a device, using a single work-item, call the function
cl_int clEnqueueTask( cl_command_queue command_queue, cl_kernel kernel, cl_uint num_events_in_wait_list, const cl_event* event_wait_list, cl_event* event);
command_queue is a valid host command-queue. The kernel will be queued for execution on the device associated with command_queue.
kernel is a valid kernel object. The OpenCL context associated with kernel and command-queue must be the same.
event_wait_list and num_events_in_wait_list specify events that need to complete before this particular command can be executed. If event_wait_list is
NULL, then this particular command does not wait on any event to complete. If event_wait_list is
NULL, num_events_in_wait_list must be 0. If event_wait_list is not
NULL, the list of events pointed to by event_wait_list must be valid and num_events_in_wait_list must be greater than 0. The events specified in event_wait_list act as synchronization points. The context associated with events in event_wait_list and command_queue must be the same. The memory associated with event_wait_list can be reused or freed after the function returns.
event returns an event object that identifies this particular kernel-instance. Event objects are unique and can be used to identify a particular kernel-instance later on. If event is
NULL, no event will be created for this kernel-instance and therefore it will not be possible for the application to query or queue a wait for this particular kernel-instance. If the event_wait_list and the event arguments are not
NULL, the event argument should not refer to an element of the event_wait_list array.
clEnqueueTask is equivalent to calling clEnqueueNDRangeKernel with
work_dim set to 1, global_work_offset set to
set to 1, and local_work_size set to 1.
CL_SUCCESS if the kernel-instance was successfully
Otherwise, it returns one of the following errors:
CL_INVALID_PROGRAM_EXECUTABLEif there is no successfully built program executable available for device associated with command_queue.
CL_INVALID_COMMAND_QUEUEif command_queue is not a valid host command-queue.
CL_INVALID_KERNELif kernel is not a valid kernel object.
CL_INVALID_CONTEXTif context associated with command_queue and kernel are not the same or if the context associated with command_queue and events in event_wait_list are not the same.
CL_INVALID_KERNEL_ARGSif the kernel argument values have not been specified or if a kernel argument declared to be a pointer to a type does not point to a named address space.
CL_INVALID_WORK_GROUP_SIZEif a work-group size is specified for kernel in the program source and it is not (1, 1, 1).
CL_INVALID_WORK_GROUP_SIZEif the required number of sub-groups is specified for kernel in the program source and is not consistent with a work-group size of (1, 1, 1).
CL_MISALIGNED_SUB_BUFFER_OFFSETif a sub-buffer object is specified as the value for an argument that is a buffer object and the offset specified when the sub-buffer object is created is not aligned to
CL_DEVICE_MEM_BASE_ADDR_ALIGNvalue for device associated with queue. This error code is missing before version 1.1.
CL_INVALID_IMAGE_SIZEif an image object is specified as an argument value and the image dimensions (image width, height, specified or compute row and/or slice pitch) are not supported by device associated with queue.
CL_IMAGE_FORMAT_NOT_SUPPORTEDif an image object is specified as an argument value and the image format (image channel order and data type) is not supported by device associated with queue.
CL_OUT_OF_RESOURCESif there is a failure to queue the execution instance of kernel on the command-queue because of insufficient resources needed to execute the kernel. See how this error code is used with clEnqueueNDRangeKernel for examples.
CL_MEM_OBJECT_ALLOCATION_FAILUREif there is a failure to allocate memory for data store associated with image or buffer objects specified as arguments to kernel.
CL_INVALID_EVENT_WAIT_LISTif event_wait_list is
NULLand num_events_in_wait_list > 0, or event_wait_list is not
NULLand num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
CL_INVALID_OPERATIONif SVM pointers are passed as arguments to a kernel and the device does not support SVM or if system pointers are passed as arguments to a kernel and/or stored inside SVM allocations passed as kernel arguments and the device does not support fine grain system SVM allocations.
CL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device.
CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
For more information, see the OpenCL Specification
This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.
Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.