From bce423ce208b6be489bc2229976523076187df73 Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Wed, 22 Sep 2021 17:20:00 -0700 Subject: [PATCH 1/2] [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 --- sycl/include/CL/sycl/nd_item.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sycl/include/CL/sycl/nd_item.hpp b/sycl/include/CL/sycl/nd_item.hpp index 6a2dec50d8a12..999307803c6a5 100644 --- a/sycl/include/CL/sycl/nd_item.hpp +++ b/sycl/include/CL/sycl/nd_item.hpp @@ -82,12 +82,11 @@ template class nd_item { } range get_group_range() const { - return Group.get_global_range() / Group.get_local_range(); + return Group.get_group_range(); } size_t __SYCL_ALWAYS_INLINE get_group_range(int dimension) const { - size_t Range = - Group.get_global_range(dimension) / Group.get_local_range(dimension); + size_t Range = Group.get_group_range(dimension); __SYCL_ASSUME_INT(Range); return Range; } From 8e2162ff15df3fec3622470e5dc28f53e4d2b5a5 Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Thu, 23 Sep 2021 09:11:37 -0700 Subject: [PATCH 2/2] Fix clang-formatZZ Signed-off-by: Vyacheslav N Klochkov --- sycl/include/CL/sycl/nd_item.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sycl/include/CL/sycl/nd_item.hpp b/sycl/include/CL/sycl/nd_item.hpp index 999307803c6a5..db92989d03b52 100644 --- a/sycl/include/CL/sycl/nd_item.hpp +++ b/sycl/include/CL/sycl/nd_item.hpp @@ -81,9 +81,7 @@ template class nd_item { return Id; } - range get_group_range() const { - return Group.get_group_range(); - } + range get_group_range() const { return Group.get_group_range(); } size_t __SYCL_ALWAYS_INLINE get_group_range(int dimension) const { size_t Range = Group.get_group_range(dimension);