Skip to content

Commit

Permalink
avoid global_mpi_rank
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Aug 31, 2022
1 parent 3e6b3e3 commit 018c7ca
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions examples/distributed_tree/distributed_intersects_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@
using ExecutionSpace = Kokkos::DefaultExecutionSpace;
using MemorySpace = ExecutionSpace::memory_space;

int global_mpi_rank;

namespace Example
{
template <class Points>
struct Intersects
{
Points points;
float radius;
int mpi_rank;
};
template <class Points>
Intersects(Points const &, int) -> Intersects<Points>;
Intersects(Points const &, float, int) -> Intersects<Points>;

struct IndexAndRank
{
Expand Down Expand Up @@ -83,7 +82,7 @@ struct ArborX::AccessTraits<Example::Intersects<Points>, ArborX::PredicatesTag>
static KOKKOS_FUNCTION auto get(Example::Intersects<Points> const &x, int i)
{
return attach(ArborX::intersects(ArborX::Sphere(x.points(i), x.radius)),
Example::IndexAndRank{i, global_mpi_rank});
Example::IndexAndRank{i, x.mpi_rank});
}
using memory_space = MemorySpace;
};
Expand All @@ -96,7 +95,6 @@ int main(int argc, char *argv[])
MPI_Comm comm = MPI_COMM_WORLD;
int comm_rank;
MPI_Comm_rank(comm, &comm_rank);
global_mpi_rank = comm_rank;
int comm_size;
MPI_Comm_size(comm, &comm_size);
ArborX::Point lower_left_corner = {static_cast<float>(comm_rank),
Expand All @@ -117,7 +115,7 @@ int main(int argc, char *argv[])
Kokkos::View<Example::IndexAndRank *, MemorySpace> values("values", 0);
Kokkos::View<int *, MemorySpace> offsets("offsets", 0);
tree.query(
exec, Example::Intersects{points_device, 1.},
exec, Example::Intersects{points_device, 1., comm_rank},
Example::InlinePrintCallback<MemorySpace>(points_device, comm_rank),
values, offsets);

Expand Down

0 comments on commit 018c7ca

Please sign in to comment.