Skip to content

Commit

Permalink
Get rid of PairValueIndex and LegacyDefaultCallback in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Nov 23, 2024
1 parent 1c9ff1a commit b933420
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
11 changes: 5 additions & 6 deletions examples/simple_intersection/example_intersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ int main(int argc, char *argv[])

ExecutionSpace space;

using Value = ArborX::PairValueIndex<Box>;

ArborX::BoundingVolumeHierarchy const tree(
space, ArborX::Experimental::attach_indices(boxes));

// The query will resize values and offsets accordingly
Kokkos::View<Value *, MemorySpace> values("Example::values", 0);
Kokkos::View<typename decltype(tree)::value_type *, MemorySpace> values(
"Example::values", 0);
Kokkos::View<int *, MemorySpace> offsets("Example::offsets", 0);
tree.query(space, queries, values, offsets);

Expand All @@ -73,9 +72,9 @@ int main(int argc, char *argv[])
std::copy(offsets_host.data(), offsets_host.data() + offsets.size(),
std::ostream_iterator<int>(std::cout, " "));
std::cout << "\nindices:";
for (int i = 0; i < values_host.extent_int(0); ++i)
std::cout << " " << values_host(i).index;
std::cout << '\n';
std::transform(values_host.data(), values_host.data() + values.size(),
std::ostream_iterator<int>(std::cout, " "),
[](auto value) { return value.index; });

return 0;
}
15 changes: 8 additions & 7 deletions examples/triangle_intersection/triangle_intersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ int main(int argc, char *argv[])
space, ArborX::Experimental::attach_indices(triangles));

// The query will resize indices and offsets accordingly
Kokkos::View<unsigned *, MemorySpace> indices("Example::indices", 0);
Kokkos::View<typename decltype(tree)::value_type *, MemorySpace> values(
"Example::values", 0);
Kokkos::View<int *, MemorySpace> offsets("Example::offsets", 0);
tree.query(space, queries, ArborX::Details::LegacyDefaultCallback{}, indices,
offsets);
tree.query(space, queries, values, offsets);

auto offsets_host =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, offsets);
auto indices_host =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, indices);
auto values_host =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, values);

// Expected output:
// offsets: 0 1 2 3 4
Expand All @@ -105,8 +105,9 @@ int main(int argc, char *argv[])
std::copy(offsets_host.data(), offsets_host.data() + offsets.size(),
std::ostream_iterator<int>(std::cout, " "));
std::cout << "\nindices: ";
std::copy(indices_host.data(), indices_host.data() + indices.size(),
std::ostream_iterator<int>(std::cout, " "));
std::transform(values_host.data(), values_host.data() + values.size(),
std::ostream_iterator<int>(std::cout, " "),
[](auto value) { return value.index; });
std::cout << "\n";

return 0;
Expand Down

0 comments on commit b933420

Please sign in to comment.