Skip to content

Commit ece170d

Browse files
authored
Clarify ballot ops for remainder subgroups (#689)
As discussed in issue #626, the wording used to describe the sub_group_ballot_bit_count() and sub_group_ballot_find_msb() operations included the phrase "only considering the bits in _value_ that represent predicate values from all work items in the subgroup", but "remainder" subgroups were not considered when arriving at this wording. In Vulkan, the subgroup size is defined in a way that is equivalent to the definition of the maximum subgroup size in OpenCL. Therefore, in Vulkan, "remainder" subgroups start with work-items that are initially inactive, but are still considered work-items within the subgroup. The ballot operations in OpenCL were intended to be equivalent to those in Vulkan. Therefore, for a "remainder" subgroup, predicate bits that would correspond to non-existent work-items that would be considered initially inactive in Vulkan should still contribute to ballot operations that concern predicate bits and are always required to be well-defined. The sub_group_ballot_bit_count() and sub_group_ballot_find_msb() operations are affected by this. Due to the manner of their operation, the sub_group_ballot_find_lsb(), sub_group_ballot_inclusive_scan() and sub_group_ballot_exclusive_scan() operations are not affected. However, as sub_group_ballot_find_lsb() is described using the same wording, and altering the wording does not affect its semantics, it has been updated for consistency.
1 parent ebc87e5 commit ece170d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

ext/cl_khr_subgroup_extensions.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ The predicate return value is undefined if the work item with subgroup local ID
303303
uint sub_group_ballot_bit_count(
304304
uint4 value )
305305
----
306-
| Returns the number of bits that are set in the bitfield _value_, only considering the bits in _value_ that represent predicate values from all work items in the subgroup.
306+
| Returns the number of bits that are set in the bitfield _value_, only considering the bits in _value_ that represent predicate values corresponding to subgroup local IDs less than the maximum subgroup size within the dispatch (as returned by `get_max_sub_group_size`).
307307

308308
|[source,c]
309309
----
@@ -324,15 +324,15 @@ uint sub_group_ballot_exclusive_scan(
324324
uint sub_group_ballot_find_lsb(
325325
uint4 value )
326326
----
327-
| Returns the smallest subgroup local ID with a bit set in the bitfield _value_, only considering the bits in _value_ that represent predicate values from all work items in the subgroup.
327+
| Returns the smallest subgroup local ID with a bit set in the bitfield _value_, only considering the bits in _value_ that represent predicate values corresponding to subgroup local IDs less than the maximum subgroup size within the dispatch (as returned by `get_max_sub_group_size`).
328328
If no bits representing predicate values from all work items in the subgroup are set in the bitfield _value_ then the return value is undefined.
329329

330330
|[source,c]
331331
----
332332
uint sub_group_ballot_find_msb(
333333
uint4 value )
334334
----
335-
| Returns the largest subgroup local ID with a bit set in the bitfield _value_, only considering the bits in _value_ that represent predicate values from all work items in the subgroup.
335+
| Returns the largest subgroup local ID with a bit set in the bitfield _value_, only considering the bits in _value_ that represent predicate values corresponding to subgroup local IDs less than the maximum subgroup size within the dispatch (as returned by `get_max_sub_group_size`).
336336
If no bits representing predicate values from all work items in the subgroup are set in the bitfield _value_ then the return value is undefined.
337337

338338
|[source,c]

0 commit comments

Comments
 (0)