@@ -704,13 +704,25 @@ DistributedTreeImpl<DeviceType>::queryDispatch(
704704 Kokkos::View<int *, ExecutionSpace> ranks (
705705 " ArborX::DistributedTree::query::nearest::ranks" , 0 );
706706
707- // First find the ranks and indices for the nearest queries.
707+ // The strategy for executing the callback only for the primitives that are
708+ // closest for every predicate is as follows:
709+ // - Find the ranks and indices for the nearest queries using the overload not
710+ // taking a callback.
711+ // - Send the predicate-primitive pairs to the process where the match was
712+ // found.
713+ // - Execute the callback on the process owning the primitives.
714+ // - Send the result back to the process owning the predicates.
715+
716+ // Find the ranks and indices for the nearest queries using the overload not
717+ // taking a callback.
708718 queryDispatchImpl (NearestPredicateTag{}, tree, space, queries, indices,
709719 offset, ranks);
710720
711721 Kokkos::Profiling::pushRegion (
712722 " ArborX::DistributedTree::query::nearest::postprocess_callback" );
713723
724+ // Send the predicate-primitive pairs to the process where the match was
725+ // found.
714726 auto comm = tree.getComm ();
715727 int comm_rank;
716728 MPI_Comm_rank (comm, &comm_rank);
@@ -746,7 +758,7 @@ DistributedTreeImpl<DeviceType>::queryDispatch(
746758 sendAcrossNetwork (space, distributor, exported_queries_with_indices,
747759 imported_queries_with_indices);
748760
749- // execute imported queries
761+ // Execute the callback on the process owning the primitives.
750762 OutputView remote_out (
751763 Kokkos::view_alloc (space, Kokkos::WithoutInitializing,
752764 " ArborX::DistributedTree::query::remote_out" ),
@@ -765,7 +777,7 @@ DistributedTreeImpl<DeviceType>::queryDispatch(
765777 });
766778 });
767779
768- // communicate results back to the source MPI ranks
780+ // Send the result back to the process owning the predicates.
769781 Distributor<DeviceType> back_distributor (comm);
770782 auto const &dest = distributor.get_sources ();
771783 auto const &off = distributor.get_source_offsets ();
0 commit comments