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

Encapsulate multi-process communication (part 2) #1817

Merged
merged 34 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7e9cbb9
mpidummy: Add MPI_OP_NULL constant
bradking Oct 4, 2019
c0bfedb
Add missing includes of ADIOSMPI.h in places that use MPI directly
bradking Sep 19, 2019
3234c58
Remove unused ADIOSMPI.h includes
bradking Sep 13, 2019
9160f88
helper: Encapsulate MPI_Gatherv as Comm::Gatherv
bradking Sep 4, 2019
4bd86ba
helper: Implement Comm::GatherArrays in terms of our encapsulation
bradking Sep 4, 2019
fff4435
helper: Implement Comm::GatherValues in terms of our encapsulation
bradking Sep 4, 2019
8b14d29
helper: Implement Comm::GathervVectors in terms of our encapsulation
bradking Sep 4, 2019
14edaa4
helper: Implement Comm::AllGatherArrays in terms of our encapsulation
bradking Sep 4, 2019
81e1cba
helper: Implement Comm::AllGatherValues in terms of our encapsulation
bradking Sep 4, 2019
c7f0d71
helper: Implement Comm::ReduceValues in terms of our encapsulation
bradking Sep 4, 2019
8ab36c2
helper: Implement Comm::BroadcastValue in terms of our encapsulation
bradking Sep 4, 2019
c88c1a8
helper: Implement Comm::BroadcastVector in terms of our encapsulation
bradking Sep 4, 2019
4afe40d
helper: Implement Comm::BroadcastFile in terms of our encapsulation
bradking Sep 12, 2019
1c62294
helper: Move Comm::BroadcastFile to after MPI-specific methods
bradking Sep 12, 2019
3371561
helper: Factor out MPI-specific Comm interfaces
bradking Sep 12, 2019
2b39dfa
helper: Move Comm MPI implementation behind an abstraction
bradking Sep 12, 2019
e5db85b
helper: Drop unused Comm::AllGatherArrays method
bradking Sep 12, 2019
a1b5a40
helper: Move private GetGathervDisplacements into Comm
bradking Sep 12, 2019
9304548
helper: Generalize Comm::GathervArrays implementation
bradking Sep 12, 2019
6fc159c
helper: Generalize Comm::GatherArrays implementation
bradking Sep 12, 2019
d58189d
helper: Generalize Comm::ReduceValues implementation
bradking Sep 12, 2019
0a21623
helper: Generalize Comm::BroadcastValue implementation
bradking Sep 12, 2019
ccdc084
helper: Generalize Comm::BroadcastVector implementation
bradking Sep 12, 2019
c85b97b
helper: Encapsulate MPI_Op as Comm::Op
bradking Sep 13, 2019
4e76dbc
helper: Encapsulate MPI_Datatype as CommImpl::Datatype
bradking Sep 13, 2019
e5adee0
helper: Add internal data type size table to Comm
bradking Sep 16, 2019
f3df8de
helper: Encapsulate MPI_Comm_dup as Comm::Duplicate
bradking Sep 16, 2019
06ab278
helper: Encapsulate MPI_COMM_WORLD as Comm::World
bradking Sep 20, 2019
f5939f9
engine: Port HDF5 engines to Comm encapsulation
bradking Oct 4, 2019
c3991a2
utils: Clarify adios_reorganize Reorganize class member names
bradking Sep 19, 2019
554a756
utils: Port adios_reorganize to Comm encapsulation
bradking Sep 19, 2019
41219da
helper: Add dummy Comm implementation
bradking Oct 7, 2019
8989123
core: Replace MPI with Comm in ADIOS, IO, and Stream interfaces
bradking Oct 7, 2019
c47c2b9
helper: Port Comm MPI backend away from SMPI_ wrappers
bradking Sep 20, 2019
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
8 changes: 6 additions & 2 deletions bindings/C/adios2/c/adios2_c_adios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@

#include "adios2_c_adios.h"

#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/ADIOS.h"
#include "adios2/helper/adiosFunctions.h"

