Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor DistributedTree to support APIv2 #1017

Merged
merged 7 commits into from
Jan 20, 2024

Conversation

aprokop
Copy link
Contributor

@aprokop aprokop commented Jan 9, 2024

  • Refactor by introducing DistributedTreeBase
  • Update distributed benchmark to take advantage of the new interface

This should also satisfy the requirements for #907, though the interface may be a bit hard to use initially.

I opted to go for the base templated on the bottom tree because all other methods were too intrusive between spatial implementation and wrapping the post callback.

@aprokop aprokop added API User visible interface modifications refactoring Code reorganization labels Jan 9, 2024
@aprokop aprokop mentioned this pull request Jan 9, 2024
Comment on lines +136 to +140
template <typename MemorySpace>
struct CallbackWithDistance<BoundingVolumeHierarchy<
MemorySpace, Details::LegacyDefaultTemplateValue,
Details::DefaultIndexableGetter, ExperimentalHyperGeometry::Box<3, float>>>
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The really bad. Can't get rid of the old legacy thingie just yet, as we cannot get a bounding volume by index.

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 we need both the primary template and that specialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The primary template is based on a general tree, which really means the APIv2 tree. We have access to indexable and values, so don't need to store reverse permutation.

The specialization is for the APIv1 (specified through the default template parameters, including LegacyDefaultTemplateValue). We don't have access to indexable there. Even if we did, the problem is that this callback is wrapped into LegacyCallbackWrapper inside APIv1, so we don't have access to the full PairValueIndex value and can't call indexable on it. So, we have to do the other things.

This is pretty much unavoidable, as we have to use APIv1 BottomTree for APIv1 DistributedTree to be able to work with APIv1 post-callback interface in the distributed setting.

@aprokop aprokop force-pushed the distributed_apiv2_attempt3 branch from 6730eca to 2f0196b Compare January 9, 2024 13:50
int _rank;

template <typename Predicate, typename OutputFunctor>
KOKKOS_FUNCTION void operator()(Predicate const &, int primitive_index,
Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't looked through the rest but my initial reaction is "why is that parameter int and not PairValueIndex?"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it's being used with BVH<MemorySpace> which will do the callback wrapping on its own.

@@ -45,6 +45,8 @@ struct PerThread
namespace Details
{
struct HappyTreeFriends;
template <typename Tree>
struct CallbackWithDistance;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is absurd. Just add an accessor to indexable getter to BVH and BF.
Or add to HappyTreeFriend if you have a good reason to think we should not do so.
FWIW boost::geometry::index::rtree has a indexable_get() member function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I introduced the accessor function. Named it indexable_get() following Boost, but not really a fan of it. Not sure what is a better name. indexable_getter() or indexableGetter()?

Kokkos::is_view<Ranks>{} && Kokkos::is_view<Distances>{}>
typename Ranks>
static std::enable_if_t<Kokkos::is_view<Indices>{} &&
Kokkos::is_view<Offset>{} && Kokkos::is_view<Ranks>{}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Oversight?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oversight of what?

@aprokop
Copy link
Contributor Author

aprokop commented Jan 12, 2024

@dalg24 Please take another look at this one.

Comment on lines +136 to +140
template <typename MemorySpace>
struct CallbackWithDistance<BoundingVolumeHierarchy<
MemorySpace, Details::LegacyDefaultTemplateValue,
Details::DefaultIndexableGetter, ExperimentalHyperGeometry::Box<3, float>>>
{
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 we need both the primary template and that specialization?

@aprokop aprokop merged commit cc58ade into arborx:master Jan 20, 2024
1 check passed
@aprokop aprokop deleted the distributed_apiv2_attempt3 branch January 20, 2024 16:10
@aprokop aprokop mentioned this pull request Jan 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
API User visible interface modifications refactoring Code reorganization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants