Skip to content
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

Merged
merged 14 commits into from
Oct 2, 2019

Conversation

dalg24
Copy link
Contributor

@dalg24 dalg24 commented Oct 1, 2019

No description provided.

@dalg24 dalg24 force-pushed the access_traits_for_predicates branch from 3f05776 to 087406e Compare October 2, 2019 01:46
@dalg24 dalg24 marked this pull request as ready for review October 2, 2019 01:47
@dalg24
Copy link
Contributor Author

dalg24 commented Oct 2, 2019

This is ready for review.

@aprokop I compared on-node performance with 5589972 and there was no noticeable difference.
I ran 1M values and 100k queries.

@dalg24
Copy link
Contributor Author

dalg24 commented Oct 2, 2019

I updated #107 as an evidence that this compile with non Kokkos view predicates

src/ArborX_LinearBVH.hpp Show resolved Hide resolved
src/details/ArborX_DetailsBatchedQueries.hpp Show resolved Hide resolved

queries =
Details::BatchedQueries<DeviceType>::applyPermutation(permute, queries);
// FIXME readability! queries is a sorted copy of the predicates
Copy link
Contributor

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?

Copy link
Contributor Author

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.

src/details/ArborX_DetailsTags.hpp Show resolved Hide resolved
src/details/ArborX_DetailsTags.hpp Show resolved Hide resolved
Copy link
Contributor

@aprokop aprokop left a 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:

  1. 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?
  2. I'm not sure how Primitives DataAccess interacts with BoxTag and PointTag. 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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Invalid tag for the predicates");
"Invalid tag for the predicates. Tag must be either NearestPredicateTag or SpatialPredicateTag.");

Copy link
Contributor Author

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>()))>;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

@masterleinad masterleinad left a 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
Copy link
Collaborator

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_asserts below sufficient?

Copy link
Contributor Author

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>
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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);
Copy link
Collaborator

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?

Copy link
Contributor Author

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>
Copy link
Collaborator

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?

Copy link
Contributor Author

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>
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@dalg24
Copy link
Contributor Author

dalg24 commented Oct 2, 2019

Overall, it looks really good. There are two points I want to bring up:

  1. 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?
  2. I'm not sure how Primitives DataAccess interacts with BoxTag and PointTag. Am I correct in understanding that the current approach does not allow for the fine search to be implemented at the same time?
  1. What other terminology would you like to suggest?
  2. Not necessarily. Storing user geometries instead of boxes in the leaf nodes would require non trivial changes so the geometry tag needed at construction is not a big concern at the moment. I would approach the fine search problem by "piggy packing" some work when collision are found. My current thinking is I will solve it via some new access traits for the results, with a specialization for a new second template argument ResultsTag.

@masterleinad masterleinad merged commit c510eac into arborx:master Oct 2, 2019
@dalg24 dalg24 deleted the access_traits_for_predicates branch October 2, 2019 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants