Skip to content

Commit

Permalink
Prefer atomic_inc to atomic_increment
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Oct 15, 2024
1 parent 4243afc commit 7a78f6b
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion benchmarks/bvh_driver/benchmark_registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
};

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/dbscan/dbscan_timpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/cluster/ArborX_DBSCAN.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/cluster/detail/ArborX_FDBSCAN.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct CountUpToN
KOKKOS_FUNCTION auto operator()(Query const &query, Value const &) const
{
auto i = getData(query);
Kokkos::atomic_increment(&_counts(i));
Kokkos::atomic_inc(&_counts(i));

if (_counts(i) < _n)
return ArborX::CallbackTreeTraversalControl::normal_continuation;
Expand Down
4 changes: 2 additions & 2 deletions src/cluster/detail/ArborX_FDBSCANDenseBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ struct CountUpToN_DenseBox
int j = _permute(jj);
if (distance(query_point, _primitives(j)) <= eps)
{
Kokkos::atomic_increment(&count);
Kokkos::atomic_inc(&count);
if (count >= _n)
return ArborX::CallbackTreeTraversalControl::early_exit;
}
}
}
else
{
Kokkos::atomic_increment(&count);
Kokkos::atomic_inc(&count);
if (count >= _n)
return ArborX::CallbackTreeTraversalControl::early_exit;
}
Expand Down
5 changes: 2 additions & 3 deletions src/distributed/detail/ArborX_DistributedTreeUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions src/spatial/detail/ArborX_CrsGraphWrapperImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ struct InsertGenerator
else if constexpr (std::is_same_v<PassTag,
FirstPassNoBufferOptimizationTag>)
{
return _callback(raw_predicate, value, [&](ValueType const &) {
Kokkos::atomic_increment(&count);
});
return _callback(raw_predicate, value,
[&](ValueType const &) { Kokkos::atomic_inc(&count); });
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/spatial/detail/ArborX_ExpandHalfToFull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/spatial/detail/ArborX_NeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/tstDetailsHalfTraversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{});

Expand Down

0 comments on commit 7a78f6b

Please sign in to comment.