Skip to content

Commit

Permalink
Remove excluxive_scan(space, view) as non-standard
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Dec 27, 2023
1 parent 287ea35 commit aed278b
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion benchmarks/dbscan/dbscan_timpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void sortAndFilterClusters(ExecutionSpace const &exec_space,
},
num_clusters);
Kokkos::resize(Kokkos::WithoutInitializing, cluster_offset, num_clusters + 1);
KokkosExt::exclusive_scan(exec_space, cluster_offset);
KokkosExt::exclusive_scan(exec_space, cluster_offset, cluster_offset);

auto cluster_starts = KokkosExt::clone(exec_space, cluster_offset);
KokkosExt::reallocWithoutInitializing(
Expand Down
6 changes: 3 additions & 3 deletions src/details/ArborX_DetailsCrsGraphWrapperImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void queryImpl(ExecutionSpace const &space, Tree const &tree,
"ArborX::CrsGraphWrapper::copy_counts_to_offsets",
Kokkos::RangePolicy<ExecutionSpace>(space, 0, n_queries),
KOKKOS_LAMBDA(int const i) { permuted_offset(i) = counts(i); });
KokkosExt::exclusive_scan(space, offset);
KokkosExt::exclusive_scan(space, offset, offset);

int const n_results = KokkosExt::lastElement(space, offset);

Expand Down Expand Up @@ -302,7 +302,7 @@ allocateAndInitializeStorage(Tag, ExecutionSpace const &space,

if (buffer_size != 0)
{
KokkosExt::exclusive_scan(space, offset);
KokkosExt::exclusive_scan(space, offset, offset);

// Use calculation for the size to avoid calling lastElement(space, offset)
// as it will launch an extra kernel to copy to host.
Expand All @@ -325,7 +325,7 @@ allocateAndInitializeStorage(Tag, ExecutionSpace const &space,
"scan_queries_for_numbers_of_nearest_neighbors",
Kokkos::RangePolicy<ExecutionSpace>(space, 0, n_queries),
KOKKOS_LAMBDA(int i) { offset(i) = getK(predicates(i)); });
KokkosExt::exclusive_scan(space, offset);
KokkosExt::exclusive_scan(space, offset, offset);

KokkosExt::reallocWithoutInitializing(space, out,
KokkosExt::lastElement(space, offset));
Expand Down
6 changes: 3 additions & 3 deletions src/details/ArborX_DetailsDistributedTreeImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void DistributedTreeImpl<DeviceType>::deviseStrategy(
}
});

KokkosExt::exclusive_scan(space, new_offset);
KokkosExt::exclusive_scan(space, new_offset, new_offset);

// Truncate results so that queries will only be forwarded to as many local
// trees as necessary to find k neighbors.
Expand Down Expand Up @@ -685,7 +685,7 @@ void DistributedTreeImpl<DeviceType>::countResults(
Kokkos::atomic_increment(&offset(query_ids(i)));
});

KokkosExt::exclusive_scan(space, offset);
KokkosExt::exclusive_scan(space, offset, offset);
}

template <typename DeviceType>
Expand Down Expand Up @@ -893,7 +893,7 @@ void DistributedTreeImpl<DeviceType>::filterResults(
new_offset(q) = min(offset(q + 1) - offset(q), getK(queries(q)));
});

KokkosExt::exclusive_scan(space, new_offset);
KokkosExt::exclusive_scan(space, new_offset, new_offset);

int const n_truncated_results = KokkosExt::lastElement(space, new_offset);
Kokkos::View<int *, DeviceType> new_indices(
Expand Down
2 changes: 1 addition & 1 deletion src/details/ArborX_DetailsExpandHalfToFull.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void expandHalfToFull(ExecutionSpace const &space, Offsets &offsets,
Kokkos::atomic_increment(&offsets(k));
}
});
KokkosExt::exclusive_scan(space, offsets);
KokkosExt::exclusive_scan(space, offsets, offsets);

