-
Notifications
You must be signed in to change notification settings - Fork 39
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
Refactor space filling curves surrounding code #1180
base: master
Are you sure you want to change the base?
Conversation
If a passed function argument is a prvalue, it will be destroyed once we return, as returning a reference to its member does not extend its lifetime.
template <typename Box, typename Geometry, | ||
std::enable_if_t<GeometryTraits::is_box_v<Box> && | ||
!GeometryTraits::is_point_v<Geometry>> * = nullptr> | ||
template <typename Box, class Geometry> |
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.
Do not mix typename
and class
Kokkos::View<LinearOrderingValueType *, typename Values::memory_space> | ||
linear_ordering_indices( | ||
Kokkos::view_alloc(space, Kokkos::WithoutInitializing, | ||
"ArborX::SpaceFillingCurve::linear_ordering"), | ||
n); |
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 moving the allocation into that function and returning the Morton codes is a good change
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 like it much either. However, our boilerplate code for determining the type of indices is really several lines at every call site.
Alternatively, we could introduce a requirement for a space filling curve to provide index_type
that it will return. It would simplify things a lot.
template <typename ExecutionSpace, typename Values, typename SpaceFillingCurve, | ||
typename Box> | ||
inline auto computeSpaceFillingCurvePermutation(ExecutionSpace const &space, | ||
Values const &values, | ||
SpaceFillingCurve const &curve, | ||
Box const &scene_bounding_box) | ||
{ | ||
auto linear_ordering_indices = | ||
projectOntoSpaceFillingCurve(space, values, curve, scene_bounding_box); | ||
return sortObjects(space, linear_ordering_indices); | ||
} |
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.
Saves little code to bundle two distinct operations.
I am not convinced it is a good idea to introduce it.
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.
That's fair. It does a bit more than that in that it also reduces the amount of used memory as linear_ordering_indices
are deallocated automatically once this function returns. This behavior is similar to the original sortPredicatesAlongSpaceFillingCurve
.
getGeometry
for prvaluesIf a passed function argument is a prvalue, it will be destroyed once we return, as returning a reference to its member does not extend its lifetime.
projectOntoSpaceFillingCurve
fromArborX_TreeConstruction.hpp
toArborX_SpaceFillingCurve.hpp
It will also be used by the tree traversal now
projectOntoSpaceFillingCurve
to return linear orderingThis avoids a lot of boilerplate code to determine the type. We currently have zero benefit from passing indices as the last argument.
computeSpaceFillingCurvePermutation
that combinesprojectOntoSpaceFillingCurve
with sorting to further reduce the amount of codePredicateIndexables
to easily iterate over predicate geometries