Skip to content

Commit

Permalink
mpi_aggregator: don't pass a local variable to MPI_Isend
Browse files Browse the repository at this point in the history
The data passed to MPI_Isend needs to remain available until after
MPI_Wait, so use a class member variable instead.
  • Loading branch information
germasch committed Mar 28, 2019
1 parent 8800c40 commit 9eae640
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
14 changes: 5 additions & 9 deletions source/adios2/toolkit/aggregator/mpi/MPIAggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@ MPIAggregator::IExchangeAbsolutePosition(BufferSTL &bufferSTL, const int step)

if (m_Rank == step)
{
const size_t position = (m_Rank == 0)
? m_SizeSend
: m_SizeSend + bufferSTL.m_AbsolutePosition;

// While the MPI_Isend function should take a const void* as it's first
// argument, some MPICH implementations provide a broken signature
// which takes a non-const first argument. The explicit const_cast
// here works around this.
m_AbsolutePositionSend =
(m_Rank == 0) ? m_SizeSend
: m_SizeSend + bufferSTL.m_AbsolutePosition;

helper::CheckMPIReturn(
MPI_Isend(const_cast<size_t *>(&position), 1, ADIOS2_MPI_SIZE_T,
MPI_Isend(&m_AbsolutePositionSend, 1, ADIOS2_MPI_SIZE_T,
destination, 0, m_Comm, &requests[0]),
", aggregation Isend absolute position at iteration " +
std::to_string(step) + "\n");
Expand Down
1 change: 1 addition & 0 deletions source/adios2/toolkit/aggregator/mpi/MPIAggregator.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class MPIAggregator
int m_ConsumerRank = -1;

size_t m_SizeSend = 0;
size_t m_AbsolutePositionSend;

MPIAggregator();

Expand Down

0 comments on commit 9eae640

Please sign in to comment.