Skip to content

Commit

Permalink
Add printouts and a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Jan 13, 2024
1 parent 4f84a09 commit 1dfe29a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/brute_force/example_brute_force.cpp
Expand Up @@ -15,6 +15,8 @@

#include <Kokkos_Core.hpp>

#include <iostream>

struct Dummy
{
int count;
Expand Down Expand Up @@ -50,6 +52,17 @@ struct ArborX::AccessTraits<Dummy, ArborX::PredicatesTag>
}
};

template <typename View,
typename Enable = std::enable_if_t<Kokkos::is_view_v<View>>>
std::ostream &operator<<(std::ostream &os, View const &view)
{
auto view_host =
Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, view);
std::copy(view_host.data(), view_host.data() + view.size(),
std::ostream_iterator<typename View::value_type>(std::cout, " "));
return os;
}

int main(int argc, char *argv[])
{
Kokkos::ScopeGuard guard(argc, argv);
Expand All @@ -71,6 +84,9 @@ int main(int argc, char *argv[])
bvh.query(space, predicates, indices, offset);

out_count = indices.extent(0);

std::cout << "offset (bvh): " << offset << std::endl;
std::cout << "indices (bvh): " << indices << std::endl;
}

{
Expand All @@ -80,6 +96,12 @@ int main(int argc, char *argv[])
Kokkos::View<int *, ExecutionSpace> offset("Example::offset", 0);
brute.query(space, predicates, indices, offset);

// The offset output should match the one from bvh. The indices output
// should have the same indices for each offset entry, but they may be
// in a different order.
std::cout << "offset (bf): " << offset << std::endl;
std::cout << "indices (bf): " << indices << std::endl;

ARBORX_ASSERT(out_count == indices.extent(0));
}

Expand Down

0 comments on commit 1dfe29a

Please sign in to comment.