Skip to content

Commit 045f5ab

Browse files
[SYCL][Doc] Update sycl_ext_oneapi_sub_group_mask (#8174)
Updated the document to use up-to-date extension template. Added revision 2 of the extension, which adds ability for user to construct `sub_group_mask` from specific values. --------- Co-authored-by: John Pennycook <[email protected]>
1 parent 812cd8a commit 045f5ab

File tree

1 file changed

+86
-53
lines changed

1 file changed

+86
-53
lines changed

sycl/doc/extensions/supported/sycl_ext_oneapi_sub_group_mask.asciidoc

Lines changed: 86 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:toc: left
99
:encoding: utf-8
1010
:lang: en
11+
:dpcpp: pass:[DPC++]
1112

1213
:blank: pass:[ +]
1314

@@ -16,61 +17,65 @@
1617
// docbook uses c++ and html5 uses cpp.
1718
:language: {basebackend@docbook:c++:cpp}
1819

19-
== Introduction
20-
IMPORTANT: This specification is a draft.
2120

22-
NOTE: Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by permission by Khronos.
21+
== Notice
2322

24-
This document describes an extension which adds a `sub_group_mask` type. Such a mask can be used to efficiently represent subsets of work-items in a sub-group for which a given Boolean condition holds.
23+
[%hardbreaks]
24+
Copyright (C) 2021-2023 Intel Corporation. All rights reserved.
2525

26-
== Notice
26+
Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks
27+
of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by
28+
permission by Khronos.
2729

28-
Copyright (c) 2021 Intel Corporation. All rights reserved.
2930

30-
== Status
31+
== Contact
3132

32-
Working Draft
33+
To report problems with this extension, please open a new issue at:
3334

34-
This is a preview extension specification, intended to provide early access to a feature for review and community feedback. When the feature matures, this specification may be released as a formal extension.
35+
https://github.com/intel/llvm/issues
3536

36-
Because the interfaces defined by this specification are not final and are subject to change they are not intended to be used by shipping software products.
3737

38-
== Version
38+
== Dependencies
3939

40-
Revision: 1
40+
This extension is written against the SYCL 2020 revision 6 specification. All
41+
references below to the "core SYCL specification" or to section numbers in the
42+
SYCL specification refer to that revision.
4143

42-
== Contact
43-
John Pennycook, Intel (john 'dot' pennycook 'at' intel 'dot' com)
4444

45-
== Dependencies
45+
== Status
46+
47+
This extension is implemented and fully supported by {dpcpp}.
48+
49+
== Overview
50+
51+
This document describes an extension which adds a `sub_group_mask` type. Such a
52+
mask can be used to efficiently represent subsets of work-items in a sub-group
53+
for which a given Boolean condition holds.
54+
55+
Group mask functionality is currently limited to groups that are instances of
56+
the `sub_group` class, but this limitation may be lifted in a future version of
57+
the specification.
58+
4659

47-
This extension is written against the SYCL 2020 specification, Revision 3.
60+
== Specification
4861

49-
== Feature Test Macro
62+
=== Feature Test Macro
5063

5164
This extension provides a feature-test macro as described in the core SYCL
52-
specification section 6.3.3 "Feature test macros". Therefore, an
53-
implementation supporting this extension must predefine the macro
54-
`SYCL_EXT_ONEAPI_SUB_GROUP_MASK` to one of the values defined in the table
55-
below. Applications can test for the existence of this macro to determine if
65+
specification. An implementation supporting this extension must predefine the
66+
macro `SYCL_EXT_ONEAPI_SUB_GROUP_MASK` to one of the values defined in the table
67+
below. Applications can test for the existence of this macro to determine if
5668
the implementation supports this feature, or applications can test the macro's
57-
value to determine which of the extension's APIs the implementation supports.
69+
value to determine which of the extension's features the implementation
70+
supports.
5871

5972
[%header,cols="1,5"]
6073
|===
6174
|Value |Description
6275
|1 |Initial extension version. Base features are supported.
76+
|2 |`sub_group_mask` is user-constructible.
6377
|===
6478

65-
== Overview
66-
67-
A group mask is an integral type sized such that each work-item in the group is
68-
represented by a single bit. Such a mask can be used to efficiently represent
69-
subsets of work-items in a group for which a given Boolean condition holds.
70-
71-
Group mask functionality is currently limited to groups that are instances of
72-
the `sub_group` class, but this limitation may be lifted in a future version of
73-
the specification.
7479

7580
=== Ballot
7681

@@ -81,8 +86,10 @@ must be encountered by all work-items in the group in converged control flow.
8186
|===
8287
|Function|Description
8388

84-
|`template <typename Group> Group::mask_type group_ballot(Group g, bool predicate = true)`
85-
|Return a `sub_group_mask` with one bit for each work-item in group _g_. A bit is set in this mask if and only if the corresponding work-item's _predicate_ is `true`.
89+
|`template <typename Group> sub_group_mask group_ballot(Group g, bool predicate = true)`
90+
|Return a `sub_group_mask` with one bit for each work-item in group _g_. A bit
91+
is set in this mask if and only if the corresponding work-item's _predicate_ is
92+
`true`. Available only when `std::is_same_v<std::decay_t<Group>, sub_group>` is true.
8693
|===
8794

8895
=== Group Masks
@@ -100,6 +107,43 @@ The mask is defined such that the least significant bit (LSB) corresponds to
100107
the work-item with id 0, and the most significant bit (MSB) corresponds to the
101108
work-item with the id `max_local_range()-1`.
102109

110+
NOTE: Constructors and assignment operator below are only available starting in
111+
revision 2 of the specification.
112+
113+
|===
114+
|Constructor|Description
115+
116+
|`sub_group_mask()`
117+
|Constructs a group mask with all bits set to 0. Size of a group mask
118+
corresponds to max local range of the sub-group which work-item belongs to.
119+
120+
|`sub_group_mask(unsigned long long val)`
121+
|Constructs a group mask with the first `N` bit positions to the
122+
corresponding bit values in _val_. `N` is a size of a group mask and it
123+
corresponds to max local range of the sub-group which work-item belongs to. If
124+
size of a group mask is bigger than the number of bits in the value
125+
representation of `unsigned long long`, the remaining positions are initialized
126+
to zero.
127+
128+
|`template <typename T, std::size_t K> sub_group_mask(const sycl::marray<T, K>& &val)`
129+
|Constructs a group mask with the first `N` bit positions to the
130+
corresponding bit values in _val_. `T` must be a SYCL `marray` of integral
131+
types. `N` is a size of a group mask and it corresponds to max local range of
132+
the sub-group which work-item belongs to. If size of a group mask is bigger than
133+
number of bits in the value representation of `T`, the remaining positions are
134+
initialized to zero.
135+
136+
|`sub_group_mask(const sub_group_mask &other) = default`
137+
|Constructs a group mask as a copy of _other_. Size of _other_ group mask must
138+
be the same as max local range of the sub-group which work-item belongs to or
139+
otherwise behavior is undefined.
140+
141+
|`sub_group_mask& operator=(const sub_group_mask &other) = default`
142+
|Assigns this instance of `sub_group_mask` with a copy of _other_. Size of both
143+
group masks must be the same or otherwise behavior is undefined.
144+
|===
145+
146+
103147
|===
104148
|Member Function|Description
105149

@@ -259,6 +303,15 @@ struct sub_group_mask {
259303
260304
static constexpr size_t max_bits = /* implementation-defined */;
261305
306+
#if SYCL_EXT_ONEAPI_SUB_GROUP_MASK >= 2
307+
sub_group_mask();
308+
sub_group_mask(unsigned long long val);
309+
template<typename T, std::size_t K>
310+
sub_group_mask(const sycl::marray<T, K>& val);
311+
sub_group_mask(const sub_group_mask &other) = default;
312+
sub_group_mask& operator=(const sub_group_mask &other) = default;
313+
#endif
314+
262315
bool operator[](id<1> id) const;
263316
reference operator[](id<1> id);
264317
bool test(id<1> id) const;
@@ -318,23 +371,3 @@ None.
318371
//--
319372
//*RESOLUTION*: Not resolved.
320373
//--
321-
322-
== Revision History
323-
324-
[cols="5,15,15,70"]
325-
[grid="rows"]
326-
[options="header"]
327-
|========================================
328-
|Rev|Date|Author|Changes
329-
|1|2021-08-11|John Pennycook|*Initial public working draft*
330-
|2|2021-09-13|Vladimir Lazarev|*Update during implementation*
331-
|========================================
332-
333-
//************************************************************************
334-
//Other formatting suggestions:
335-
//
336-
//* Use *bold* text for host APIs, or [source] syntax highlighting.
337-
//* Use +mono+ text for device APIs, or [source] syntax highlighting.
338-
//* Use +mono+ text for extension names, types, or enum values.
339-
//* Use _italics_ for parameters.
340-
//************************************************************************

0 commit comments

Comments
 (0)