Skip to content

Commit

Permalink
Merge pull request #1155 from aprokop/arborx-2.0-no-apiv1-bruteforce
Browse files Browse the repository at this point in the history
Remove APIv1 for BruteForce
  • Loading branch information
aprokop authored Sep 22, 2024
2 parents 59a4cdd + f304a93 commit b9985cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 90 deletions.
3 changes: 2 additions & 1 deletion examples/brute_force/example_brute_force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ int main(int argc, char *argv[])
}

{
ArborX::BruteForce<MemorySpace> brute{space, primitives};
ArborX::BruteForce<MemorySpace, ArborX::PairValueIndex<ArborX::Point<3>>>
brute{space, ArborX::Experimental::attach_indices(primitives)};

Kokkos::View<int *, ExecutionSpace> indices("Example::indices", 0);
Kokkos::View<int *, ExecutionSpace> offset("Example::offset", 0);
Expand Down
93 changes: 7 additions & 86 deletions src/ArborX_BruteForce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
namespace ArborX
{

template <
typename MemorySpace, typename Value = Details::LegacyDefaultTemplateValue,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume =
Box<GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type_t<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>>>
template <typename MemorySpace, typename Value,
typename IndexableGetter = Details::DefaultIndexableGetter,
typename BoundingVolume = Box<
GeometryTraits::dimension_v<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>,
typename GeometryTraits::coordinate_type_t<
std::decay_t<std::invoke_result_t<IndexableGetter, Value>>>>>
class BruteForce
{
public:
Expand Down Expand Up @@ -127,84 +126,6 @@ class BruteForce
IndexableGetter _indexable_getter;
};

template <typename MemorySpace>
class BruteForce<MemorySpace, Details::LegacyDefaultTemplateValue,
Details::DefaultIndexableGetter, Box<3, float>>
: public BruteForce<MemorySpace, PairValueIndex<Box<3, float>>,
Details::DefaultIndexableGetter, Box<3, float>>
{
using base_type = BruteForce<MemorySpace, PairValueIndex<Box<3, float>>,
Details::DefaultIndexableGetter, Box<3, float>>;

public:
using bounding_volume_type = typename base_type::bounding_volume_type;

BruteForce() = default;

template <typename ExecutionSpace, typename Primitives>
BruteForce(ExecutionSpace const &space, Primitives const &primitives)
: base_type(
space,
// Validate the primitives before calling the base constructor
(Details::check_valid_access_traits(PrimitivesTag{}, primitives),
Details::LegacyValues<Primitives, bounding_volume_type>{
primitives}),
Details::DefaultIndexableGetter())
{}

template <typename ExecutionSpace, typename Predicates, typename Callback,
typename Ignore = int>
void query(ExecutionSpace const &space, Predicates const &predicates,
Callback const &callback, Ignore = Ignore()) const
{
Details::check_valid_callback<int>(callback, predicates);
base_type::query(space, predicates,
Details::LegacyCallbackWrapper<Callback>{callback});
}

template <typename ExecutionSpace, typename Predicates, typename View,
typename... Args>
std::enable_if_t<Kokkos::is_view_v<std::decay_t<View>>>
query(ExecutionSpace const &space, Predicates const &predicates, View &&view,
Args &&...args) const
{
base_type::query(space, predicates, Details::LegacyDefaultCallback{},
std::forward<View>(view), std::forward<Args>(args)...);
}

template <typename ExecutionSpace, typename Predicates, typename Callback,
typename OutputView, typename OffsetView, typename... Args>
std::enable_if_t<!Kokkos::is_view_v<std::decay_t<Callback>>>
query(ExecutionSpace const &space, Predicates const &predicates,
Callback &&callback, OutputView &&out, OffsetView &&offset,
Args &&...args) const
{
if constexpr (!Details::is_tagged_post_callback<
std::decay_t<Callback>>::value)
{
Details::check_valid_callback<int>(callback, predicates, out);
base_type::query(space, predicates,
Details::LegacyCallbackWrapper<std::decay_t<Callback>>{
std::forward<Callback>(callback)},
std::forward<OutputView>(out),
std::forward<OffsetView>(offset),
std::forward<Args>(args)...);
}
else
{
Kokkos::Profiling::ScopedRegion guard("ArborX::BruteForce::query_crs");

Kokkos::View<int *, MemorySpace> indices(
"ArborX::CrsGraphWrapper::query::indices", 0);
base_type::query(space, predicates, Details::LegacyDefaultCallback{},
indices, std::forward<OffsetView>(offset),
std::forward<Args>(args)...);
callback(predicates, std::forward<OffsetView>(offset), indices,
std::forward<OutputView>(out));
}
}
};

template <typename MemorySpace, typename Value, typename IndexableGetter,
typename BoundingVolume>
template <typename ExecutionSpace, typename UserValues>
Expand Down
4 changes: 1 addition & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,11 @@ foreach(_test Callbacks Degenerate ManufacturedSolution ComparisonWithBoost)
"#include <ArborX_Box.hpp>\n"
"#include \"ArborXTest_LegacyTree.hpp\"\n"
"template <class MemorySpace>\n"
"using ArborX_BruteForce_Box = ArborX::BruteForce<MemorySpace>;\n"
"template <class MemorySpace>\n"
"using ArborX_Legacy_BruteForce_Box =\n"
" LegacyTree<ArborX::BruteForce<\n"
" MemorySpace, ArborX::PairValueIndex<ArborX::Box<3, float>>,\n"
" ArborX::Details::DefaultIndexableGetter, ArborX::Box<3, float>>>;\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX_BruteForce_Box, ArborX_Legacy_BruteForce_Box>\n"
"#define ARBORX_TEST_TREE_TYPES Tuple<ArborX_Legacy_BruteForce_Box>\n"
"#define ARBORX_TEST_DEVICE_TYPES std::tuple<${ARBORX_DEVICE_TYPES}>\n"
"#define ARBORX_TEST_DISABLE_CALLBACK_EARLY_EXIT\n"
"#include <tstQueryTree${_test}.cpp>\n"
Expand Down

0 comments on commit b9985cc

Please sign in to comment.