Skip to content

Commit 771ffa4

Browse files
authored
[SYCL] Remove get_child_group() (#13482)
get_child_group() was originally designed assuming there would be a fixed hierarchy of groups, and is therefore incompatible with extensions that would modify the hierarchy (e.g., "clusters" on NVIDIA GPUs). This interface should be replaced by a more general and explicit mechanism for partitioning groups that does not make such assumptions. Signed-off-by: John Pennycook <[email protected]> --------- Signed-off-by: John Pennycook <[email protected]>
1 parent 4354284 commit 771ffa4

File tree

3 files changed

+4
-53
lines changed

3 files changed

+4
-53
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_root_group.asciidoc

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
== Notice
2121

2222
[%hardbreaks]
23-
Copyright (C) 2022-2023 Intel Corporation. All rights reserved.
23+
Copyright (C) 2022-2024 Intel Corporation. All rights reserved.
2424

2525
Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks
2626
of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by
@@ -407,36 +407,7 @@ _Returns_: The number of work-groups or work-items of `Scope` hierarchy level wi
407407

408408
`root_group` provides an alternative representation of the work-items executing
409409
an ND-range kernel and exposes equivalent functionality to `sycl::nd_item` for
410-
querying a work-item's position in the global range. In order to provide access
411-
to information pertaining to a work-item's position in the work-group or
412-
sub-group local range, `root_group` needs to provide a new mechanism to access
413-
instances of the `sycl::group` and `sycl::sub_group` classes. The
414-
`get_child_group` function provides a general form of this mechanism, allowing
415-
developers to move down the hierarchy of fixed topology groups.
416-
417-
[source,c++]
418-
----
419-
template <typename Group>
420-
/* type of child group */ get_child_group(Group g);
421-
----
422-
_Constraints_: `Group` must be one of `root_group` or `sycl::group`.
423-
424-
_Returns_: An instance of another fixed topology group type, representing the
425-
child of group _g_ to which the calling work-item belongs. If `Group` is
426-
`root_group`, the child group type is `sycl::group` with the same
427-
dimensionality. If `Group` is `sycl::group`, the child group type is
428-
`sycl::sub_group`.
429-
430-
NOTE: Although `sycl::sub_group` is a fixed topology group, it is currently
431-
the lowest level of the hierarchy and cannot be passed to `get_child_group`.
432-
433-
NOTE: This extension does not provide a `get_parent_group` function because it
434-
would be easy to use incorrectly. It is good practice for a function accepting
435-
a group _g_ to only use the work-items in that group, to assist developers in
436-
reasoning about requirements of the call context (e.g. converged control flow).
437-
Dividing a group into its children is consistent with this practice, whereas
438-
accessing the parent group is not. Developers seeking this functionality should
439-
use the free function queries instead.
410+
querying a work-item's position in the global range.
440411

441412

442413
=== Synchronizing a `root_group`

sycl/include/sycl/ext/oneapi/experimental/root_group.hpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ template <int Dimensions> class root_group {
7979
sycl::nd_item<Dimensions> it;
8080
};
8181

82-
template <int Dimensions>
83-
group<Dimensions> get_child_group(root_group<Dimensions> g) {
84-
(void)g;
85-
return this_group<Dimensions>();
86-
}
87-
88-
template <int Dimensions> sycl::sub_group get_child_group(group<Dimensions> g) {
89-
(void)g;
90-
return this_sub_group();
91-
}
9282
namespace this_work_item {
9383
template <int Dimensions> root_group<Dimensions> get_root_group() {
9484
return sycl::ext::oneapi::this_work_item::get_nd_item<Dimensions>()
@@ -118,7 +108,7 @@ void group_barrier(ext::oneapi::experimental::root_group<dimensions> G,
118108
// workaround that's not intended to reduce the bar for SPIR-V modules
119109
// acceptance, but rather make a pessimistic case work until we have full
120110
// support for the device barrier built-in from backends.
121-
const auto ChildGroup = ext::oneapi::experimental::get_child_group(G);
111+
const auto ChildGroup = ext::oneapi::experimental::this_group<dimensions>();
122112
if (ChildGroup.get_group_linear_range() == 1) {
123113
group_barrier(ChildGroup);
124114
} else {

sycl/test-e2e/GroupAlgorithm/root_group.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void testRootGroupFunctions() {
8080
const auto props = sycl::ext::oneapi::experimental::properties{
8181
sycl::ext::oneapi::experimental::use_root_sync};
8282

83-
constexpr int testCount = 10;
83+
constexpr int testCount = 9;
8484
sycl::buffer<bool> testResultsBuf{sycl::range{testCount}};
8585
const auto range = sycl::nd_range<1>{maxWGs * WorkGroupSize, WorkGroupSize};
8686
q.submit([&](sycl::handler &h) {
@@ -103,16 +103,6 @@ void testRootGroupFunctions() {
103103
root.get_local_linear_id() == root.get_local_id().get(0);
104104
testResults[7] = root.get_group_linear_range() == 1;
105105
testResults[8] = root.get_local_linear_range() == WorkGroupSize;
106-
107-
const auto child =
108-
sycl::ext::oneapi::experimental::get_child_group(root);
109-
const auto grandchild =
110-
sycl::ext::oneapi::experimental::get_child_group(child);
111-
testResults[9] = child == it.get_group();
112-
static_assert(
113-
std::is_same_v<std::remove_cv<decltype(grandchild)>::type,
114-
sycl::sub_group>,
115-
"get_child_group(sycl::group) must return a sycl::sub_group");
116106
}
117107
});
118108
});

0 commit comments

Comments
 (0)