Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Dec 27, 2023
1 parent d221f4f commit d97938b
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion benchmarks/dbscan/dbscan_timpl.hpp
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, cluster_offset);
KokkosExt::exclusive_scan(exec_space, cluster_offset, cluster_offset, 0);

auto cluster_starts = KokkosExt::clone(exec_space, cluster_offset);
KokkosExt::reallocWithoutInitializing(
Expand Down
6 changes: 3 additions & 3 deletions src/details/ArborX_DetailsCrsGraphWrapperImpl.hpp
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, offset);
KokkosExt::exclusive_scan(space, offset, offset, 0);

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, offset);
KokkosExt::exclusive_scan(space, offset, offset, 0);

// 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, offset);
KokkosExt::exclusive_scan(space, offset, offset, 0);

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

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

// 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, offset);
KokkosExt::exclusive_scan(space, offset, offset, 0);
}

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, new_offset);
KokkosExt::exclusive_scan(space, new_offset, new_offset, 0);

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
Expand Up @@ -41,7 +41,7 @@ void expandHalfToFull(ExecutionSpace const &space, Offsets &offsets,
Kokkos::atomic_increment(&offsets(k));
}
});
KokkosExt::exclusive_scan(space, offsets, offsets);
KokkosExt::exclusive_scan(space, offsets, offsets, 0);

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
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, offset);
KokkosExt::exclusive_scan(space, offset, offset, 0);
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
2 changes: 1 addition & 1 deletion src/details/ArborX_DetailsUtils.hpp
Expand Up @@ -167,7 +167,7 @@ template <typename ExecutionSpace, typename ST, typename... SP, typename DT,
Kokkos::View<DT, DP...> const &dst)
{
Details::KokkosExt::exclusive_scan(std::forward<ExecutionSpace>(space), src,
dst);
dst, 0);
}

template <typename ExecutionSpace, typename T, typename... P>
Expand Down
4 changes: 2 additions & 2 deletions src/details/ArborX_NeighborList.hpp
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, offsets);
KokkosExt::exclusive_scan(space, offsets, offsets, 0);
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, offsets);
KokkosExt::exclusive_scan(space, offsets, offsets, 0);
KokkosExt::reallocWithoutInitializing(space, indices,
KokkosExt::lastElement(space, offsets));