auto const m = KokkosExt::lastElement(space, offsets);
KokkosExt::reallocWithoutInitializing(space, indices, m);
Expand Down
2 changes: 1 addition & 1 deletion src/details/ArborX_DetailsTreeTraversal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct TreeTraversal<BVH, Predicates, Callback, NearestPredicateTag>
"scan_queries_for_numbers_of_neighbors",
Kokkos::RangePolicy<ExecutionSpace>(space, 0, n_queries),
KOKKOS_CLASS_LAMBDA(int i) { offset(i) = getK(_predicates(i)); });
KokkosExt::exclusive_scan(space, offset);
KokkosExt::exclusive_scan(space, offset, offset);
int const buffer_size = KokkosExt::lastElement(space, offset);
// Allocate buffer over which to perform heap operations in
// TreeTraversal::nearestQuery() to store nearest leaf nodes found so far.
Expand Down
4 changes: 2 additions & 2 deletions src/details/ArborX_NeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void findHalfNeighborList(ExecutionSpace const &space,
space, bvh,
KOKKOS_LAMBDA(int, int j) { Kokkos::atomic_increment(&offsets(j)); },
NeighborListPredicateGetter{radius});
KokkosExt::exclusive_scan(space, offsets);
KokkosExt::exclusive_scan(space, offsets, offsets);
KokkosExt::reallocWithoutInitializing(space, indices,
KokkosExt::lastElement(space, offsets));

Expand Down Expand Up @@ -105,7 +105,7 @@ void findFullNeighborList(ExecutionSpace const &space,
Kokkos::atomic_increment(&offsets(j));
},
NeighborListPredicateGetter{radius});
KokkosExt::exclusive_scan(space, offsets);
KokkosExt::exclusive_scan(space, offsets, offsets);
KokkosExt::reallocWithoutInitializing(space, indices,
KokkosExt::lastElement(space, offsets));

Expand Down
8 changes: 0 additions & 8 deletions src/kokkos_ext/ArborX_DetailsKokkosExtStdAlgorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ void exclusive_scan(ExecutionSpace &&space, Kokkos::View<ST, SP...> const &src,
ExclusiveScanFunctor<ValueType, DeviceType>(src, dst));
}

template <typename ExecutionSpace, typename T, typename... P>
inline std::enable_if_t<
Kokkos::is_execution_space<std::remove_reference_t<ExecutionSpace>>::value>
exclusive_scan(ExecutionSpace &&space, Kokkos::View<T, P...> const &v)
{
exclusive_scan(std::forward<ExecutionSpace>(space), v, v);
}

template <typename ExecutionSpace, typename ViewType>
typename ViewType::non_const_value_type
reduce(ExecutionSpace &&space, ViewType const &v,
Expand Down
4 changes: 2 additions & 2 deletions test/ArborX_BoostRTreeHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ performQueries(RTree<Indexable> const &rtree, InputView const &queries)
std::back_inserter(returned_values));
using ExecutionSpace = typename InputView::execution_space;
ExecutionSpace space;
KokkosExt::exclusive_scan(space, offset);
KokkosExt::exclusive_scan(space, offset, offset);
auto const n_results = KokkosExt::lastElement(space, offset);
OutputView indices("indices", n_results);
for (int i = 0; i < n_queries; ++i)
Expand Down Expand Up @@ -230,7 +230,7 @@ performQueries(ParallelRTree<Indexable> const &rtree, InputView const &queries)
std::back_inserter(returned_values));
using ExecutionSpace = typename InputView::execution_space;
ExecutionSpace space;
KokkosExt::exclusive_scan(space, offset);
KokkosExt::exclusive_scan(space, offset, offset);
auto const n_results = KokkosExt::lastElement(space, offset);
OutputView1 values("values", n_results);
for (int i = 0; i < n_queries; ++i)
Expand Down
2 changes: 1 addition & 1 deletion test/tstDetailsCrsGraphWrapperImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(query_impl, DeviceType, ARBORX_DEVICE_TYPES)
ExecutionSpace space;
KokkosExt::iota(space, permute);

KokkosExt::exclusive_scan(space, offset);
KokkosExt::exclusive_scan(space, offset, offset);
Kokkos::realloc(indices, KokkosExt::lastElement(space, offset));
ArborX::Details::CrsGraphWrapperImpl::queryImpl(
space, Test1{}, predicates, ArborX::Details::DefaultCallback{}, indices,
Expand Down
2 changes: 1 addition & 1 deletion test/tstDetailsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(exclusive_scan, DeviceType, ARBORX_DEVICE_TYPES)
v_host(1) = 1.;
v_host(2) = 0.;
Kokkos::deep_copy(v, v_host);
KokkosExt::exclusive_scan(space, v);
KokkosExt::exclusive_scan(space, v, v);
Kokkos::deep_copy(v_host, v);
std::vector<double> v_ref = {0., 1., 2.};
BOOST_TEST(v_host == v_ref, tt::per_element());
Expand Down

0 comments on commit aed278b

Please sign in to comment.