Skip to content

Commit 3fc5cdc

Browse files
committed
Minor optimization in ExpandHalfToFull
No need to hammer local counts with atomics, use local variable instead.
1 parent 0e3df2f commit 3fc5cdc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/spatial/detail/ArborX_ExpandHalfToFull.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ 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
{
39-
int const k = indices_orig(j);
40-
Kokkos::atomic_inc(&offsets(i));
41-
Kokkos::atomic_inc(&offsets(k));
40+
++local_update;
41+
Kokkos::atomic_inc(&offsets(indices_orig(j)));
4242
}
43+
Kokkos::atomic_add(&offsets(i), local_update);
4344
});
4445
KokkosExt::exclusive_scan(space, offsets, offsets, 0);
4546

0 commit comments

Comments
 (0)