Skip to content

[SYCL] Update root_group extension to use this_work_item namespace #13304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,15 @@ class nd_item {
sycl::ext::oneapi::experimental::root_group<Dimensions> ext_oneapi_get_root_group() const;
};

namespace ext {
namespace oneapi {
namespace experimental {
namespace this_kernel {
namespace ext::oneapi::experimental {
namespace this_work_item {

template <int Dimensions>
root_group<Dimensions> get_root_group();

} // namespace this_kernel
} // namespace experimental
} // namespace oneapi
} // namespace ext
}

} // namespace ext::oneapi::experimental
} // namespace sycl
----

Expand All @@ -505,6 +502,31 @@ a `sycl::nd_range` argument.
_Returns_: A `root_group` instance representing the root-group to which the
calling work-item belongs.

=== Deprecated functionality

The functionality in this section was previously part of this extension, but is
now deprecated.

[source,c++]
----
namespace sycl::ext::oneapi::experimental {

namespace this_kernel {

template <int Dimensions>
root_group<Dimensions> get_root_group();

} // namespace this_kernel

}
----

[source,c++]
----
template <int Dimensions>
root_group<Dimensions> get_root_group();
----
_Effects_: Equivalent to `return this_work_item::get_root_group()`.

== Implementation notes

Expand Down
13 changes: 11 additions & 2 deletions sycl/include/sycl/ext/oneapi/experimental/root_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,21 @@ template <int Dimensions> sycl::sub_group get_child_group(group<Dimensions> g) {
(void)g;
return this_sub_group();
}

namespace this_kernel {
namespace this_work_item {
template <int Dimensions> root_group<Dimensions> get_root_group() {
return sycl::ext::oneapi::this_work_item::get_nd_item<Dimensions>()
.ext_oneapi_get_root_group();
}
} // namespace this_work_item

namespace this_kernel {
template <int Dimensions>
__SYCL_DEPRECATED(
"use sycl::ext::oneapi::experimental::this_work_item::get_root_group() "
"instead")
root_group<Dimensions> get_root_group() {
this_work_item::get_root_group<Dimensions>();
}
} // namespace this_kernel

} // namespace ext::oneapi::experimental
Expand Down
3 changes: 2 additions & 1 deletion sycl/test-e2e/GroupAlgorithm/root_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ void testRootGroup() {
sycl::group_barrier(root);

root =
sycl::ext::oneapi::experimental::this_kernel::get_root_group<1>();
sycl::ext::oneapi::experimental::this_work_item::get_root_group<
1>();
int sum = data[root.get_local_id()] +
data[root.get_local_range() - root.get_local_id() - 1];
sycl::group_barrier(root);
Expand Down
3 changes: 3 additions & 0 deletions sycl/test/warnings/free_functions_deprecation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ int main() {
// expected-warning@+1 {{'this_id<1>' is deprecated: use nd_range kernel and sycl::ext::oneapi::this_work_item::get_nd_item() instead}}
(void)sycl_exp::this_id<1>();

// expected-warning@+1 {{'get_root_group<1>' is deprecated: use sycl::ext::oneapi::experimental::this_work_item::get_root_group() instead}}
(void)sycl_exp::this_kernel::get_root_group<1>();

return 0;
}