Expand Down
16 changes: 8 additions & 8 deletions src/kokkos_ext/ArborX_DetailsKokkosExtStdAlgorithms.hpp
Expand Up @@ -21,12 +21,11 @@ namespace ArborX::Details::KokkosExt
{

template <typename ExecutionSpace, typename SrcView, typename DstView,
typename InitValueType = typename DstView::value_type>
typename InitValueType>
void exclusive_scan(ExecutionSpace const &space, SrcView const &src,
DstView const &dst, InitValueType init = 0)
DstView const &dst, InitValueType init)
{
static_assert(
Kokkos::is_execution_space<std::decay_t<ExecutionSpace>>::value);
static_assert(Kokkos::is_execution_space<ExecutionSpace>::value);
static_assert(Kokkos::is_view<SrcView>::value);
static_assert(Kokkos::is_view<DstView>::value);
static_assert(
Expand Down Expand Up @@ -63,8 +62,7 @@ typename ViewType::non_const_value_type
reduce(ExecutionSpace const &space, ViewType const &v,
typename ViewType::non_const_value_type init)
{
static_assert(
Kokkos::is_execution_space<std::decay_t<ExecutionSpace>>::value);
static_assert(Kokkos::is_execution_space<ExecutionSpace>::value);
static_assert(Kokkos::is_view<ViewType>::value);
static_assert(is_accessible_from<typename ViewType::memory_space,
ExecutionSpace>::value,
Expand Down Expand Up @@ -93,8 +91,7 @@ template <typename ExecutionSpace, typename SrcView, typename DstView>
void adjacent_difference(ExecutionSpace const &space, SrcView const &src,
DstView const &dst)
{
static_assert(
Kokkos::is_execution_space<std::decay_t<ExecutionSpace>>::value);
static_assert(Kokkos::is_execution_space<ExecutionSpace>::value);
static_assert(Kokkos::is_view<SrcView>::value);
static_assert(Kokkos::is_view<DstView>::value);
static_assert(
Expand Down Expand Up @@ -133,6 +130,9 @@ void iota(ExecutionSpace const &space, ViewType const &v,
{
static_assert(Kokkos::is_execution_space<ExecutionSpace>::value);
static_assert(Kokkos::is_view<ViewType>::value);
static_assert(is_accessible_from<typename ViewType::memory_space,
ExecutionSpace>::value,
"View must be accessible from the execution space");
static_assert(unsigned(ViewType::rank) == unsigned(1),
"iota requires a View of rank 1");

Expand Down
4 changes: 2 additions & 2 deletions test/ArborX_BoostRTreeHelpers.hpp
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, offset);
KokkosExt::exclusive_scan(space, offset, offset, 0);
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, offset);
KokkosExt::exclusive_scan(space, offset, offset, 0);
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
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, offset);
KokkosExt::exclusive_scan(space, offset, offset, 0);
Kokkos::realloc(indices, KokkosExt::lastElement(space, offset));
ArborX::Details::CrsGraphWrapperImpl::queryImpl(
space, Test1{}, predicates, ArborX::Details::DefaultCallback{}, indices,
Expand Down
14 changes: 7 additions & 7 deletions test/tstDetailsKokkosExtStdAlgorithms.cpp
Expand Up @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(exclusive_scan, DeviceType, ARBORX_DEVICE_TYPES)
Kokkos::deep_copy(x, x_host);

Kokkos::View<int *, DeviceType> y("y", n);
KokkosExt::exclusive_scan(space, x, y);
KokkosExt::exclusive_scan(space, x, y, 0);

std::vector<int> y_ref(n);
std::iota(y_ref.begin(), y_ref.end(), 0);
Expand All @@ -78,33 +78,33 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(exclusive_scan, DeviceType, ARBORX_DEVICE_TYPES)
BOOST_TEST(y_host == y_ref, tt::per_element());
BOOST_TEST(x_host == x_ref, tt::per_element());
// in-place
KokkosExt::exclusive_scan(space, x, x);
KokkosExt::exclusive_scan(space, x, x, 0);
Kokkos::deep_copy(x_host, x);
BOOST_TEST(x_host == y_ref, tt::per_element());
int const m = 11;
BOOST_TEST(n != m);
Kokkos::View<int *, DeviceType> z("z", m);
BOOST_CHECK_THROW(KokkosExt::exclusive_scan(space, x, z),
BOOST_CHECK_THROW(KokkosExt::exclusive_scan(space, x, z, 0),
ArborX::SearchException);
Kokkos::View<double[3], DeviceType> v("v");
auto v_host = Kokkos::create_mirror_view(v);
v_host(0) = 1.;
v_host(1) = 1.;
v_host(2) = 0.;
Kokkos::deep_copy(v, v_host);
KokkosExt::exclusive_scan(space, v, v);
KokkosExt::exclusive_scan(space, v, v, 5.);
Kokkos::deep_copy(v_host, v);
std::vector<double> v_ref = {0., 1., 2.};
std::vector<double> v_ref = {5., 6., 7.};
BOOST_TEST(v_host == v_ref, tt::per_element());
Kokkos::View<double *, DeviceType> w("w", 4);
BOOST_CHECK_THROW(KokkosExt::exclusive_scan(space, v, w),
BOOST_CHECK_THROW(KokkosExt::exclusive_scan(space, v, w, 0),
ArborX::SearchException);
v_host(0) = 1.;
v_host(1) = 0.;
v_host(2) = 0.;
Kokkos::deep_copy(v, v_host);
Kokkos::resize(w, 3);
KokkosExt::exclusive_scan(space, v, w);
KokkosExt::exclusive_scan(space, v, w, 0);
auto w_host = Kokkos::create_mirror_view(w);
Kokkos::deep_copy(w_host, w);
std::vector<double> w_ref = {0., 1., 1.};
Expand Down

0 comments on commit d97938b

Please sign in to comment.