Skip to content

Commit b486a5b

Browse files
authored
[SYCL] Clarify a few work-group attribute docs (#14417)
Declaring upfront that `reqd_work_group_size` has the same semantics between OpenCL and SYCL is misleading because the dimensionality is different. The docs for `work_group_size_hint` were better in clarifying the difference, so those have been copied and adapted. Describe OpenCL upfront as it's simpler, and won't be buried by the wordier SYCL documentation. Try and re-enforce the SYCL dimensionality rules to aid people more familiar with OpenCL and other similar languages. Clarify that the `max_work_group_size` attribute (at least currently) behaves like `reqd_work_group_size` but we require *all* dimensions to be supplied.
1 parent b249afc commit b486a5b

File tree

1 file changed

+42
-35
lines changed

1 file changed

+42
-35
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,18 +2980,32 @@ argument to **clEnqueueNDRangeKernel** (in OpenCL) or to
29802980
**parallel_for** in SYCL. This allows the compiler to optimize the
29812981
generated code appropriately for the kernel to which attribute is applied.
29822982

2983-
While semantic of this attribute is the same between OpenCL and SYCL,
2984-
spelling is a bit different:
2985-
2986-
SYCL 2020 describes the ``[[sycl::reqd_work_group_size(X, Y, Z)]]`` spelling
2987-
in detail. This attribute indicates that the kernel must be launched with the
2988-
specified work-group size. The order of the arguments matches the constructor
2989-
of the group class. Each argument to the attribute must be an integral constant
2990-
expression. The dimensionality of the attribute variant used must match the
2991-
dimensionality of the work-group used to invoke the kernel. This spelling
2992-
allows the Y and Z arguments to be optional. If not provided by the user, the
2993-
value of Y and Z defaults to 1. See section 5.8.1 Kernel Attributes for more
2994-
details.
2983+
The arguments to ``reqd_work_group_size`` are ordered based on which index
2984+
increments the fastest. In OpenCL, the first argument is the index that
2985+
increments the fastest. In SYCL, the last argument is the index that increments
2986+
the fastest.
2987+
2988+
In OpenCL C, this attribute is available with the GNU spelling
2989+
(``__attribute__((reqd_work_group_size(X, Y, Z)))``) and all three arguments
2990+
are required. See section 6.7.2 Optional Attribute Qualifiers of OpenCL 1.2
2991+
specification for details.
2992+
2993+
.. code-block:: c++
2994+
2995+
__kernel __attribute__((reqd_work_group_size(8, 16, 32))) void test() {}
2996+
2997+
In SYCL, the attribute accepts either one, two, or three arguments; in each
2998+
form, the last (or only) argument is the index that increments fastest. The
2999+
number of arguments passed to the attribute must match the dimensionality of
3000+
the kernel the attribute is applied to.
3001+
3002+
SYCL 2020 describes the ``[[sycl::reqd_work_group_size(dim0, dim1, dim2)]]``
3003+
spelling in detail. This attribute indicates that the kernel must be launched
3004+
with the specified work-group size. The order of the arguments matches the
3005+
constructor of the ``range`` class. Each argument to the attribute must be an
3006+
integral constant expression. The dimensionality of the attribute variant used
3007+
must match the dimensionality of the work-group used to invoke the kernel. See
3008+
section 5.8.1 Kernel Attributes for more details.
29953009

29963010
In SYCL 1.2.1 mode, the ``cl::reqd_work_group_size`` and
29973011
``sycl::reqd_work_group_size`` attributes are propagated from the function they
@@ -3016,18 +3030,9 @@ attributes are not propagated to the kernel.
30163030
template <int N, int N1, int N2>
30173031
[[sycl::reqd_work_group_size(N, N1, N2)]] void func() {}
30183032

3019-
The ``[[cl::reqd_work_group_size(X, Y, Z)]]`` and
3020-
``__attribute__((reqd_work_group_size(X, Y, Z)))`` spellings are both
3033+
The ``[[cl::reqd_work_group_size(dim0, dim1, dim2)]]`` and
3034+
``__attribute__((reqd_work_group_size(dim0, dim1, dim2)))`` spellings are both
30213035
deprecated in SYCL 2020.
3022-
3023-
In OpenCL C, this attribute is available with the GNU spelling
3024-
(``__attribute__((reqd_work_group_size(X, Y, Z)))``), see section
3025-
6.7.2 Optional Attribute Qualifiers of OpenCL 1.2 specification for details.
3026-
3027-
.. code-block:: c++
3028-
3029-
__kernel __attribute__((reqd_work_group_size(8, 16, 32))) void test() {}
3030-
30313036
}];
30323037
}
30333038

@@ -3041,6 +3046,15 @@ unsigned. The number of dimensional values defined provide additional
30413046
information to the compiler on the dimensionality most likely to be used when
30423047
launching the kernel at runtime.
30433048

3049+
The arguments to ``work_group_size_hint`` are ordered based on which index
3050+
increments the fastest. In OpenCL, the first argument is the index that
3051+
increments the fastest. In SYCL, the last argument is the index that increments
3052+
the fastest.
3053+
3054+
In OpenCL C, this attribute is available with the GNU spelling
3055+
(``__attribute__((work_group_size_hint(X, Y, Z)))``) and all three arguments
3056+
are required.
3057+
30443058
The GNU spelling is deprecated in SYCL mode.
30453059

30463060
.. code-block:: c++
@@ -3052,15 +3066,6 @@ The GNU spelling is deprecated in SYCL mode.
30523066
[[sycl::work_group_size_hint(2, 2, 2)]] void operator()() const {}
30533067
};
30543068

3055-
The arguments to ``work_group_size_hint`` are ordered based on which index
3056-
increments the fastest. In OpenCL, the first argument is the index that
3057-
increments the fastest, and in SYCL, the last argument is the index that
3058-
increments the fastest.
3059-
3060-
In OpenCL C, this attribute is available with the GNU spelling
3061-
(``__attribute__((work_group_size_hint(X, Y, Z)))``) and all
3062-
three arguments are required.
3063-
30643069
In SYCL, the attribute accepts either one, two, or three arguments; in each
30653070
form, the last (or only) argument is the index that increments fastest. The
30663071
number of arguments passed to the attribute must match the dimensionality of
@@ -3077,9 +3082,11 @@ def SYCLIntelMaxWorkGroupSizeAttrDocs : Documentation {
30773082
let Heading = "intel::max_work_group_size";
30783083
let Content = [{
30793084
Applies to a device function/lambda function. Indicates the maximum dimensions
3080-
of a work group. Values must be positive integers. This is similar to
3081-
reqd_work_group_size, but allows work groups that are smaller or equal to the
3082-
specified sizes.
3085+
of a work group. Values must be positive integers. This attribute behaves
3086+
similarly to ``reqd_work_group_size``, but allows work groups that are smaller
3087+
or equal to the specified sizes. The dimensionality behaves the same as with
3088+
the SYCL ``reqd_work_group_size`` attribute, but *all* dimensions must be
3089+
provided.
30833090

30843091
In SYCL 1.2.1 mode, the ``intel::max_work_group_size`` attribute is propagated
30853092
from the function it is applied to onto the kernel which calls the function.

0 commit comments

Comments
 (0)