'\" t .\" Title: clEnqueueNDRangeKernel .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/14/2021 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "CLENQUEUENDRANGEKERN" "3clc" "01/14/2021" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" clEnqueueNDRangeKernel \- Enqueues a command to execute a kernel on a device\&. .SH "" .HP \w'cl_int\ clEnqueueNDRangeKernel('u .BI "cl_int clEnqueueNDRangeKernel(cl_command_queue\ " "command_queue" ", cl_kernel\ " "kernel" ", cl_uint\ " "work_dim" ", const\ size_t\ *" "global_work_offset" ", const\ size_t\ *" "global_work_size" ", const\ size_t\ *" "local_work_size" ", cl_uint\ " "num_events_in_wait_list" ", const\ cl_event\ *" "event_wait_list" ", cl_event\ *" "event" ");" .SH "PARAMETERS" .PP \fI command_queue \fR .RS 4 A valid command\-queue\&. The kernel will be queued for execution on the device associated with \fIcommand_queue\fR\&. .RE .PP \fI kernel \fR .RS 4 A valid kernel object\&. The OpenCL context associated with \fIkernel\fR and \fIcommand_queue\fR must be the same\&. .RE .PP \fI work_dim \fR .RS 4 The number of dimensions used to specify the global work\-items and work\-items in the work\-group\&. \fIwork_dim\fR must be greater than zero and less than or equal to \fBCL_DEVICE_MAX_WORK_ITEM_DIMENSIONS\fR\&. .RE .PP \fI global_work_offset \fR .RS 4 \fIglobal_work_offset\fR can be used to specify an array of \fIwork_dim\fR unsigned values that describe the offset used to calculate the global ID of a work\-item\&. If \fIglobal_work_offset\fR is NULL, the global IDs start at offset (0, 0, \&.\&.\&. 0)\&. .RE .PP \fI global_work_size \fR .RS 4 Points to an array of \fIwork_dim\fR unsigned values that describe the number of global work\-items in \fIwork_dim\fR dimensions that will execute the kernel function\&. The total number of global work\-items is computed as \fIglobal_work_size\fR[0] *\&.\&.\&.* \fIglobal_work_size\fR[\fIwork_dim\fR \- 1]\&. .RE .PP \fI local_work_size \fR .RS 4 Points to an array of \fIwork_dim\fR unsigned values that describe the number of work\-items that make up a work\-group (also referred to as the size of the work\-group) that will execute the kernel specified by \fIkernel\fR\&. The total number of work\-items in a work\-group is computed as \fIlocal_work_size\fR[0] *\&.\&.\&. * \fIlocal_work_size\fR[\fIwork_dim\fR \- 1]\&. The total number of work\-items in the work\-group must be less than or equal to the \fBCL_DEVICE_MAX_WORK_GROUP_SIZE\fR value specified in table of OpenCL Device Queries for \fBclGetDeviceInfo\fR(3clc) and the number of work\-items specified in \fIlocal_work_size\fR[0],\&.\&.\&. \fIlocal_work_size\fR[\fIwork_dim\fR \- 1] must be less than or equal to the corresponding values specified by \fBCL_DEVICE_MAX_WORK_ITEM_SIZES\fR[0],\&.\&.\&.\&. \fBCL_DEVICE_MAX_WORK_ITEM_SIZES\fR[\fIwork_dim\fR \- 1]\&. The explicitly specified \fIlocal_work_size\fR will be used to determine how to break the global work\-items specified by \fIglobal_work_size\fR into appropriate work\-group instances\&. If \fIlocal_work_size\fR is specified, the values specified in \fIglobal_work_size\fR[0],\&.\&.\&. \fIglobal_work_size\fR[\fIwork_dim\fR \- 1] must be evenly divisible by the corresponding values specified in \fIlocal_work_size\fR[0],\&.\&.\&. \fIlocal_work_size\fR[\fIwork_dim\fR \- 1]\&. .sp \fIlocal_work_size\fR can also be a NULL value in which case the OpenCL implementation will determine how to be break the global work\-items into appropriate work\-group instances\&. .RE .PP \fI \fR\fI\fR\fI event_wait_list \fR and \fI \fR\fI\fR\fI num_events_in_wait_list \fR .RS 4 Specify events that need to complete before this particular command can be executed\&. If \fIevent_wait_list\fR is NULL, then this particular command does not wait on any event to complete\&. If \fIevent_wait_list\fR is NULL, \fInum_events_in_wait_list\fR must be 0\&. If \fIevent_wait_list\fR is not NULL, the list of events pointed to by \fIevent_wait_list\fR must be valid and \fInum_events_in_wait_list\fR must be greater than 0\&. The events specified in \fIevent_wait_list\fR act as synchronization points\&. The context associated with events in \fIevent_wait_list\fR and \fIcommand_queue\fR must be the same\&. The memory associated with \fIevent_wait_list\fR can be reused or freed after the function returns\&. .RE .PP \fI event \fR .RS 4 Returns an event object that identifies this particular kernel execution instance\&. Event objects are unique and can be used to identify a particular kernel execution instance later on\&. If \fIevent\fR is NULL, no event will be created for this kernel execution instance and therefore it will not be possible for the application to query or queue a wait for this particular kernel execution instance\&. .RE .SH "NOTES" .PP The work\-group size to be used for \fIkernel\fR can also be specified in the program source using the \fBattribute\fR(3clc) ((reqd_work_group_size(X, Y, Z))) qualifier\&. In this case the size of work group specified by \fIlocal_work_size\fR must match the value specified by the reqd_work_group_size \fBattribute\fR(3clc) qualifier\&. .PP These work\-group instances are executed in parallel across multiple compute units or concurrently on the same compute unit\&. .PP Each work\-item is uniquely identified by a global identifier\&. The global ID, which can be read inside the kernel, is computed using the value given by \fIglobal_work_size\fR and \fIglobal_work_offset\fR\&. In addition, a work\-item is also identified within a work\-group by a unique local ID\&. The local ID, which can also be read by the kernel, is computed using the value given by \fIlocal_work_size\fR\&. The starting local ID is always (0, 0, \&.\&.\&. 0)\&. .SH "ERRORS" .PP Returns CL_SUCCESS if the kernel execution was successfully queued\&. Otherwise, it returns one of the following errors: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_PROGRAM_EXECUTABLE if there is no successfully built program executable available for device associated with \fIcommand_queue\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_COMMAND_QUEUE if \fIcommand_queue\fR is not a valid command\-queue\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_KERNEL if \fIkernel\fR is not a valid kernel object\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_CONTEXT if context associated with \fIcommand_queue\fR and \fIkernel\fR is not the same or if the context associated with \fIcommand_queue\fR and events in \fIevent_wait_list\fR are not the same\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_KERNEL_ARGS if the kernel argument values have not been specified\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_WORK_DIMENSION if \fIwork_dim\fR is not a valid value (i\&.e\&. a value between 1 and 3)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_GLOBAL_WORK_SIZE if \fIglobal_work_size\fR is NULL, or if any of the values specified in \fIglobal_work_size\fR[0], \&.\&.\&.\fIglobal_work_size\fR [\fIwork_dim\fR \- 1] are 0 or exceed the range given by the sizeof(size_t) for the device on which the kernel execution will be enqueued\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_GLOBAL_OFFSET if the value specified in \fIglobal_work_size\fR + the corresponding values in \fIglobal_work_offset\fR for any dimensions is greater than the sizeof(size_t) for the device on which the kernel execution will be enqueued\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_WORK_GROUP_SIZE if \fIlocal_work_size\fR is specified and number of work\-items specified by \fIglobal_work_size\fR is not evenly divisable by size of work\-group given by \fIlocal_work_size\fR or does not match the work\-group size specified for \fIkernel\fR using the \fBfunctionQualifiers\fR(3clc) ((reqd_work_group_size(X, Y, Z))) qualifier in program source\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_WORK_GROUP_SIZE if \fIlocal_work_size\fR is specified and the total number of work\-items in the work\-group computed as \fIlocal_work_size\fR[0] *\&.\&.\&. \fIlocal_work_size\fR[\fIwork_dim\fR \- 1] is greater than the value specified by \fBCL_DEVICE_MAX_WORK_GROUP_SIZE\fR in the table of OpenCL Device Queries for \fBclGetDeviceInfo\fR(3clc)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_WORK_GROUP_SIZE if \fIlocal_work_size\fR is NULL and the \fBfunctionQualifiers\fR(3clc) ((reqd_work_group_size(X, Y, Z))) qualifier is used to declare the work\-group size for \fIkernel\fR in the program source\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_WORK_ITEM_SIZE if the number of work\-items specified in any of \fIlocal_work_size\fR[0], \&.\&.\&. \fIlocal_work_size\fR[\fIwork_dim\fR \- 1] is greater than the corresponding values specified by \fBCL_DEVICE_MAX_WORK_ITEM_SIZES\fR[0], \&.\&.\&.\&. \fBCL_DEVICE_MAX_WORK_ITEM_SIZES\fR[\fIwork_dim\fR \- 1]\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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 \fIoffset\fR specified when the sub\-buffer object is created is not aligned to \fBCL_DEVICE_MEM_BASE_ADDR_ALIGN\fR value for device associated with \fIqueue\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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 \fIqueue\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_IMAGE_FORMAT 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 \fIqueue\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_RESOURCES if there is a failure to queue the execution instance of \fIkernel\fR on the command\-queue because of insufficient resources needed to execute the kernel\&. For example, the explicitly specified \fIlocal_work_size\fR causes a failure to execute the kernel because of insufficient resources such as registers or local memory\&. Another example would be the number of read\-only image args used in \fIkernel\fR exceed the \fBCL_DEVICE_MAX_READ_IMAGE_ARGS\fR value for device or the number of write\-only image args used in \fIkernel\fR exceed the \fBCL_DEVICE_MAX_WRITE_IMAGE_ARGS\fR value for device or the number of samplers used in \fIkernel\fR exceed \fBCL_DEVICE_MAX_SAMPLERS\fR for device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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 \fIkernel\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_EVENT_WAIT_LIST if \fIevent_wait_list\fR is NULL and \fInum_events_in_wait_list\fR > 0, or \fIevent_wait_list\fR is not NULL and \fInum_events_in_wait_list\fR is 0, or if event objects in \fIevent_wait_list\fR are not valid events\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host\&. .RE .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBclCreateCommandQueue\fR(3clc), \fBclGetDeviceInfo\fR(3clc), \fBclEnqueueNativeKernel\fR(3clc), \fBclEnqueueTask\fR(3clc), \fBworkItemFunctions\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 169, section 5.8 - Executing Kernels (updated for 1.2 rev 14) .RE