Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Use MPI_IN_PLACE #3428

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Src/Base/AMReX_ParallelReduce.H
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ namespace detail {
inline void Reduce (ReduceOp op, T* v, int cnt, int root, MPI_Comm comm)
{
auto mpi_op = mpi_ops[static_cast<int>(op)]; // NOLINT
Vector<T> tmp(v, v+cnt);
if (root == -1) {
// TODO: add BL_COMM_PROFILE commands
MPI_Allreduce(tmp.data(), v, cnt, ParallelDescriptor::Mpi_typemap<T>::type(),
MPI_Allreduce(MPI_IN_PLACE, v, cnt, ParallelDescriptor::Mpi_typemap<T>::type(),
mpi_op, comm);
} else {
// TODO: add BL_COMM_PROFILE commands
MPI_Reduce(tmp.data(), v, cnt, ParallelDescriptor::Mpi_typemap<T>::type(),
const auto* sendbuf = (ParallelDescriptor::MyProc(comm) == root) ?
(void const*)(MPI_IN_PLACE) : (void const*) v;
MPI_Reduce(sendbuf, v, cnt, ParallelDescriptor::Mpi_typemap<T>::type(),
mpi_op, root, comm);
}
}
Expand Down
Loading