Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Oct 24, 2023
1 parent 6320774 commit 34d74fc
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 62 deletions.
13 changes: 7 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ set(ARBORX_TEST_QUERY_TREE_SOURCES)
foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BVH.cpp.tmp"
"#include <ArborX_LinearBVH.hpp>\n"
"[[maybe_unused]] constexpr bool APIv1 = true;\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX::BVH>\n"
"#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n"
"#include <tstQueryTree${_test}.cpp>\n"
Expand All @@ -90,8 +89,7 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost)

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BasicBVH.cpp.tmp"
"#include <ArborX_LinearBVH.hpp>\n"
"template <class MemorySpace> using ArborX__BoundingVolumeHierarchy_Box = ArborX::BasicBoundingVolumeHierarchy<MemorySpace, ArborX::Details::PairIndexVolume<ArborX::Box>, ArborX::Details::DefaultIndexableGetter, ArborX::Box>;\n"
"[[maybe_unused]] constexpr bool APIv1 = false;\n"
"#include \"Search_UnitTestHelpers.hpp\"\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX__BoundingVolumeHierarchy_Box>\n"
"#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n"
"#include <tstQueryTree${_test}.cpp>\n"
Expand All @@ -106,7 +104,6 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost)
"#include <ArborX_BruteForce.hpp>\n"
"#include <ArborX_Box.hpp>\n"
"template <class MemorySpace> using ArborX__BruteForce = ArborX::BruteForce<MemorySpace, ArborX::Box>;\n"
"[[maybe_unused]] constexpr bool APIv1 = true;\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX__BruteForce>\n"
"#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n"
"#define ARBORX_TEST_DISABLE_NEAREST_QUERY\n"
Expand All @@ -122,12 +119,16 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/tstQueryTree${_test}_BVH_${_bounding_volume}.cpp.tmp"
"#include <ArborX_LinearBVH.hpp>\n"
"#include <ArborX_KDOP.hpp>\n"
"#include \"Search_UnitTestHelpers.hpp\"\n"
"using KDOP6 = ArborX::Experimental::KDOP<6>;\n"
"using KDOP14 = ArborX::Experimental::KDOP<14>;\n"
"using KDOP18 = ArborX::Experimental::KDOP<18>;\n"
"using KDOP26 = ArborX::Experimental::KDOP<26>;\n"
"template <class MemorySpace> using ArborX__BoundingVolumeHierarchy_${_bounding_volume} = ArborX::BasicBoundingVolumeHierarchy<MemorySpace, ArborX::Details::PairIndexVolume<${_bounding_volume}>, ArborX::Details::DefaultIndexableGetter, ${_bounding_volume}>;\n"
"[[maybe_unused]] constexpr bool APIv1 = false;\n"
"template <class MemorySpace>\n"
"using ArborX__BoundingVolumeHierarchy_${_bounding_volume} =\n"
" LegacyTree<ArborX::BasicBoundingVolumeHierarchy<\n"
" MemorySpace, ArborX::Details::PairIndexVolume<${_bounding_volume}>,\n"
" ArborX::Details::DefaultIndexableGetter, ${_bounding_volume}>>;\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX__BoundingVolumeHierarchy_${_bounding_volume}>\n"
"#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n"
"#define ARBORX_TEST_DISABLE_NEAREST_QUERY\n"
Expand Down
15 changes: 2 additions & 13 deletions test/Search_UnitTestHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,12 @@ auto query_with_distance(ExecutionSpace const &exec_space, Tree const &tree,
BOOST_TEST(query_with_distance(exec_space, tree, queries) == (reference), \
boost::test_tools::per_element());

template <typename Tree, bool Legacy>
class LegacyTree;

template <typename Tree>
class LegacyTree<Tree, true> : public Tree
class LegacyTree : public Tree
{
public:
template <typename ExecutionSpace, typename Primitives>
LegacyTree(ExecutionSpace const &space, Primitives const &primitives)
: Tree(space, primitives)
{}
};
LegacyTree() = default;

template <typename Tree>
class LegacyTree<Tree, false> : public Tree
{
public:
template <typename ExecutionSpace, typename Primitives>
LegacyTree(ExecutionSpace const &space, Primitives const &primitives)
: Tree(space,
Expand Down
20 changes: 10 additions & 10 deletions test/tstQueryTreeCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_spatial_predicate, TreeTypeTraits,
auto values = initialize_values(points, /*delta*/ 0.f);
std::vector<int> offsets = {0, n};

LegacyTree<Tree, APIv1> const tree(ExecutionSpace{}, points);
Tree const tree(ExecutionSpace{}, points);

ARBORX_TEST_QUERY_TREE_CALLBACK(ExecutionSpace{}, tree,
makeIntersectsBoxQueries<DeviceType>({
Expand Down Expand Up @@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_nearest_predicate, TreeTypeTraits,
auto values = initialize_values(points, /*delta*/ 0.f);
std::vector<int> offsets = {0, n};

LegacyTree<Tree, APIv1> const tree(ExecutionSpace{}, points);
Tree const tree(ExecutionSpace{}, points);

ARBORX_TEST_QUERY_TREE_CALLBACK(ExecutionSpace{}, tree,
makeNearestQueries<DeviceType>({
Expand Down Expand Up @@ -186,12 +186,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_early_exit, TreeTypeTraits,
using DeviceType = typename TreeTypeTraits::device_type;

auto const tree =
make<Tree, APIv1>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{0., 0., 0.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
{{{2., 2., 2.}}, {{2., 2., 2.}}},
{{{3., 3., 3.}}, {{3., 3., 3.}}},
});
make<Tree>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{0., 0., 0.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
{{{2., 2., 2.}}, {{2., 2., 2.}}},
{{{3., 3., 3.}}, {{3., 3., 3.}}},
});

Kokkos::View<int *, DeviceType> counts("counts", 4);

Expand Down Expand Up @@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_with_attachment_spatial_predicate,
auto values = initialize_values(points, delta);
std::vector<int> offsets = {0, n};

LegacyTree<Tree, APIv1> const tree(ExecutionSpace{}, points);
Tree const tree(ExecutionSpace{}, points);

ARBORX_TEST_QUERY_TREE_CALLBACK(
ExecutionSpace{}, tree,
Expand Down Expand Up @@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(callback_with_attachment_nearest_predicate,
auto values = initialize_values(points, delta);
std::vector<int> offsets = {0, n};

LegacyTree<Tree, APIv1> const tree(ExecutionSpace{}, points);
Tree const tree(ExecutionSpace{}, points);

ARBORX_TEST_QUERY_TREE_CALLBACK(
ExecutionSpace{}, tree,
Expand Down
10 changes: 4 additions & 6 deletions test/tstQueryTreeComparisonWithBoost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ void boost_rtree_nearest_predicate()
auto nearest_queries_host = Kokkos::create_mirror_view(nearest_queries);
Kokkos::deep_copy(nearest_queries_host, nearest_queries);

LegacyTree<Tree, APIv1> tree(
ExecutionSpace{},
Kokkos::create_mirror_view_and_copy(MemorySpace{}, cloud));
Tree tree(ExecutionSpace{},
Kokkos::create_mirror_view_and_copy(MemorySpace{}, cloud));

BoostExt::RTree<decltype(cloud)::value_type> rtree(ExecutionSpace{}, cloud);

Expand Down Expand Up @@ -179,9 +178,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(boost_rtree_spatial_predicate, TreeTypeTraits,
auto intersects_queries_host = Kokkos::create_mirror_view(intersects_queries);
Kokkos::deep_copy(intersects_queries_host, intersects_queries);

LegacyTree<Tree, APIv1> tree(
ExecutionSpace{},
Kokkos::create_mirror_view_and_copy(MemorySpace{}, cloud));
Tree tree(ExecutionSpace{},
Kokkos::create_mirror_view_and_copy(MemorySpace{}, cloud));

BoostExt::RTree<decltype(cloud)::value_type> rtree(ExecutionSpace{}, cloud);

Expand Down
52 changes: 26 additions & 26 deletions test/tstQueryTreeDegenerate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(empty_tree_spatial_predicate, TreeTypeTraits,
Tree value_initialized{};
for (auto const &tree : {
default_initialized, value_initialized,
make<Tree, APIv1>(ExecutionSpace{},
{}), // constructed with empty view of boxes
make<Tree>(ExecutionSpace{},
{}), // constructed with empty view of boxes
})
{
BOOST_TEST(tree.empty());
Expand Down Expand Up @@ -91,8 +91,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(empty_tree_nearest_predicate, TreeTypeTraits,
// tree is empty, it has no leaves.
for (auto const &tree : {
Tree{}, // default constructed
make<Tree, APIv1>(ExecutionSpace{},
{}), // constructed with empty view of boxes
make<Tree>(ExecutionSpace{},
{}), // constructed with empty view of boxes
})
{
BOOST_TEST(tree.empty());
Expand Down Expand Up @@ -130,9 +130,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(single_leaf_tree_spatial_predicate,

// tree has a single leaf (unit box)
auto const tree =
make<Tree, APIv1>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{1., 1., 1.}}},
});
make<Tree>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{1., 1., 1.}}},
});

BOOST_TEST(!tree.empty());
BOOST_TEST(tree.size() == 1);
Expand Down Expand Up @@ -176,9 +176,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(single_leaf_tree_nearest_predicate,

// tree has a single leaf (unit box)
auto const tree =
make<Tree, APIv1>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{1., 1., 1.}}},
});
make<Tree>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{1., 1., 1.}}},
});

BOOST_TEST(!tree.empty());
BOOST_TEST(tree.size() == 1);
Expand Down Expand Up @@ -213,10 +213,10 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(couple_leaves_tree_spatial_predicate,
using DeviceType = typename TreeTypeTraits::device_type;

auto const tree =
make<Tree, APIv1>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{0., 0., 0.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
});
make<Tree>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{0., 0., 0.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
});

