Skip to content

Commit

Permalink
Remove APIv1 convenience shortcuts from BVH and BruteForce
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Oct 14, 2024
1 parent 805036d commit ce5eb55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 62 deletions.
35 changes: 4 additions & 31 deletions src/spatial/ArborX_BruteForce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,37 +81,10 @@ class BruteForce
using Predicates = Details::AccessValues<UserPredicates, PredicatesTag>;
using Tag = typename Predicates::value_type::Tag;

// Automatically add LegacyDefaultCallback if
// 1. A user does not provide a callback
// 2. The index is constructed on PairValueIndex
// 3. The output value_type is an integral type
constexpr bool use_convenient_shortcut = []() {
if constexpr (!Kokkos::is_view_v<std::decay_t<CallbackOrView>>)
return false;
else if constexpr (!Details::is_pair_value_index_v<value_type>)
return false;
else
return std::is_integral_v<
typename std::decay_t<CallbackOrView>::value_type>;
}();

if constexpr (use_convenient_shortcut)
{
// Simplified way to get APIv1 result using APIv2 interface
Details::CrsGraphWrapperImpl::queryDispatch(
Tag{}, *this, space, Predicates{user_predicates},
Details::LegacyDefaultCallback{}, // inject legacy callback arg
std::forward<CallbackOrView>(callback_or_view),
std::forward<View>(view), std::forward<Args>(args)...);
return;
}
else
{
Details::CrsGraphWrapperImpl::queryDispatch(
Tag{}, *this, space, Predicates{user_predicates},
std::forward<CallbackOrView>(callback_or_view),
std::forward<View>(view), std::forward<Args>(args)...);
}
Details::CrsGraphWrapperImpl::queryDispatch(
Tag{}, *this, space, Predicates{user_predicates},
std::forward<CallbackOrView>(callback_or_view),
std::forward<View>(view), std::forward<Args>(args)...);
}

KOKKOS_FUNCTION auto const &indexable_get() const
Expand Down
35 changes: 4 additions & 31 deletions src/spatial/ArborX_LinearBVH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,37 +103,10 @@ class BoundingVolumeHierarchy
using Predicates = Details::AccessValues<UserPredicates, PredicatesTag>;
using Tag = typename Predicates::value_type::Tag;

// Automatically add LegacyDefaultCallback if
// 1. A user does not provide a callback
// 2. The index is constructed on PairValueIndex
// 3. The output value_type is an integral type
constexpr bool use_convenient_shortcut = []() {
if constexpr (!Kokkos::is_view_v<std::decay_t<CallbackOrView>>)
return false;
else if constexpr (!Details::is_pair_value_index_v<value_type>)
return false;
else
return std::is_integral_v<
typename std::decay_t<CallbackOrView>::value_type>;
}();

if constexpr (use_convenient_shortcut)
{
// Simplified way to get APIv1 result using APIv2 interface
Details::CrsGraphWrapperImpl::queryDispatch(
Tag{}, *this, space, Predicates{user_predicates},
Details::LegacyDefaultCallback{}, // inject legacy callback arg
std::forward<CallbackOrView>(callback_or_view),
std::forward<View>(view), std::forward<Args>(args)...);
return;
}
else
{
Details::CrsGraphWrapperImpl::queryDispatch(
Tag{}, *this, space, Predicates{user_predicates},
std::forward<CallbackOrView>(callback_or_view),
std::forward<View>(view), std::forward<Args>(args)...);
}
Details::CrsGraphWrapperImpl::queryDispatch(
Tag{}, *this, space, Predicates{user_predicates},
std::forward<CallbackOrView>(callback_or_view),
std::forward<View>(view), std::forward<Args>(args)...);
}

template <typename Predicate, typename Callback>
Expand Down

0 comments on commit ce5eb55

Please sign in to comment.