-
Notifications
You must be signed in to change notification settings - Fork 41
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
Access traits for predicates #117
Access traits for predicates #117
Conversation
3f05776
to
087406e
Compare
I updated #107 as an evidence that this compile with non Kokkos view predicates |
|
||
queries = | ||
Details::BatchedQueries<DeviceType>::applyPermutation(permute, queries); | ||
// FIXME readability! queries is a sorted copy of the 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.
What is the readability issue here?
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.
Function argument is predicates
and it is some unspecified type that is only required to have a valid matching specialization of the access traits and bam next line I create queries
which is a Kokkos view and keep going as before.
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.
Overall, it looks really good. There are two points I want to bring up:
- The words predicates and primitives are really hard for me. It always takes me several seconds to remember what they are, so personally I would prefer something simpler. Am I the only one with this issue?
- I'm not sure how
Primitives
DataAccess
interacts withBoxTag
andPointTag
. Am I correct in understanding that the current approach does not allow for the fine search to be implemented at the same time?
typename Details::TagHelper<Predicates, Traits::PredicatesTag>::type; | ||
static_assert(std::is_same<Tag, Details::NearestPredicateTag>::value || | ||
std::is_same<Tag, Details::SpatialPredicateTag>::value, | ||
"Invalid tag for the 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.
"Invalid tag for the predicates"); | |
"Invalid tag for the predicates. Tag must be either NearestPredicateTag or SpatialPredicateTag."); |
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.
Won't fix. Will be superseded by #113
private: | ||
using accessor_return_type = | ||
std::decay_t<decltype(Traits::Access<T, TTag>::get( | ||
std::declval<T const &>(), std::declval<int>()))>; |
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.
Why do you need the second declval
?
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.
Could probably replace with an integer but the second argument is needed because get
takes two params.
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.
Looks overall OK, but I have some questions below.
// FIXME lame placeholder for concept check | ||
static_assert(Kokkos::is_view<Predicates>::value, "must pass a view"); | ||
using Tag = typename Predicates::value_type::Tag; | ||
// FIXME placeholder for concept check |
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.
What else would you want to check here? Aren't the static_assert
s below sufficient?
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.
See #113
Would check that matching specialization exist, that it has the proper size()
and get()
static member functions, the memory_space
member type, that the tag can be deduced for the dispatch, etc.
Without it the user gets error messages that are very hard to parse.
@@ -36,6 +36,19 @@ namespace ArborX | |||
{ | |||
namespace Details | |||
{ | |||
|
|||
template <typename T, typename TTag> |
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.
Please put some documentation here. Basically, TagHelper::type
can be used for SFINAE ensuring that the Access
specialization implements the required get
interface (returning a registered Tag
, without user speciallization Point
or Box
, or any type that has a Tag
alias). TagHelper::type
then contains a Tag
for that return type.
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 that's not what this is for. It is there to deduce the tag from the return type of the get()
access traits.
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.
... which is what I said in the last sentence.
Details::BatchedQueries<DeviceType>::applyPermutation(permute, queries); | ||
// FIXME readability! queries is a sorted copy of the predicates | ||
auto queries = Details::BatchedQueries<DeviceType>::applyPermutation( | ||
permute, 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.
So this doesn't impact performance?
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.
This does not change the algorithm and the choices that were previously done, which was to make a sorted copy of the queries/predicates instead of accessing with indirection. I had also explored populating the results in permuted order and reverse the permutation at the end but that was slower.
We can try to not make a copy (i.e. drop queries
) and do Access::get(predicates, permute(i))
but I don't want to explore this in this PR. Also I am pretty sure I had explored that option back then.
@@ -28,7 +28,7 @@ struct BoxTag | |||
{ | |||
}; | |||
|
|||
template <typename Geometry> | |||
template <typename T, typename Enable = void> |
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.
Wouldn't it make sense to separate geometry tags and predicate tags? Is there any function that is supposed to handle both?
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.
And put them what header instead? This is good enough.
@@ -45,6 +45,12 @@ struct Tag<Box> | |||
using type = BoxTag; | |||
}; | |||
|
|||
template <typename T> | |||
struct Tag<T> |
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.
Hmm... It looks a little bit weird to treat Point
and Box
separately here. I would be happier if Point
and Box
would also have a Tag
alias and we would not have to specialize here.
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.
Not going to happen here.
|
No description provided.