diff --git a/benchmarks/bvh_driver/benchmark_registration.hpp b/benchmarks/bvh_driver/benchmark_registration.hpp index 264e7ae70..a228a78ce 100644 --- a/benchmarks/bvh_driver/benchmark_registration.hpp +++ b/benchmarks/bvh_driver/benchmark_registration.hpp @@ -191,7 +191,7 @@ struct CountCallback KOKKOS_FUNCTION void operator()(Query const &query, Value) const { auto const i = ArborX::getData(query); - Kokkos::atomic_increment(&count_(i)); + Kokkos::atomic_inc(&count_(i)); } }; diff --git a/benchmarks/dbscan/dbscan_timpl.hpp b/benchmarks/dbscan/dbscan_timpl.hpp index 0850cf123..6acd3f20d 100644 --- a/benchmarks/dbscan/dbscan_timpl.hpp +++ b/benchmarks/dbscan/dbscan_timpl.hpp @@ -83,7 +83,7 @@ void sortAndFilterClusters(ExecutionSpace const &exec_space, if (labels(i) < 0) return; - Kokkos::atomic_increment(&cluster_sizes(labels(i))); + Kokkos::atomic_inc(&cluster_sizes(labels(i))); }); // This kernel serves dual purpose: diff --git a/benchmarks/execution_space_instances/execution_space_instances_driver.cpp b/benchmarks/execution_space_instances/execution_space_instances_driver.cpp index 0c80cc9dc..830c33e3c 100644 --- a/benchmarks/execution_space_instances/execution_space_instances_driver.cpp +++ b/benchmarks/execution_space_instances/execution_space_instances_driver.cpp @@ -84,7 +84,7 @@ struct CountCallback KOKKOS_FUNCTION void operator()(Query const &query, Value const &) const { auto const i = ArborX::getData(query); - Kokkos::atomic_increment(&_counts(i)); + Kokkos::atomic_inc(&_counts(i)); } }; diff --git a/src/cluster/ArborX_DBSCAN.hpp b/src/cluster/ArborX_DBSCAN.hpp index 137f97301..94dc2e6d9 100644 --- a/src/cluster/ArborX_DBSCAN.hpp +++ b/src/cluster/ArborX_DBSCAN.hpp @@ -461,7 +461,7 @@ dbscan(ExecutionSpace const &exec_space, Primitives const &primitives, if (vstat != old) labels(i) = vstat; - Kokkos::atomic_increment(&cluster_sizes(labels(i))); + Kokkos::atomic_inc(&cluster_sizes(labels(i))); }); if (is_special_case) { diff --git a/src/cluster/detail/ArborX_FDBSCAN.hpp b/src/cluster/detail/ArborX_FDBSCAN.hpp index 704685580..80db1f9f6 100644 --- a/src/cluster/detail/ArborX_FDBSCAN.hpp +++ b/src/cluster/detail/ArborX_FDBSCAN.hpp @@ -33,14 +33,12 @@ struct CountUpToN template KOKKOS_FUNCTION auto operator()(Query const &query, Value const &) const { - auto i = getData(query); - Kokkos::atomic_increment(&_counts(i)); + int const i = getData(query); + int &count = _counts(i); + if (Kokkos::atomic_inc_fetch(&count) >= _n) + return ArborX::CallbackTreeTraversalControl::early_exit; - if (_counts(i) < _n) - return ArborX::CallbackTreeTraversalControl::normal_continuation; - - // Once count reaches threshold, terminate the traversal. - return ArborX::CallbackTreeTraversalControl::early_exit; + return ArborX::CallbackTreeTraversalControl::normal_continuation; } }; diff --git a/src/cluster/detail/ArborX_FDBSCANDenseBox.hpp b/src/cluster/detail/ArborX_FDBSCANDenseBox.hpp index 6915e2da8..8b0baa911 100644 --- a/src/cluster/detail/ArborX_FDBSCANDenseBox.hpp +++ b/src/cluster/detail/ArborX_FDBSCANDenseBox.hpp @@ -74,16 +74,14 @@ struct CountUpToN_DenseBox int j = _permute(jj); if (distance(query_point, _primitives(j)) <= eps) { - Kokkos::atomic_increment(&count); - if (count >= _n) + if (Kokkos::atomic_inc_fetch(&count) >= _n) return ArborX::CallbackTreeTraversalControl::early_exit; } } } else { - Kokkos::atomic_increment(&count); - if (count >= _n) + if (Kokkos::atomic_inc_fetch(&count) >= _n) return ArborX::CallbackTreeTraversalControl::early_exit; } diff --git a/src/distributed/detail/ArborX_DistributedTreeUtils.hpp b/src/distributed/detail/ArborX_DistributedTreeUtils.hpp index fe7f6c6af..f61465337 100644 --- a/src/distributed/detail/ArborX_DistributedTreeUtils.hpp +++ b/src/distributed/detail/ArborX_DistributedTreeUtils.hpp @@ -38,9 +38,8 @@ void countResults(ExecutionSpace const &space, int n_queries, Kokkos::parallel_for( "ArborX::DistributedTree::query::count_results_per_query", - Kokkos::RangePolicy(space, 0, nnz), KOKKOS_LAMBDA(int i) { - Kokkos::atomic_increment(&offset(query_ids(i))); - }); + Kokkos::RangePolicy(space, 0, nnz), + KOKKOS_LAMBDA(int i) { Kokkos::atomic_inc(&offset(query_ids(i))); }); KokkosExt::exclusive_scan(space, offset, offset, 0); } diff --git a/src/spatial/detail/ArborX_CrsGraphWrapperImpl.hpp b/src/spatial/detail/ArborX_CrsGraphWrapperImpl.hpp index 7f17f99b7..7f33b6924 100644 --- a/src/spatial/detail/ArborX_CrsGraphWrapperImpl.hpp +++ b/src/spatial/detail/ArborX_CrsGraphWrapperImpl.hpp @@ -86,9 +86,8 @@ struct InsertGenerator else if constexpr (std::is_same_v) { - return _callback(raw_predicate, value, [&](ValueType const &) { - Kokkos::atomic_increment(&count); - }); + return _callback(raw_predicate, value, + [&](ValueType const &) { Kokkos::atomic_inc(&count); }); } else { diff --git a/src/spatial/detail/ArborX_ExpandHalfToFull.hpp b/src/spatial/detail/ArborX_ExpandHalfToFull.hpp index f8d3de513..09e88537a 100644 --- a/src/spatial/detail/ArborX_ExpandHalfToFull.hpp +++ b/src/spatial/detail/ArborX_ExpandHalfToFull.hpp @@ -37,8 +37,8 @@ void expandHalfToFull(ExecutionSpace const &space, Offsets &offsets, for (int j = offsets_orig(i); j < offsets_orig(i + 1); ++j) { int const k = indices_orig(j); - Kokkos::atomic_increment(&offsets(i)); - Kokkos::atomic_increment(&offsets(k)); + Kokkos::atomic_inc(&offsets(i)); + Kokkos::atomic_inc(&offsets(k)); } }); KokkosExt::exclusive_scan(space, offsets, offsets, 0); diff --git a/src/spatial/detail/ArborX_NeighborList.hpp b/src/spatial/detail/ArborX_NeighborList.hpp index 4ac7f2e40..f209d8f06 100644 --- a/src/spatial/detail/ArborX_NeighborList.hpp +++ b/src/spatial/detail/ArborX_NeighborList.hpp @@ -77,7 +77,7 @@ void findHalfNeighborList(ExecutionSpace const &space, HalfTraversal( space, bvh, KOKKOS_LAMBDA(Value const &, Value const &value) { - Kokkos::atomic_increment(&offsets(value.index)); + Kokkos::atomic_inc(&offsets(value.index)); }, NeighborListPredicateGetter{radius}); KokkosExt::exclusive_scan(space, offsets, offsets, 0); @@ -136,8 +136,8 @@ void findFullNeighborList(ExecutionSpace const &space, HalfTraversal( space, bvh, KOKKOS_LAMBDA(Value const &value1, Value const &value2) { - Kokkos::atomic_increment(&offsets(value1.index)); - Kokkos::atomic_increment(&offsets(value2.index)); + Kokkos::atomic_inc(&offsets(value1.index)); + Kokkos::atomic_inc(&offsets(value2.index)); }, NeighborListPredicateGetter{radius}); KokkosExt::exclusive_scan(space, offsets, offsets, 0); diff --git a/test/tstDetailsHalfTraversal.cpp b/test/tstDetailsHalfTraversal.cpp index 167add989..2ed0b476f 100644 --- a/test/tstDetailsHalfTraversal.cpp +++ b/test/tstDetailsHalfTraversal.cpp @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(half_traversal, DeviceType, ARBORX_DEVICE_TYPES) int i = value1.index; int j = value2.index; auto [min_ij, max_ij] = Kokkos::minmax(i, j); - Kokkos::atomic_increment(&count(max_ij * (max_ij + 1) / 2 + min_ij)); + Kokkos::atomic_inc(&count(max_ij * (max_ij + 1) / 2 + min_ij)); }, Test::PredicateGetter{});