@@ -10911,112 +10911,90 @@ include::{generated}/api/protos/clSetKernelArg.txt[]
1091110911include::{generated}/api/version-notes/clSetKernelArg.asciidoc[]
1091210912
1091310913 * _kernel_ is a valid kernel object.
10914- * _arg_index_ is the argument index.
10915- Arguments to the kernel are referred by indices that go from 0 for the
10916- leftmost argument to _n_ - 1, where _n_ is the total number of arguments
10917- declared by a kernel (see below).
10918- * _arg_size_ specifies the size of the argument value.
10919- If the argument is a memory object, the _arg_size_ value must be equal to
10920- `sizeof({cl_mem_TYPE})`.
10921- For arguments declared with the `local` qualifier, the size specified will
10922- be the size in bytes of the buffer that must be allocated for the `local`
10923- argument.
10924- If the argument is of type _sampler_t_, the _arg_size_ value must be equal
10925- to `sizeof({cl_sampler_TYPE})`.
10926- If the argument is of type _queue_t_, the _arg_size_ value must be equal to
10927- `sizeof({cl_command_queue_TYPE})`.
10928- For all other arguments, the size will be the size of argument type.
10929- * _arg_value_ is a pointer to data that should be used as the argument value
10930- for argument specified by _arg_index_.
10914+ * _arg_index_ is the kernel argument index.
10915+ Kernel arguments are referred to by indices that go from zero to
10916+ _n - 1_, where _n_ is the total number of arguments declared by the kernel.
10917+ * _arg_size_ specifies the size of the kernel argument value.
10918+ * _arg_value_ is a pointer to the data for the kernel argument.
1093110919 The argument data pointed to by _arg_value_ is copied and the _arg_value_
1093210920 pointer can therefore be reused by the application after {clSetKernelArg}
1093310921 returns.
10934- The argument value specified is the value used by all API calls that enqueue
10935- _kernel_ ({clEnqueueNDRangeKernel} and {clEnqueueTask}) until the argument
10936- value is changed by a call to {clSetKernelArg} for _kernel_.
10922+ The argument data is used by all API calls that enqueue the kernel until the
10923+ argument is changed by another call to {clSetKernelArg} for the kernel.
10924+
10925+ If the kernel argument being set is a pointer to the `global` or `constant`
10926+ address space, then _arg_value_ must point to a buffer memory object or `NULL`,
10927+ or _arg_value_ must be `NULL`.
10928+ If _arg_value_ is `NULL` or points to `NULL`, then the kernel argument will be
10929+ set to `NULL`.
10930+
10931+ If the kernel argument being set is a pointer to the `constant` address space,
10932+ then the size in bytes of the memory object cannot exceed
10933+ {CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE}.
10934+
10935+ // TODO: Should CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE be checked when the kernel
10936+ // argument is set or when the kernel is enqueued?
10937+ // If it is checked when the kernel argument is set, then what is the error code
10938+ // if the size is exceeded?
10939+
10940+ If the kernel argument being set is a pointer to the `local` address space, then
10941+ _arg_value_ must be `NULL`, and _arg_size_ specifies the amount of local memory
10942+ in bytes that are allocated for the kernel argument.
10943+
10944+ If the kernel argument being set is an image object, then _arg_value_ must point
10945+ to an image memory object.
10946+ Additionally:
10947+
10948+ * If the kernel argument is a 1D image, then the image memory object must be of
10949+ image type {CL_MEM_OBJECT_IMAGE1D}.
10950+ * If the kernel argument is a 2D image, then the image memory object must be of
10951+ image type {CL_MEM_OBJECT_IMAGE2D}.
10952+ * If the kernel argument is a 3D image, then the image memory object must be of
10953+ image type {CL_MEM_OBJECT_IMAGE3D}.
10954+ * If the kernel argument is a 1D image buffer, then the image memory object must
10955+ be of image type {CL_MEM_OBJECT_IMAGE1D_BUFFER}.
10956+ * If the kernel argument is a 1D image array, then the image memory object must
10957+ be of image type {CL_MEM_OBJECT_IMAGE1D_ARRAY}.
10958+ * If the kernel argument is a 2D image array, then the image memory object must
10959+ be of image type {CL_MEM_OBJECT_IMAGE2D_ARRAY}.
10960+ * If the kernel argument is a 2D depth image, then the image memory object must
10961+ be of image type {CL_MEM_OBJECT_IMAGE2D} and image channel order {CL_DEPTH}.
10962+ * If the kernel argument is a 2D depth image array, then the image memory object
10963+ must be of image type {CL_MEM_OBJECT_IMAGE2D_ARRAY} and image channel order
10964+ {CL_DEPTH}.
10965+ ifdef::cl_khr_gl_msaa_sharing[]
10966+ * If the kernel argument is a 2D MSAA image, then the image memory object must
10967+ be of image type {CL_MEM_OBJECT_IMAGE2D}.
10968+ * If the kernel argument is a 2D MSAA image array, then the image memory object
10969+ must be of image type {CL_MEM_OBJECT_IMAGE2D_ARRAY}.
10970+ * If the kernel argument is a 2D MSAA depth image, then the image memory object
10971+ must be of image type {CL_MEM_OBJECT_IMAGE2D} and image channel order
10972+ {CL_DEPTH}.
10973+ * If the kernel argument is a 2D MSAA depth image array, then the image memory
10974+ object must be of image type {CL_MEM_OBJECT_IMAGE2D_ARRAY} and image channel
10975+ order {CL_DEPTH}.
10976+ endif::cl_khr_gl_msaa_sharing[]
1093710977
10938- For example, consider the following kernel:
10978+ Behavior is undefined if the same image memory object is passed as both a
10979+ `read_only` image and a `write_only` image, or as a `read_write` image and
10980+ either a `read_only` image or a `write_only` image.
1093910981
10940- [source,opencl_c]
10941- ----
10942- kernel void image_filter (int n,
10943- int m,
10944- constant float *filter_weights,
10945- read_only image2d_t src_image,
10946- write_only image2d_t dst_image)
10947- {
10948- ...
10949- }
10950- ----
10982+ If the kernel argument being set is a sampler, then _arg_value_ must point to a
10983+ sampler object.
1095110984
10952- Argument index values for `image_filter` will be 0 for `n`, 1 for `m`, 2 for
10953- `filter_weights`, 3 for `src_image` and 4 for `dst_image` .
10985+ If the kernel argument being set is a device queue, then _arg_value_ must point
10986+ to a device queue object .
1095410987
10955- If the argument is a memory object (buffer, pipe, image or image array), the
10956- _arg_value_ entry will be a pointer to the appropriate buffer, pipe, image
10957- or image array object.
10958- The memory object must be created with the context associated with the
10959- kernel object.
10960- If the argument is a buffer object, the _arg_value_ pointer can be `NULL` or
10961- point to a `NULL` value in which case a `NULL` value will be used as the
10962- value for the argument declared as a pointer to `global` or `constant`
10963- memory in the kernel.
10964- If the argument is declared with the `local` qualifier, the _arg_value_
10965- entry must be `NULL`.
10966- If the argument is of type _sampler_t_, the _arg_value_ entry must be a
10967- pointer to the sampler object.
10968- If the argument is of type _queue_t_, the _arg_value_ entry must be a
10969- pointer to the device queue object.
10988+ If the kernel argument being set is a pipe, then _arg_value_ must point to a
10989+ pipe memory object.
1097010990
10971- ifdef::cl_khr_gl_msaa_sharing[]
10972- If the {cl_khr_gl_msaa_sharing_EXT} extension is supported, then:
10973- If the argument is a multi-sample 2D image, the _arg_value_ entry must be a
10974- pointer to a multi-sample image object.
10975- If the argument is a multi-sample 2D depth image, the _arg_value_ entry must
10976- be a pointer to a multisample depth image object.
10977- If the argument is a multi-sample 2D image array, the _arg_value_ entry must
10978- be a pointer to a multi-sample image array object.
10979- If the argument is a multi-sample 2D depth image array, the _arg_value_
10980- entry must be a pointer to a multi-sample depth image array object.
10981- endif::cl_khr_gl_msaa_sharing[]
10991+ For all other kernel arguments, _arg_value_ points to the data that is used as
10992+ the kernel argument value.
1098210993
10983- If the argument is declared to be a pointer of a built-in scalar or vector
10984- type, or a user defined structure type in the global or constant address
10985- space, the memory object specified as argument value must be a buffer object
10986- (or `NULL`).
10987- If the argument is declared with the `constant` qualifier, the size in bytes
10988- of the memory object cannot exceed {CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE} and
10989- the number of arguments declared as pointers to `constant` memory cannot
10990- exceed {CL_DEVICE_MAX_CONSTANT_ARGS}.
10991-
10992- The memory object specified as argument value must be a pipe object if the
10993- argument is declared with the _pipe_ qualifier.
10994-
10995- The memory object specified as argument value must be a 2D image object if
10996- the argument is declared to be of type _image2d_t_.
10997- The memory object specified as argument value must be a 2D image object with
10998- image channel order = {CL_DEPTH} if the argument is declared to be of type
10999- _image2d_depth_t_.
11000- The memory object specified as argument value must be a 3D image object if
11001- argument is declared to be of type _image3d_t_.
11002- The memory object specified as argument value must be a 1D image object if
11003- the argument is declared to be of type _image1d_t_.
11004- The memory object specified as argument value must be a 1D image buffer
11005- object if the argument is declared to be of type _image1d_buffer_t_.
11006- The memory object specified as argument value must be a 1D image array
11007- object if argument is declared to be of type _image1d_array_t_.
11008- The memory object specified as argument value must be a 2D image array
11009- object if argument is declared to be of type _image2d_array_t_.
11010- The memory object specified as argument value must be a 2D image array
11011- object with image channel order = {CL_DEPTH} if argument is declared to be of
11012- type _image2d_array_depth_t_.
11013-
11014- Behavior is undefined if the same memory object is passed as both a `read_only`
11015- image and a `write_only` image, or as a `read_write` image and either a
11016- `read_only` image or a `write_only` image.
11017-
11018- For all other kernel arguments, the _arg_value_ entry must be a pointer to
11019- the actual data to be used as argument value.
10994+ All objects set as kernel arguments must be created from the same context as the
10995+ kernel object.
10996+
10997+ // TODO: Should this be CL_INVALID_CONTEXT, or should the object be considered invalid?
1102010998
1102110999[NOTE]
1102211000====
@@ -11036,55 +11014,61 @@ the {cl_mem_TYPE} backing store used with {CL_MEM_USE_HOST_PTR}.
1103611014
1103711015// refError
1103811016
11039- {clSetKernelArg} returns {CL_SUCCESS} if the function was executed
11040- successfully.
11017+ {clSetKernelArg} returns {CL_SUCCESS} if the function is executed successfully.
1104111018Otherwise, it returns one of the following errors:
1104211019
11043- * {CL_INVALID_KERNEL} if _kernel_ is not a valid kernel object.
11044- * {CL_INVALID_ARG_INDEX} if _arg_index_ is not a valid argument index.
11045- * {CL_INVALID_ARG_VALUE} if _arg_value_ specified is not a valid value.
11046- * {CL_INVALID_MEM_OBJECT} for an argument declared to be a memory object
11047- when the specified _arg_value_ is not a valid memory object.
11048- ifdef::cl_khr_depth_images,cl_khr_gl_msaa_sharing[]
11049- * {CL_INVALID_MEM_OBJECT} for an argument declared to be a
11050- ifdef::cl_khr_depth_images[]
11051- depth image, depth image array,
11052- endif::cl_khr_depth_images[]
11053- ifdef::cl_khr_gl_msaa_sharing[]
11054- multi-sample image, multi-sample image array, multi-sample depth image,
11055- or a multi-sample depth image array
11056- endif::cl_khr_gl_msaa_sharing[]
11057- when the specified _arg_value_ does not follow the rules described above
11058- for a depth memory object or memory array object argument.
11059- endif::cl_khr_depth_images,cl_khr_gl_msaa_sharing[]
11060- * {CL_INVALID_SAMPLER} for an argument declared to be of type _sampler_t_
11061- when the specified _arg_value_ is not a valid sampler object.
11062- * {CL_INVALID_DEVICE_QUEUE} for an argument declared to be of type _queue_t_
11063- when the specified _arg_value_ is not a valid device queue object.
11020+ * {CL_INVALID_KERNEL}
11021+ ** if _kernel_ is not a valid kernel
11022+ * {CL_INVALID_ARG_INDEX}
11023+ ** if _arg_index_ is not a valid argument index
11024+ * {CL_INVALID_MEM_OBJECT}
11025+ ** if _arg_value_ is `NULL` and it must point to a valid memory object
11026+ ** if _arg_value_ points to `NULL` and it must point to a valid memory object
11027+ ** if _arg_value_ is not `NULL`, and does not point to `NULL`, and does not
11028+ point to a valid memory object
11029+ ** if _arg_value_ points to a valid memory object, but the memory object is
11030+ not valid for the kernel argument specified by _arg_index_
11031+ * {CL_INVALID_SAMPLER}
11032+ ** if the kernel argument is a sampler, but _arg_value_ does not point to a
11033+ valid sampler object
11034+ * {CL_INVALID_DEVICE_QUEUE}
11035+ ** if the kernel argument is a device queue, but _arg_value_ does not point
11036+ to a valid device queue object.
1106411037 This error code is <<unified-spec, missing before>> version 2.0.
1106511038 * {CL_INVALID_ARG_SIZE}
11066- ** if _arg_size_ does not match the size of the data type for an argument
11067- that is not a memory object, or
11068- ** if the argument is a memory object and _arg_size_ != `sizeof({cl_mem_TYPE})`, or
11069- ** if _arg_size_ is zero and the argument is declared with the `local` qualifier, or
11070- ** if the argument is a sampler and _arg_size_ != `sizeof({cl_sampler_TYPE})`.
11071- * {CL_MAX_SIZE_RESTRICTION_EXCEEDED} if the size in bytes of the memory
11072- object (if the argument is a memory object) or _arg_size_ (if the
11073- argument is declared with `local` qualifier) exceeds a language-
11074- specified maximum size restriction for this argument, such as the
11075- *MaxByteOffset* SPIR-V decoration.
11076- This error code is <<unified-spec, missing before>> version 2.2.
11039+ ** if _arg_value_ points to a memory object and _arg_size_ is not equal to
11040+ `sizeof({cl_mem_TYPE})`, or
11041+ ** if _arg_value_ points to a sampler object and _arg_size_ is not equal to
11042+ `sizeof({cl_sampler_TYPE})`, or
11043+ ** if _arg_value_ points to a device queue object and _arg_size_ is not
11044+ equal to `sizeof({cl_command_queue_TYPE})`, or
11045+ ** if the kernel argument is a pointer to the the `local` address space and
11046+ _arg_size_ is zero, or
11047+ ** if _arg_value_ points to the data to be used as the kernel argument value
11048+ and _arg_size_ does not match the size of the data type for the argument
1107711049 * {CL_INVALID_ARG_VALUE}
11078- ** if the argument is an image declared with the `read_only` qualifier and
11079- _arg_value_ refers to an image object created with _cl_mem_flags_ of
11080- {CL_MEM_WRITE_ONLY}, or
11081- ** if the image argument is declared with the `write_only` qualifier and
11082- _arg_value_ refers to an image object created with _cl_mem_flags_ of
11083- {CL_MEM_READ_ONLY}.
11084- * {CL_OUT_OF_RESOURCES} if there is a failure to allocate resources required
11085- by the OpenCL implementation on the device.
11086- * {CL_OUT_OF_HOST_MEMORY} if there is a failure to allocate resources
11087- required by the OpenCL implementation on the host.
11050+ ** if _arg_value_ is not a valid value.
11051+ ** if the argument is an image declared with the `read_only` qualifier and
11052+ _arg_value_ points to an image object created with the memory flag
11053+ {CL_MEM_WRITE_ONLY}, or
11054+ ** if the argument is an image declared with the `write_only` qualifier and
11055+ _arg_value_ points to an image object created with the memory flag
11056+ {CL_MEM_READ_ONLY}
11057+ ifdef::cl_ext_immutable_memory_objects[]
11058+ or {CL_MEM_IMMUTABLE_EXT}
11059+ endif::cl_ext_immutable_memory_objects[]
11060+ * {CL_MAX_SIZE_RESTRICTION_EXCEEDED}
11061+ ** if the size in bytes of the memory object (if the argument is a memory
11062+ object) or _arg_size_ (if the argument is declared with `local` qualifier)
11063+ exceeds a language-specified maximum size restriction for this argument,
11064+ such as the *MaxByteOffset* SPIR-V decoration.
11065+ This error code is <<unified-spec, missing before>> version 2.2.
11066+ * {CL_OUT_OF_RESOURCES}
11067+ ** if there is a failure to allocate resources required by the OpenCL
11068+ implementation on the device
11069+ * {CL_OUT_OF_HOST_MEMORY}
11070+ ** if there is a failure to allocate resources required by the OpenCL
11071+ implementation on the host
1108811072
1108911073When {clSetKernelArg} returns an error code different from {CL_SUCCESS}, the
1109011074internal state of _kernel_ may only be modified when that error code is
@@ -11125,7 +11109,7 @@ include::{generated}/api/version-notes/clSetKernelArgSVMPointer.asciidoc[]
1112511109
1112611110// refError
1112711111
11128- {clSetKernelArgSVMPointer} returns {CL_SUCCESS} if the function was executed
11112+ {clSetKernelArgSVMPointer} returns {CL_SUCCESS} if the function is executed
1112911113successfully.
1113011114Otherwise, it returns one of the following errors:
1113111115
@@ -12504,7 +12488,7 @@ clReleaseMemObject(buf2);
1250412488
1250512489// refError
1250612490
12507- {clSetUserEventStatus} returns {CL_SUCCESS} if the function was executed
12491+ {clSetUserEventStatus} returns {CL_SUCCESS} if the function is executed
1250812492successfully.
1250912493Otherwise, it returns one of the following errors:
1251012494
0 commit comments