Skip to content

Commit

Permalink
Merge pull request #127 from streeve/fix_inplace_reduce
Browse files Browse the repository at this point in the history
Fix MPI error by removing in place reduce in solver
  • Loading branch information
streeve authored Aug 13, 2024
2 parents 95bc551 + 7d252eb commit 661a4a4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/CabanaPD_Solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class SolverElastic
unsigned long long& total_neighbors )
{
auto neigh = *neighbors;
unsigned local_max_neighbors;
unsigned long long local_total_neighbors;
auto neigh_stats = KOKKOS_LAMBDA( const int, unsigned& max_n,
unsigned long long& total_n )
{
Expand All @@ -194,13 +196,13 @@ class SolverElastic
Cabana::NeighborList<neighbor_type>::totalNeighbor( neigh );
};
Kokkos::RangePolicy<exec_space> policy( 0, 1 );
Kokkos::parallel_reduce( policy, neigh_stats, max_neighbors,
total_neighbors );
Kokkos::parallel_reduce( policy, neigh_stats, local_max_neighbors,
local_total_neighbors );
Kokkos::fence();
MPI_Reduce( MPI_IN_PLACE, &max_neighbors, 1, MPI_UNSIGNED, MPI_MAX, 0,
MPI_COMM_WORLD );
MPI_Reduce( MPI_IN_PLACE, &total_neighbors, 1, MPI_UNSIGNED_LONG_LONG,
MPI_SUM, 0, MPI_COMM_WORLD );
MPI_Reduce( &local_max_neighbors, &max_neighbors, 1, MPI_UNSIGNED,
MPI_MAX, 0, MPI_COMM_WORLD );
MPI_Reduce( &local_total_neighbors, &total_neighbors, 1,
MPI_UNSIGNED_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD );
}

void init( const bool initial_output = true )
Expand Down

0 comments on commit 661a4a4

Please sign in to comment.