@@ -698,13 +698,25 @@ DistributedTreeImpl<DeviceType>::queryDispatch(
698698 Kokkos::View<int *, ExecutionSpace> ranks (
699699 " ArborX::DistributedTree::query::nearest::ranks" , 0 );
700700
701- // First find the ranks and indices for the nearest queries.
701+ // The strategy for executing the callback only for the primitives that are
702+ // closest for every predicate is as follows:
703+ // - Find the ranks and indices for the nearest queries using the overload not
704+ // taking a callback.
705+ // - Send the predicate-primitive pairs to the process where the match was
706+ // found.
707+ // - Execute the callback on the process owning the primitives.
708+ // - Send the result back to the process owning the predicates.
709+
710+ // Find the ranks and indices for the nearest queries using the overload not
711+ // taking a callback.
702712 queryDispatchImpl (NearestPredicateTag{}, tree, space, queries, indices,
703713 offset, ranks);
704714
705715 Kokkos::Profiling::pushRegion (
706716 " ArborX::DistributedTree::query::nearest::postprocess_callback" );
707717
718+ // Send the predicate-primitive pairs to the process where the match was
719+ // found.
708720 auto comm = tree.getComm ();
709721 int comm_rank;
710722 MPI_Comm_rank (comm, &comm_rank);
@@ -740,7 +752,7 @@ DistributedTreeImpl<DeviceType>::queryDispatch(
740752 sendAcrossNetwork (space, distributor, exported_queries_with_indices,
741753 imported_queries_with_indices);
742754
743- // execute imported queries
755+ // Execute the callback on the process owning the primitives.
744756 OutputView remote_out (
745757 Kokkos::view_alloc (space, Kokkos::WithoutInitializing,
746758 " ArborX::DistributedTree::query::remote_out" ),
@@ -759,7 +771,7 @@ DistributedTreeImpl<DeviceType>::queryDispatch(
759771 });
760772 });
761773
762- // communicate results back to the source MPI ranks
774+ // Send the result back to the process owning the predicates.
763775 Distributor<DeviceType> back_distributor (comm);
764776 auto const &dest = distributor.get_sources ();
765777 auto const &off = distributor.get_source_offsets ();
0 commit comments