Commit 89891238 authored by Brad King's avatar Brad King
Browse files

core: Replace MPI with Comm in ADIOS, IO, and Stream interfaces

parent 41219da7
...@@ -10,10 +10,13 @@ ...@@ -10,10 +10,13 @@
#include "adios2_c_adios.h" #include "adios2_c_adios.h"
#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/ADIOS.h" #include "adios2/core/ADIOS.h"
#include "adios2/helper/adiosFunctions.h" #include "adios2/helper/adiosFunctions.h"
#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -35,7 +38,8 @@ adios2_adios *adios2_init_config_glue(const char *config_file, MPI_Comm comm, ...@@ -35,7 +38,8 @@ adios2_adios *adios2_init_config_glue(const char *config_file, MPI_Comm comm,
const bool debugBool = const bool debugBool =
(debug_mode == adios2_debug_mode_on) ? true : false; (debug_mode == adios2_debug_mode_on) ? true : false;
adios = reinterpret_cast<adios2_adios *>(new adios2::core::ADIOS( 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 (...) catch (...)
{ {
......
...@@ -12,11 +12,14 @@ ...@@ -12,11 +12,14 @@
#include <vector> #include <vector>
#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/IO.h" #include "adios2/core/IO.h"
#include "adios2/helper/adiosFunctions.h" //GetType<T> #include "adios2/helper/adiosFunctions.h" //GetType<T>
#include "adios2_c_internal.h" #include "adios2_c_internal.h"
#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
...@@ -729,7 +732,8 @@ adios2_engine *adios2_open_new_comm(adios2_io *io, const char *name, ...@@ -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"); io, "for adios2_io, in call to adios2_open");
engine = reinterpret_cast<adios2_engine *>( engine = reinterpret_cast<adios2_engine *>(
&reinterpret_cast<adios2::core::IO *>(io)->Open( &reinterpret_cast<adios2::core::IO *>(io)->Open(
name, adios2_ToOpenMode(mode), comm)); name, adios2_ToOpenMode(mode),
adios2::helper::CommFromMPI(comm)));
} }
catch (...) catch (...)
{ {
......
...@@ -8,16 +8,20 @@ ...@@ -8,16 +8,20 @@
#include "ADIOS.h" #include "ADIOS.h"
#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/ADIOS.h" #include "adios2/core/ADIOS.h"
#include "adios2/core/IO.h" #include "adios2/core/IO.h"
#include "adios2/helper/adiosFunctions.h" //CheckForNullptr #include "adios2/helper/adiosFunctions.h" //CheckForNullptr
#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif
namespace adios2 namespace adios2
{ {
#ifdef ADIOS2_HAVE_MPI #ifdef ADIOS2_HAVE_MPI
ADIOS::ADIOS(const std::string &configFile, MPI_Comm comm, const bool debugMode) 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++"))
{ {
} }
......
...@@ -11,9 +11,12 @@ ...@@ -11,9 +11,12 @@
#include "IO.h" #include "IO.h"
#include "IO.tcc" #include "IO.tcc"
#include "adios2/common/ADIOSMPI.h"
#include "adios2/core/IO.h" #include "adios2/core/IO.h"
#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif
namespace adios2 namespace adios2
{ {
...@@ -109,7 +112,7 @@ Engine IO::Open(const std::string &name, const Mode mode, MPI_Comm comm) ...@@ -109,7 +112,7 @@ Engine IO::Open(const std::string &name, const Mode mode, MPI_Comm comm)
{ {
helper::CheckForNullptr(m_IO, helper::CheckForNullptr(m_IO,
"for engine " + name + ", in call to IO::Open"); "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 #endif
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#include "ADIOS2fstream.h" #include "ADIOS2fstream.h"
#include "ADIOS2fstream.tcc" #include "ADIOS2fstream.tcc"
#include "adios2/common/ADIOSMPI.h" #ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif
namespace adios2 namespace adios2
{ {
...@@ -19,15 +21,16 @@ namespace adios2 ...@@ -19,15 +21,16 @@ namespace adios2
#ifdef ADIOS2_HAVE_MPI #ifdef ADIOS2_HAVE_MPI
fstream::fstream(const std::string &name, const openmode mode, MPI_Comm comm, fstream::fstream(const std::string &name, const openmode mode, MPI_Comm comm,
const std::string engineType) const std::string engineType)
: m_Stream(std::make_shared<core::Stream>(name, ToMode(mode), comm, engineType, : m_Stream(std::make_shared<core::Stream>(
"C++")) name, ToMode(mode), helper::CommFromMPI(comm), engineType, "C++"))
{ {
} }
fstream::fstream(const std::string &name, const openmode mode, MPI_Comm comm, fstream::fstream(const std::string &name, const openmode mode, MPI_Comm comm,
const std::string &configFile, const std::string &configFile,
const std::string ioInConfigFile) 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++")) ioInConfigFile, "C++"))
{ {
} }
...@@ -54,8 +57,8 @@ void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm, ...@@ -54,8 +57,8 @@ void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm,
const std::string engineType) const std::string engineType)
{ {
CheckOpen(name); CheckOpen(name);
m_Stream = std::make_shared<core::Stream>(name, ToMode(mode), comm, m_Stream = std::make_shared<core::Stream>(
engineType, "C++"); name, ToMode(mode), helper::CommFromMPI(comm), engineType, "C++");
} }
void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm, void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm,
...@@ -64,7 +67,8 @@ void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm, ...@@ -64,7 +67,8 @@ void fstream::open(const std::string &name, const openmode mode, MPI_Comm comm,
{ {
CheckOpen(name); CheckOpen(name);
m_Stream = std::make_shared<core::Stream>( m_Stream = std::make_shared<core::Stream>(
name, ToMode(mode), comm, configFile, ioInConfigFile, "C++"); name, ToMode(mode), helper::CommFromMPI(comm), configFile,
ioInConfigFile, "C++");
} }
#else #else
void fstream::open(const std::string &name, const openmode mode, void fstream::open(const std::string &name, const openmode mode,
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
#include "py11ADIOS.h" #include "py11ADIOS.h"
#include "adios2/common/ADIOSMPI.h" #ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif
namespace adios2 namespace adios2
{ {
...@@ -20,8 +22,8 @@ namespace py11 ...@@ -20,8 +22,8 @@ namespace py11
#ifdef ADIOS2_HAVE_MPI #ifdef ADIOS2_HAVE_MPI
ADIOS::ADIOS(const std::string &configFile, MPI4PY_Comm mpiComm, ADIOS::ADIOS(const std::string &configFile, MPI4PY_Comm mpiComm,
const bool debugMode) const bool debugMode)
: m_ADIOS(std::make_shared<adios2::core::ADIOS>(configFile, mpiComm, debugMode, : m_ADIOS(std::make_shared<adios2::core::ADIOS>(
"Python")) configFile, helper::CommFromMPI(mpiComm), debugMode, "Python"))
{ {
} }
......
...@@ -14,10 +14,14 @@ ...@@ -14,10 +14,14 @@
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include "adios2/common/ADIOSMPI.h"
#include "adios2/common/ADIOSMacros.h" #include "adios2/common/ADIOSMacros.h"
#include "adios2/helper/adiosCommDummy.h"
#include "adios2/helper/adiosFunctions.h" #include "adios2/helper/adiosFunctions.h"
#ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#endif
#include "py11types.h" #include "py11types.h"
namespace adios2 namespace adios2
...@@ -25,31 +29,37 @@ namespace adios2 ...@@ -25,31 +29,37 @@ namespace adios2
namespace py11 namespace py11
{ {
#ifdef ADIOS2_HAVE_MPI
File::File(const std::string &name, const std::string mode, MPI_Comm comm, File::File(const std::string &name, const std::string mode, MPI_Comm comm,
const std::string engineType) const std::string engineType)
: m_Name(name), m_Mode(mode), : m_Name(name), m_Mode(mode),
m_Stream(std::make_shared<core::Stream>(name, ToMode(mode), comm, engineType, m_Stream(std::make_shared<core::Stream>(
"Python")) name, ToMode(mode), helper::CommFromMPI(comm), engineType, "Python"))
{ {
} }
File::File(const std::string &name, const std::string mode, MPI_Comm comm, File::File(const std::string &name, const std::string mode, MPI_Comm comm,
const std::string &configFile, const std::string ioInConfigFile) const std::string &configFile, const std::string ioInConfigFile)
: m_Name(name), m_Mode(mode), : 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")) ioInConfigFile, "Python"))
{ {
} }
#endif
File::File(const std::string &name, const std::string mode, File::File(const std::string &name, const std::string mode,
const std::string engineType) 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, File::File(const std::string &name, const std::string mode,
const std::string &configFile, const std::string ioInConfigFile) 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"))
{ {
} }
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
#include "adios2/common/ADIOSTypes.h" #include "adios2/common/ADIOSTypes.h"
#include "adios2/core/Stream.h" #include "adios2/core/Stream.h"
#ifdef ADIOS2_HAVE_MPI
#include "adios2/common/ADIOSMPI.h"
#endif
namespace adios2 namespace adios2
{ {
namespace py11 namespace py11
...@@ -27,11 +31,13 @@ public: ...@@ -27,11 +31,13 @@ public:
const std::string m_Name; const std::string m_Name;
const std::string m_Mode; const std::string m_Mode;
#ifdef ADIOS2_HAVE_MPI
File(const std::string &name, const std::string mode, MPI_Comm comm, File(const std::string &name, const std::string mode, MPI_Comm comm,
const std::string engineType = "BPFile"); const std::string engineType = "BPFile");
File(const std::string &name, const std::string mode, MPI_Comm comm, File(const std::string &name, const std::string mode, MPI_Comm comm,
const std::string &configFile, const std::string ioInConfigFile); const std::string &configFile, const std::string ioInConfigFile);
#endif
File(const std::string &name, const std::string mode, File(const std::string &name, const std::string mode,
const std::string engineType = "BPFile"); const std::string engineType = "BPFile");
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "adios2/helper/adiosFunctions.h" //GetType<T> #include "adios2/helper/adiosFunctions.h" //GetType<T>
#ifdef ADIOS2_HAVE_MPI #ifdef ADIOS2_HAVE_MPI
#include "adios2/helper/adiosCommMPI.h"
#include <mpi4py/mpi4py.h> #include <mpi4py/mpi4py.h>
#endif #endif
...@@ -252,7 +253,8 @@ Engine IO::Open(const std::string &name, const int mode, MPI4PY_Comm comm) ...@@ -252,7 +253,8 @@ Engine IO::Open(const std::string &name, const int mode, MPI4PY_Comm comm)
helper::CheckForNullptr(m_IO, helper::CheckForNullptr(m_IO,
"for engine " + name + ", in call to IO::Open"); "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 #endif
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <ios> //std::ios_base::failure #include <ios> //std::ios_base::failure
#include "adios2/core/IO.h" #include "adios2/core/IO.h"
#include "adios2/helper/adiosCommMPI.h" #include "adios2/helper/adiosCommDummy.h"
#include "adios2/helper/adiosFunctions.h" //InquireKey, BroadcastFile #include "adios2/helper/adiosFunctions.h" //InquireKey, BroadcastFile
// OPERATORS // OPERATORS
...@@ -57,10 +57,10 @@ namespace adios2 ...@@ -57,10 +57,10 @@ namespace adios2
namespace core 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) const bool debugMode, const std::string hostLanguage)
: m_ConfigFile(configFile), m_DebugMode(debugMode), : m_ConfigFile(configFile), m_DebugMode(debugMode),
m_HostLanguage(hostLanguage), m_Comm(helper::CommFromMPI(mpiComm)) m_HostLanguage(hostLanguage), m_Comm(std::move(comm))
{ {
if (!configFile.empty()) if (!configFile.empty())
{ {
...@@ -74,18 +74,18 @@ ADIOS::ADIOS(const std::string configFile, MPI_Comm mpiComm, ...@@ -74,18 +74,18 @@ ADIOS::ADIOS(const std::string configFile, MPI_Comm mpiComm,
ADIOS::ADIOS(const std::string configFile, const bool debugMode, ADIOS::ADIOS(const std::string configFile, const bool debugMode,
const std::string hostLanguage) 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) const std::string hostLanguage)
: ADIOS("", mpiComm, debugMode, hostLanguage) : ADIOS("", std::move(comm), debugMode, hostLanguage)
{ {
} }
ADIOS::ADIOS(const bool debugMode, const std::string hostLanguage) ADIOS::ADIOS(const bool debugMode, const std::string hostLanguage)
: ADIOS("", MPI_COMM_NULL, debugMode, hostLanguage) : ADIOS("", helper::CommDummy(), debugMode, hostLanguage)
{ {
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
/// \endcond /// \endcond
#include "adios2/common/ADIOSConfig.h" #include "adios2/common/ADIOSConfig.h"
#include "adios2/common/ADIOSMPI.h"
#include "adios2/common/ADIOSTypes.h" #include "adios2/common/ADIOSTypes.h"
#include "adios2/core/Operator.h" #include "adios2/core/Operator.h"
#include "adios2/helper/adiosComm.h" #include "adios2/helper/adiosComm.h"
...@@ -55,7 +54,7 @@ public: ...@@ -55,7 +54,7 @@ public:
* false: optional feature to turn off checks on user input data, * false: optional feature to turn off checks on user input data,
* recommended in stable flows * 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); const std::string hostLanguage);
/** /**
...@@ -77,7 +76,7 @@ public: ...@@ -77,7 +76,7 @@ public:
* false: optional feature to turn off checks on user input data, * false: optional feature to turn off checks on user input data,
* recommended in stable flows * recommended in stable flows
*/ */
ADIOS(MPI_Comm mpiComm, const bool debugMode, ADIOS(helper::Comm comm, const bool debugMode,
const std::string hostLanguage); const std::string hostLanguage);
/** /**
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <sstream> #include <sstream>
#include <utility> // std::pair #include <utility> // std::pair
#include "adios2/common/ADIOSMPI.h"
#include "adios2/common/ADIOSMacros.h" #include "adios2/common/ADIOSMacros.h"
#include "adios2/engine/bp3/BP3Reader.h" #include "adios2/engine/bp3/BP3Reader.h"
...@@ -29,7 +28,6 @@ ...@@ -29,7 +28,6 @@
#include "adios2/engine/skeleton/SkeletonWriter.h" #include "adios2/engine/skeleton/SkeletonWriter.h"
#include "adios2/helper/adiosComm.h" #include "adios2/helper/adiosComm.h"
#include "adios2/helper/adiosCommMPI.h"
#include "adios2/helper/adiosFunctions.h" //BuildParametersMap #include "adios2/helper/adiosFunctions.h" //BuildParametersMap
#include "adios2/toolkit/profiling/taustubs/tautimer.hpp" #include "adios2/toolkit/profiling/taustubs/tautimer.hpp"
#include <adios2sys/SystemTools.hxx> // FileIsDirectory() #include <adios2sys/SystemTools.hxx> // FileIsDirectory()
...@@ -473,7 +471,7 @@ size_t IO::AddOperation(Operator &op, const Params &parameters) noexcept ...@@ -473,7 +471,7 @@ size_t IO::AddOperation(Operator &op, const Params &parameters) noexcept
return m_Operations.size() - 1; 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"); TAU_SCOPED_TIMER("IO::Open");
auto itEngineFound = m_Engines.find(name); auto itEngineFound = m_Engines.find(name);
...@@ -505,7 +503,6 @@ Engine &IO::Open(const std::string &name, const Mode mode, MPI_Comm mpiComm) ...@@ -505,7 +503,6 @@ Engine &IO::Open(const std::string &name, const Mode mode, MPI_Comm mpiComm)
} }
} }
auto comm = helper::CommFromMPI(mpiComm);
std::shared_ptr<Engine> engine; std::shared_ptr<Engine> engine;
const bool isDefaultEngine = m_EngineType.empty() ? true : false; const bool isDefaultEngine = m_EngineType.empty() ? true : false;
std::string engineTypeLC = m_EngineType; std::string engineTypeLC = m_EngineType;
...@@ -766,7 +763,7 @@ Engine &IO::Open(const std::string &name, const Mode mode, MPI_Comm mpiComm) ...@@ -766,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) Engine &IO::Open(const std::string &name, const Mode mode)
{ {
return Open(name, mode, CommAsMPI(m_ADIOS.GetComm())); return Open(name, mode, m_ADIOS.GetComm().Duplicate());
} }
Engine &IO::GetEngine(const std::string &name) Engine &IO::GetEngine(const std::string &name)
......
...@@ -360,7 +360,7 @@ public: ...@@ -360,7 +360,7 @@ public:
* @exception std::invalid_argument if Engine with unique name is already * @exception std::invalid_argument if Engine with unique name is already
* created with another Open, in debug mode only * 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 * Overloaded version that reuses the MPI_Comm object passed
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <stdexcept> //std::invalid_argument #include <stdexcept> //std::invalid_argument
/// \endcond /// \endcond
#include "adios2/common/ADIOSMPI.h"
#include "adios2/common/ADIOSMacros.h" #include "adios2/common/ADIOSMacros.h"
#include "adios2/helper/adiosFunctions.h" //helper::GetType<T> #include "adios2/helper/adiosFunctions.h" //helper::GetType<T>
#include "adios2/toolkit/profiling/taustubs/tautimer.hpp" #include "adios2/toolkit/profiling/taustubs/tautimer.hpp"
......
...@@ -11,16 +11,17 @@ ...@@ -11,16 +11,17 @@