Skip to content

Commit aeeec84

Browse files
committed
Minor optimization in ExpandHalfToFull
No need to hammer local counts with atomics, use local variable instead.
1 parent 1f818a9 commit aeeec84

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/spatial/detail/ArborX_ExpandHalfToFull.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ void expandHalfToFull(ExecutionSpace const &space, Offsets &offsets,
3434
Kokkos::parallel_for(
3535
"ArborX::Experimental::HalfToFull::count",
3636
Kokkos::RangePolicy(space, 0, n), KOKKOS_LAMBDA(int i) {
37+
int local_update = 0;
3738
for (int j = offsets_orig(i); j < offsets_orig(i + 1); ++j)
3839
{
40+
++local_update;
3941
int const k = indices_orig(j);
40-
Kokkos::atomic_inc(&offsets(i));
4142
Kokkos::atomic_inc(&offsets(k));
4243
}
44+
Kokkos::atomic_add(&offsets(i), local_update);
4345
});
4446
KokkosExt::exclusive_scan(space, offsets, offsets, 0);
4547

0 commit comments

Comments
 (0)