Skip to content

Commit 0cd7b7e

Browse files
authored
[SYCL] Avoid re-computing group_range in nd_item::get_group_range() (#4621)
* [SYCL] Avoid re-computing group_range in nd_item class This fix is mostly NFC. Instead of doing costly division operations and re-computing the group_range inside nd_item class, it is better to call group::get_group_range() that does not do divisions as the group class keeps the group_range as a pre-computed field. Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent 5b8f3b0 commit 0cd7b7e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

sycl/include/CL/sycl/nd_item.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,10 @@ template <int dimensions = 1> class nd_item {
8181
return Id;
8282
}
8383

84-
range<dimensions> get_group_range() const {
85-
return Group.get_global_range() / Group.get_local_range();
86-
}
84+
range<dimensions> get_group_range() const { return Group.get_group_range(); }
8785

8886
size_t __SYCL_ALWAYS_INLINE get_group_range(int dimension) const {
89-
size_t Range =
90-
Group.get_global_range(dimension) / Group.get_local_range(dimension);
87+
size_t Range = Group.get_group_range(dimension);
9188
__SYCL_ASSUME_INT(Range);
9289
return Range;
9390
}

0 commit comments

Comments
 (0)