C Specification

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);

Parameters

  • 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.

Description

clEnqueueTask is equivalent to calling clEnqueueNDRangeKernel with work_dim set to 1, global_work_offset set to NULL, global_work_size[0] set to 1, and local_work_size[0] set to 1.

clEnqueueTask returns CL_​SUCCESS if the kernel-instance was successfully queued. Otherwise, it returns one of the following errors:

  • CL_​INVALID_​PROGRAM_​EXECUTABLE if there is no successfully built program executable available for device associated with command_queue.

  • CL_​INVALID_​COMMAND_​QUEUE if command_queue is not a valid host command-queue.

  • CL_​INVALID_​KERNEL if kernel is not a valid kernel object.

  • CL_​INVALID_​CONTEXT if 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_​ARGS if 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_​SIZE if a work-group size is specified for kernel in the program source and it is not (1, 1, 1).

  • CL_​INVALID_​WORK_​GROUP_​SIZE if 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_​OFFSET if 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_​ALIGN value for device associated with queue. This error code is missing before version 1.1.

  • CL_​INVALID_​IMAGE_​SIZE if 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_​SUPPORTED if 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_​RESOURCES if 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_​FAILURE if 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_​LIST if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.

  • CL_​INVALID_​OPERATION if 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_​RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_​OUT_​OF_​HOST_​MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

See Also

Document Notes

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.