Skip to content

Commit

Permalink
helper: Replace implicit Comm conversion to MPI with explicit Comm::A…
Browse files Browse the repository at this point in the history
…sMPI
  • Loading branch information
bradking committed Aug 26, 2019
1 parent f5357b4 commit 3f711df
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion source/adios2/core/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ Engine &IO::Open(const std::string &name, const Mode mode, MPI_Comm mpiComm)

Engine &IO::Open(const std::string &name, const Mode mode)
{
return Open(name, mode, m_ADIOS.GetComm());
return Open(name, mode, m_ADIOS.GetComm().AsMPI());
}

Engine &IO::GetEngine(const std::string &name)
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/engine/dataspaces/DataSpacesReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ DataSpacesReader::DataSpacesReader(IO &io, const std::string &name,
{
m_ProvideLatest = false;
}
MPI_Comm mpiComm = m_Comm;
MPI_Comm mpiComm = m_Comm.AsMPI();
ret = adios_read_dataspaces_init(&mpiComm, &m_data);
if (ret < 0)
{
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/engine/dataspaces/DataSpacesWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ DataSpacesWriter::DataSpacesWriter(IO &io, const std::string &name,
{
m_data.appid = 0;
}
MPI_Comm mpiComm = m_Comm;
MPI_Comm mpiComm = m_Comm.AsMPI();
ret = adios_dataspaces_init(&mpiComm, &m_data);
if (ret < 0)
fprintf(stderr, "Unable to connect to DataSpaces. Err: %d\n", ret);
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/engine/hdf5/HDF5ReaderP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void HDF5ReaderP::Init()
", in call to Open\n");
}

m_H5File.Init(m_Name, m_Comm, false);
m_H5File.Init(m_Name, m_Comm.AsMPI(), false);
m_H5File.ParseParameters(m_IO);

/*
Expand Down
6 changes: 3 additions & 3 deletions source/adios2/engine/hdf5/HDF5WriterP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void HDF5WriterP::Init()
}

#ifdef NEVER
m_H5File.Init(m_Name, m_Comm, true);
m_H5File.Init(m_Name, m_Comm.AsMPI(), true);
#else
// enforce .h5 ending
std::string suffix = ".h5";
Expand All @@ -71,11 +71,11 @@ void HDF5WriterP::Init()
{
// is a file with .bp ending
std::string updatedName = m_Name.substr(0, wpos) + suffix;
m_H5File.Init(updatedName, m_Comm, true);
m_H5File.Init(updatedName, m_Comm.AsMPI(), true);
}
else
{
m_H5File.Init(m_Name, m_Comm, true);
m_H5File.Init(m_Name, m_Comm.AsMPI(), true);
}
m_H5File.ParseParameters(m_IO);
#endif
Expand Down
3 changes: 2 additions & 1 deletion source/adios2/engine/insitumpi/InSituMPIReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ InSituMPIReader::InSituMPIReader(IO &io, const std::string &name,
m_EndMessage = " in call to IO Open InSituMPIReader " + m_Name + "\n";
Init();

m_RankAllPeers = insitumpi::FindPeers(m_Comm, m_Name, false, m_CommWorld);
m_RankAllPeers =
insitumpi::FindPeers(m_Comm.AsMPI(), m_Name, false, m_CommWorld);
MPI_Comm_rank(m_CommWorld, &m_GlobalRank);
MPI_Comm_size(m_CommWorld, &m_GlobalNproc);
m_ReaderRank = m_Comm.Rank();
Expand Down
3 changes: 2 additions & 1 deletion source/adios2/engine/insitumpi/InSituMPIWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ InSituMPIWriter::InSituMPIWriter(IO &io, const std::string &name,
Init();
m_BP3Serializer.InitParameters(m_IO.m_Parameters);

m_RankAllPeers = insitumpi::FindPeers(m_Comm, m_Name, true, m_CommWorld);
m_RankAllPeers =
insitumpi::FindPeers(m_Comm.AsMPI(), m_Name, true, m_CommWorld);
for (int i = 0; i < m_RankAllPeers.size(); i++)
{
m_RankToPeerID[m_RankAllPeers[i]] = i;
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/engine/sst/SstReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SstReader::SstReader(IO &io, const std::string &name, const Mode mode,

Init();

m_Input = SstReaderOpen(cstr, &Params, m_Comm);
m_Input = SstReaderOpen(cstr, &Params, m_Comm.AsMPI());
if (!m_Input)
{
throw std::runtime_error(
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/engine/sst/SstWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ SstWriter::SstWriter(IO &io, const std::string &name, const Mode mode,

Init();

m_Output = SstWriterOpen(name.c_str(), &Params, m_Comm);
m_Output = SstWriterOpen(name.c_str(), &Params, m_Comm.AsMPI());

if (m_MarshalMethod == SstMarshalBP)
{
Expand Down
7 changes: 4 additions & 3 deletions source/adios2/helper/adiosComm.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ class Comm
*/
void swap(Comm &comm);

// FIXME: Remove conversion after clients transition to encapsulation.
/** Convert to a concrete MPI communicator. */
operator MPI_Comm() const { return m_MPIComm; }
/**
* @brief Get the underlying raw MPI communicator.
*/
MPI_Comm AsMPI() const { return m_MPIComm; }

/**
* @brief Create a communicator by duplicating a MPI communicator.
Expand Down

0 comments on commit 3f711df

Please sign in to comment.