#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -35,7 +38,8 @@ adios2_adios *adios2_init_config_glue(const char *config_file, MPI_Comm comm,
const bool debugBool =
(debug_mode == adios2_debug_mode_on) ? true : false;
adios = reinterpret_cast<adios2_adios *>(new adios2::core::ADIOS(
config_file, comm, debugBool, host_language));
config_file, adios2::helper::CommFromMPI(comm), debugBool,
host_language));
}
catch (...)
{
Expand Down
8 changes: 6 additions & 2 deletions bindings/C/adios2/c/adios2_c_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

#include <vector>

#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/IO.h"
#include "adios2/helper/adiosFunctions.h" //GetType<T>
#include "adios2_c_internal.h"

#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -729,7 +732,8 @@ adios2_engine *adios2_open_new_comm(adios2_io *io, const char *name,
io, "for adios2_io, in call to adios2_open");
engine = reinterpret_cast<adios2_engine *>(
&reinterpret_cast<adios2::core::IO *>(io)->Open(
name, adios2_ToOpenMode(mode), comm));
name, adios2_ToOpenMode(mode),
adios2::helper::CommFromMPI(comm)));
}
catch (...)
{
Expand Down
8 changes: 6 additions & 2 deletions bindings/CXX11/adios2/cxx11/ADIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@

#include "ADIOS.h"

#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/ADIOS.h"
#include "adios2/core/IO.h"
#include "adios2/helper/adiosFunctions.h" //CheckForNullptr

#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif

namespace adios2
{
#ifdef ADIOS2_HAVE_MPI
ADIOS::ADIOS(const std::string &configFile, MPI_Comm comm, const bool debugMode)
: m_ADIOS(std::make_shared<core::ADIOS>(configFile, comm, debugMode, "C++"))
: m_ADIOS(std::make_shared<core::ADIOS>(configFile, helper::CommFromMPI(comm),
debugMode, "C++"))
{
}

Expand Down
7 changes: 5 additions & 2 deletions bindings/CXX11/adios2/cxx11/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
#include "IO.h"
#include "IO.tcc"

#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/IO.h"

#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif

namespace adios2
{

Expand Down Expand Up @@ -109,7 +112,7 @@ Engine IO::Open(const std::string &name, const Mode mode, MPI_Comm comm)
{
helper::CheckForNullptr(m_IO,
"for engine " + name + ", in call to IO::Open");
return Engine(&m_IO->Open(name, mode, comm));
return Engine(&m_IO->Open(name, mode, helper::CommFromMPI(comm)));
}
#endif

Expand Down
18 changes: 11 additions & 7 deletions bindings/CXX11/adios2/cxx11/fstream/ADIOS2fstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@
#include "ADIOS2fstream.h"
#include "ADIOS2fstream.tcc"

#include "adios2/common/ADIOSMPI.h"
#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif

namespace adios2
{

#ifdef ADIOS2_HAVE_MPI
fstream::fstream(const std::string &name, const openmode mode, MPI_Comm comm,
const std::string engineType)
: m_Stream(std::make_shared<core::Stream>(name, ToMode(mode), comm, engineType,
"C++"))
: m_Stream(std::make_shared<core::Stream>(
name, ToMode(mode), helper::CommFromMPI(comm), engineType, "C++"))
{
}

fstream::fstream(const std::string &name, const openmode mode, MPI_Comm comm,
const std::string &configFile,
const std::string ioInConfigFile)
: m_Stream(std::make_shared<core::Stream>(name, ToMode(mode), comm, configFile,
: m_Stream(std::make_shared<core::Stream>(name, ToMode(mode),
helper::CommFromMPI(comm), configFile,
ioInConfigFile, "C++"))
{
}
Expand All @@ -54,8 +57,8 @@ void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm,
const std::string engineType)
{
CheckOpen(name);
m_Stream = std::make_shared<core::Stream>(name, ToMode(mode), comm,
engineType, "C++");
m_Stream = std::make_shared<core::Stream>(
name, ToMode(mode), helper::CommFromMPI(comm), engineType, "C++");
}

void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm,
Expand All @@ -64,7 +67,8 @@ void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm,
{
CheckOpen(name);
m_Stream = std::make_shared<core::Stream>(
name, ToMode(mode), comm, configFile, ioInConfigFile, "C++");
name, ToMode(mode), helper::CommFromMPI(comm), configFile,
ioInConfigFile, "C++");
}
#else
void fstream::open(const std::string &name, const openmode mode,
Expand Down
8 changes: 5 additions & 3 deletions bindings/Python/py11ADIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

#include "py11ADIOS.h"

#include "adios2/common/ADIOSMPI.h"
#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif

namespace adios2
{
Expand All @@ -20,8 +22,8 @@ namespace py11
#ifdef ADIOS2_HAVE_MPI
ADIOS::ADIOS(const std::string &configFile, MPI4PY_Comm mpiComm,
const bool debugMode)
: m_ADIOS(std::make_shared<adios2::core::ADIOS>(configFile, mpiComm, debugMode,
"Python"))
: m_ADIOS(std::make_shared<adios2::core::ADIOS>(
configFile, helper::CommFromMPI(mpiComm), debugMode, "Python"))
{
}

Expand Down
22 changes: 16 additions & 6 deletions bindings/Python/py11File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,52 @@
#include <algorithm>
#include <iostream>

#include "adios2/common/ADIOSMPI.h"
#include "adios2/common/ADIOSMacros.h"
#include "adios2/helper/adiosCommDummy.h"
#include "adios2/helper/adiosFunctions.h"

#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif

#include "py11types.h"

namespace adios2
{
namespace py11
{

#ifdef ADIOS2_HAVE_MPI
File::File(const std::string &name, const std::string mode, MPI_Comm comm,
const std::string engineType)
: m_Name(name), m_Mode(mode),
m_Stream(std::make_shared<core::Stream>(name, ToMode(mode), comm, engineType,
"Python"))
m_Stream(std::make_shared<core::Stream>(
name, ToMode(mode), helper::CommFromMPI(comm), engineType, "Python"))
{
}

File::File(const std::string &name, const std::string mode, MPI_Comm comm,
const std::string &configFile, const std::string ioInConfigFile)
: m_Name(name), m_Mode(mode),
m_Stream(std::make_shared<core::Stream>(name, ToMode(mode), comm, configFile,
m_Stream(std::make_shared<core::Stream>(name, ToMode(mode),
helper::CommFromMPI(comm), configFile,
ioInConfigFile, "Python"))
{
}
#endif

File::File(const std::string &name, const std::string mode,
const std::string engineType)
: File(name, mode, MPI_COMM_NULL, engineType)
: m_Name(name), m_Mode(mode), m_Stream(std::make_shared<core::Stream>(
name, ToMode(mode), engineType, "Python"))
{
}

File::File(const std::string &name, const std::string mode,
const std::string &configFile, const std::string ioInConfigFile)
: File(name, mode, MPI_COMM_NULL, configFile, ioInConfigFile)
: m_Name(name), m_Mode(mode),
m_Stream(std::make_shared<core::Stream>(name, ToMode(mode), configFile,
ioInConfigFile, "Python"))
{
}

Expand Down
6 changes: 6 additions & 0 deletions bindings/Python/py11File.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include "adios2/common/ADIOSTypes.h"
#include "adios2/core/Stream.h"

#ifdef ADIOS2_HAVE_MPI
#include "adios2/common/ADIOSMPI.h"
#endif

namespace adios2
{
namespace py11
Expand All @@ -27,11 +31,13 @@ class File
const std::string m_Name;
const std::string m_Mode;

#ifdef ADIOS2_HAVE_MPI
File(const std::string &name, const std::string mode, MPI_Comm comm,
const std::string engineType = "BPFile");

File(const std::string &name, const std::string mode, MPI_Comm comm,
const std::string &configFile, const std::string ioInConfigFile);
#endif

File(const std::string &name, const std::string mode,
const std::string engineType = "BPFile");
Expand Down
4 changes: 3 additions & 1 deletion bindings/Python/py11IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "adios2/helper/adiosFunctions.h" //GetType<T>

#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#include <mpi4py/mpi4py.h>
#endif

Expand Down Expand Up @@ -252,7 +253,8 @@ Engine IO::Open(const std::string &name, const int mode, MPI4PY_Comm comm)
helper::CheckForNullptr(m_IO,
"for engine " + name + ", in call to IO::Open");

return Engine(&m_IO->Open(name, static_cast<adios2::Mode>(mode), comm));
return Engine(&m_IO->Open(name, static_cast<adios2::Mode>(mode),
helper::CommFromMPI(comm)));
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ add_library(adios2

#helper
helper/adiosComm.h helper/adiosComm.cpp
helper/adiosCommDummy.h helper/adiosCommDummy.cpp
helper/adiosCommMPI.h helper/adiosCommMPI.cpp
helper/adiosDynamicBinder.h helper/adiosDynamicBinder.cpp
helper/adiosMath.cpp
helper/adiosMemory.cpp
Expand Down
14 changes: 7 additions & 7 deletions source/adios2/core/ADIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include <algorithm> // std::transform
#include <ios> //std::ios_base::failure

#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/IO.h"
#include "adios2/helper/adiosCommDummy.h"
#include "adios2/helper/adiosFunctions.h" //InquireKey, BroadcastFile

// OPERATORS
Expand Down Expand Up @@ -57,10 +57,10 @@ namespace adios2
namespace core
{

ADIOS::ADIOS(const std::string configFile, MPI_Comm mpiComm,
ADIOS::ADIOS(const std::string configFile, helper::Comm comm,
const bool debugMode, const std::string hostLanguage)
: m_ConfigFile(configFile), m_DebugMode(debugMode),
m_HostLanguage(hostLanguage), m_Comm(helper::Comm::Duplicate(mpiComm))
m_HostLanguage(hostLanguage), m_Comm(std::move(comm))
{
if (!configFile.empty())
{
Expand All @@ -74,18 +74,18 @@ ADIOS::ADIOS(const std::string configFile, MPI_Comm mpiComm,

ADIOS::ADIOS(const std::string configFile, const bool debugMode,
const std::string hostLanguage)
: ADIOS(configFile, MPI_COMM_NULL, debugMode, hostLanguage)
: ADIOS(configFile, helper::CommDummy(), debugMode, hostLanguage)
{
}

ADIOS::ADIOS(MPI_Comm mpiComm, const bool debugMode,
ADIOS::ADIOS(helper::Comm comm, const bool debugMode,
const std::string hostLanguage)
: ADIOS("", mpiComm, debugMode, hostLanguage)
: ADIOS("", std::move(comm), debugMode, hostLanguage)
{
}

ADIOS::ADIOS(const bool debugMode, const std::string hostLanguage)
: ADIOS("", MPI_COMM_NULL, debugMode, hostLanguage)
: ADIOS("", helper::CommDummy(), debugMode, hostLanguage)
{
}

Expand Down
5 changes: 2 additions & 3 deletions source/adios2/core/ADIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
/// \endcond

#include "adios2/common/ADIOSConfig.h"
#include "adios2/common/ADIOSMPI.h"
#include "adios2/common/ADIOSTypes.h"
#include "adios2/core/Operator.h"
#include "adios2/helper/adiosComm.h"
Expand Down Expand Up @@ -55,7 +54,7 @@ class ADIOS
* false: optional feature to turn off checks on user input data,
* recommended in stable flows
*/
ADIOS(const std::string configFile, MPI_Comm mpiComm, const bool debugMode,
ADIOS(const std::string configFile, helper::Comm comm, const bool debugMode,
const std::string hostLanguage);

/**
Expand All @@ -77,7 +76,7 @@ class ADIOS
* false: optional feature to turn off checks on user input data,
* recommended in stable flows
*/
ADIOS(MPI_Comm mpiComm, const bool debugMode,
ADIOS(helper::Comm comm, const bool debugMode,
const std::string hostLanguage);

/**
Expand Down
6 changes: 2 additions & 4 deletions source/adios2/core/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <sstream>
#include <utility> // std::pair

#include "adios2/common/ADIOSMPI.h"
#include "adios2/common/ADIOSMacros.h"

#include "adios2/engine/bp3/BP3Reader.h"
Expand Down Expand Up @@ -472,7 +471,7 @@ size_t IO::AddOperation(Operator &op, const Params &parameters) noexcept
return m_Operations.size() - 1;
}

Engine &IO::Open(const std::string &name, const Mode mode, MPI_Comm mpiComm)
Engine &IO::Open(const std::string &name, const Mode mode, helper::Comm comm)
{
TAU_SCOPED_TIMER("IO::Open");
auto itEngineFound = m_Engines.find(name);
Expand Down Expand Up @@ -504,7 +503,6 @@ Engine &IO::Open(const std::string &name, const Mode mode, MPI_Comm mpiComm)
}
}

auto comm = helper::Comm::Duplicate(mpiComm);
std::shared_ptr<Engine> engine;
const bool isDefaultEngine = m_EngineType.empty() ? true : false;
std::string engineTypeLC = m_EngineType;
Expand Down Expand Up @@ -765,7 +763,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().AsMPI());
return Open(name, mode, m_ADIOS.GetComm().Duplicate());
bradking marked this conversation as resolved.
Show resolved Hide resolved
}

Engine &IO::GetEngine(const std::string &name)
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/core/IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class IO
* @exception std::invalid_argument if Engine with unique name is already
* created with another Open, in debug mode only
*/
Engine &Open(const std::string &name, const Mode mode, MPI_Comm mpiComm);
Engine &Open(const std::string &name, const Mode mode, helper::Comm comm);

/**
* Overloaded version that reuses the MPI_Comm object passed
Expand Down
Loading