BOOST_TEST(!tree.empty());
BOOST_TEST(tree.size() == 2);
Expand Down Expand Up @@ -276,10 +276,10 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(couple_leaves_tree_nearest_predicate,
using DeviceType = typename TreeTypeTraits::device_type;

auto const tree =
make<Tree, APIv1>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{0., 0., 0.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
});
make<Tree>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{0., 0., 0.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
});

BOOST_TEST(!tree.empty());
BOOST_TEST(tree.size() == 2);
Expand Down Expand Up @@ -315,12 +315,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(duplicated_leaves_spatial_predicate,
// at construction had leaves with no parent which yielded a segfault later
// when computing bounding boxes and walking the hierarchy toward the root.
auto const tree =
make<Tree, APIv1>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{0., 0., 0.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
});
make<Tree>(ExecutionSpace{}, {
{{{0., 0., 0.}}, {{0., 0., 0.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
{{{1., 1., 1.}}, {{1., 1., 1.}}},
});

ARBORX_TEST_QUERY_TREE(
ExecutionSpace{}, tree,
Expand Down Expand Up @@ -354,7 +354,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(not_exceeding_stack_capacity_spatial_predicate,
boxes.push_back({{{a, a, a}}, {{b, b, b}}});
}
ExecutionSpace space;
auto const bvh = make<Tree, APIv1>(space, boxes);
auto const bvh = make<Tree>(space, boxes);

Kokkos::View<int *, DeviceType> indices("indices", 0);
Kokkos::View<int *, DeviceType> offset("offset", 0);
Expand Down Expand Up @@ -386,7 +386,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(not_exceeding_stack_capacity_nearest_predicate,
boxes.push_back({{{a, a, a}}, {{b, b, b}}});
}
ExecutionSpace space;
auto const bvh = make<Tree, APIv1>(space, boxes);
auto const bvh = make<Tree>(space, boxes);

Kokkos::View<int *, DeviceType> indices("indices", 0);
Kokkos::View<int *, DeviceType> offset("offset", 0);
Expand Down
2 changes: 1 addition & 1 deletion test/tstQueryTreeManufacturedSolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(structured_grid, TreeTypeTraits,
}
Kokkos::deep_copy(bounding_boxes, bounding_boxes_host);

LegacyTree<Tree, APIv1> const tree(ExecutionSpace{}, bounding_boxes);
Tree const tree(ExecutionSpace{}, bounding_boxes);

std::vector<int> offset_ref(n + 1);
std::vector<int> indices_ref;
Expand Down

0 comments on commit 34d74fc

Please sign in to comment.