-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APIv2: change signature of the 3-argument callback #965
Conversation
src/ArborX_BruteForce.hpp
Outdated
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::forward<Callback>(callback)}, | ||
std::forward<OutputView>(out), std::forward<OffsetView>(offset), | ||
std::forward<Args>(args)...); | ||
} | ||
else | ||
{ | ||
KokkosExt::ScopedProfileRegion guard("ArborX::BruteForce::query_crs"); | ||
|
||
Kokkos::View<int *, MemorySpace> indices( | ||
"ArborX::CrsGraphWrapper::query::indices", 0); | ||
base_type::query(space, predicates, Details::DefaultLegacyCallback{}, | ||
indices, std::forward<OffsetView>(offset), | ||
std::forward<Args>(args)...); | ||
callback(predicates, std::forward<OffsetView>(offset), indices, | ||
std::forward<OutputView>(out)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the calls for the legacy classes out of CrsGraphImpl
. The reason being is that the call stack was too complicated to figure out from within CrsGraphImpl
when to wrap and when not to. Moving out made things doable.
The downside is that it had to be repeated in both BruteForce
and Testing::LegacyTree
. I think it's ok.
@@ -172,23 +170,52 @@ class BoundingVolumeHierarchy | |||
Experimental::TraversalPolicy const &policy = | |||
Experimental::TraversalPolicy()) const | |||
{ | |||
Details::check_valid_callback<int>(callback, predicates); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by change
@@ -123,21 +121,51 @@ class BruteForce | |||
void query(ExecutionSpace const &space, Predicates const &predicates, | |||
Callback const &callback, Ignore = Ignore()) const | |||
{ | |||
Details::check_valid_callback<int>(callback, predicates); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by change
cc0b025
to
a1e0d71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor comments
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in that case the Args
template parameter pack is really just an "optional tree traversal policy" right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
} | ||
else | ||
{ | ||
KokkosExt::ScopedProfileRegion guard("ArborX::BVH::query_crs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we changing the stack of regions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This one does not go through the base class, so we have to add it here to retain the original stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yuk. Not sure if that is worth a comment to keep them in sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that is important. We don't guarantee anything about profiling regions stacks. As long as we name them somewhat related, it should be fine.
Callback &&callback, OutputView &&out, OffsetView &&offset, | ||
Args &&...args) const | ||
{ | ||
if constexpr (!Details::is_tagged_post_callback< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just observing that we have this pattern 3x (BF, BVH, and LegacyTree)
Not sure whether we should/could abstract it away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it would be nicer to forward the callback
} | ||
else | ||
{ | ||
KokkosExt::ScopedProfileRegion guard("ArborX::BVH::query_crs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yuk. Not sure if that is worth a comment to keep them in sync.
a17940e
to
ac7b15d
Compare
ac7b15d
to
45ab513
Compare
Change the signature of the callback: