diff --git a/source/adios2/ADIOS.cpp b/source/adios2/ADIOS.cpp index 15676f532bc4be63476049daf0b816bb0ac68b11..ac4725a53e4257fe58e1a06bef1e10578db4fb52 100644 --- a/source/adios2/ADIOS.cpp +++ b/source/adios2/ADIOS.cpp @@ -17,6 +17,7 @@ #include <sstream> #include <utility> +#include "adios2/ADIOSMPI.h" #include "adios2/ADIOSMacros.h" #include "adios2/core/adiosFunctions.h" #include "adios2/engine/bp/BPFileReader.h" @@ -41,17 +42,14 @@ namespace adios { ADIOS::ADIOS(const Verbose verbose, const bool debugMode) -: m_DebugMode{debugMode} +: ADIOS("", MPI_COMM_SELF, verbose, debugMode) { - InitMPI(); } ADIOS::ADIOS(const std::string config, const Verbose verbose, const bool debugMode) -: m_ConfigFile(config), m_DebugMode(debugMode) +: ADIOS(config, MPI_COMM_SELF, verbose, debugMode) { - InitMPI(); - // InitXML( m_ConfigFile, m_MPIComm, m_DebugMode, m_Transforms ); } ADIOS::ADIOS(const std::string configFile, MPI_Comm mpiComm, @@ -64,9 +62,8 @@ ADIOS::ADIOS(const std::string configFile, MPI_Comm mpiComm, } ADIOS::ADIOS(MPI_Comm mpiComm, const Verbose verbose, const bool debugMode) -: m_MPIComm(mpiComm), m_DebugMode(debugMode) +: ADIOS("", mpiComm, verbose, debugMode) { - InitMPI(); } // ADIOS::~ADIOS() {} diff --git a/source/adios2/ADIOS.h b/source/adios2/ADIOS.h index baf5183c570fc1487e21aa95fd9d6df212b461fe..0a5a23439093831d01d8efd57746369cc7135a7e 100644 --- a/source/adios2/ADIOS.h +++ b/source/adios2/ADIOS.h @@ -21,9 +21,9 @@ /// \endcond #include "adios2/ADIOSConfig.h" +#include "adios2/ADIOSMPICommOnly.h" #include "adios2/ADIOSMacros.h" #include "adios2/ADIOSTypes.h" -#include "adios2/ADIOS_MPI.h" #include "adios2/core/Method.h" #include "adios2/core/Support.h" #include "adios2/core/Transform.h" @@ -45,7 +45,7 @@ public: * Passed from parallel constructor, MPI_Comm is a pointer itself. * Public as called from C */ - MPI_Comm m_MPIComm = MPI_COMM_SELF; + MPI_Comm m_MPIComm; int m_RankMPI = 0; ///< current MPI rank process int m_SizeMPI = 1; ///< current MPI processes size diff --git a/source/adios2/ADIOS_MPI.h b/source/adios2/ADIOSMPI.h similarity index 73% rename from source/adios2/ADIOS_MPI.h rename to source/adios2/ADIOSMPI.h index 5a1a585db1818ff4a2059bb5edb99dbf6e8b52df..3524532d34ee3e5b81ef977f6269cf25a813047e 100644 --- a/source/adios2/ADIOS_MPI.h +++ b/source/adios2/ADIOSMPI.h @@ -3,8 +3,8 @@ * accompanying file Copyright.txt for details. */ -#ifndef ADIOS2_ADIOS_MPI_H_ -#define ADIOS2_ADIOS_MPI_H_ +#ifndef ADIOS2_ADIOSMPI_H_ +#define ADIOS2_ADIOSMPI_H_ #include "adios2/ADIOSConfig.h" @@ -14,4 +14,4 @@ #include "adios2/mpidummy.h" #endif -#endif /* ADIOS2_ADIOS_MPI_H_ */ +#endif /* ADIOS2_ADIOSMPI_H_ */ diff --git a/source/adios2/ADIOSMPICommOnly.h b/source/adios2/ADIOSMPICommOnly.h new file mode 100644 index 0000000000000000000000000000000000000000..f0943579943f2a5a0201b02cf61de8acc606feb3 --- /dev/null +++ b/source/adios2/ADIOSMPICommOnly.h @@ -0,0 +1,20 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + */ + +#ifndef ADIOS2_ADIOSMPICOMMONLY_H_ +#define ADIOS2_ADIOSMPICOMMONLY_H_ + +#include "adios2/ADIOSConfig.h" + +#ifdef ADIOS2_HAVE_MPI +#include <mpi.h> +#else +namespace adios +{ +using MPI_Comm = int; +} // end namespace adios +#endif + +#endif /* ADIOS2_ADIOSMPICOMMONLY_H_ */ diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt index e24b486a1ae958e642452a7a23e4a75fc8b61778..ee1a1b46beb209bbf901863cd1cfdee05560f697 100644 --- a/source/adios2/CMakeLists.txt +++ b/source/adios2/CMakeLists.txt @@ -103,7 +103,7 @@ endif() install( FILES - ADIOS.h ADIOS.inl ADIOSMacros.h ADIOS_MPI.h ADIOSTypes.h mpidummy.h + ADIOS.h ADIOS.inl ADIOSMacros.h ADIOS_MPI.h ADIOSTypes.h ADIOSMPICommOnly.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2 ) install( diff --git a/source/adios2/core/Engine.cpp b/source/adios2/core/Engine.cpp index d8bcbd1eb5679d61ae02d86054cf8c37c0884a6f..fdbb85cca8bf02d7c7bc93c762a9c9b662baff91 100644 --- a/source/adios2/core/Engine.cpp +++ b/source/adios2/core/Engine.cpp @@ -12,6 +12,7 @@ #include <ios> //std::ios_base::failure +#include "adios2/ADIOSMPI.h" #include "adios2/core/Support.h" #include "adios2/core/adiosFunctions.h" diff --git a/source/adios2/core/Engine.h b/source/adios2/core/Engine.h index dec2565ddb5e3064d50842b88c88a58d1eb640fb..72850a746205db792aae7b610c147e1003eb7258 100644 --- a/source/adios2/core/Engine.h +++ b/source/adios2/core/Engine.h @@ -23,8 +23,8 @@ #include "adios2/ADIOS.h" #include "adios2/ADIOSConfig.h" +#include "adios2/ADIOSMPICommOnly.h" #include "adios2/ADIOSTypes.h" -#include "adios2/ADIOS_MPI.h" #include "adios2/core/Capsule.h" #include "adios2/core/Method.h" #include "adios2/core/Transform.h" @@ -52,7 +52,7 @@ class Engine { public: - MPI_Comm m_MPIComm = MPI_COMM_SELF; + MPI_Comm m_MPIComm; const std::string m_EngineType; ///< from derived class const std::string m_Name; ///< name used for this engine diff --git a/source/adios2/core/Transport.cpp b/source/adios2/core/Transport.cpp index 808b5c9330d871bb6d747a4278ca153267f70acd..6b0e0772d584b52ae4f3a4fa3b4757ebb235ab3b 100644 --- a/source/adios2/core/Transport.cpp +++ b/source/adios2/core/Transport.cpp @@ -12,6 +12,8 @@ #include <utility> +#include "adios2/ADIOSMPI.h" + namespace adios { diff --git a/source/adios2/core/Transport.h b/source/adios2/core/Transport.h index 83f5339f86fd24ff6244824d9c9e88c11e8235ec..1a5cf845de38e67bafe1250c53cd0813a103b164 100644 --- a/source/adios2/core/Transport.h +++ b/source/adios2/core/Transport.h @@ -17,7 +17,7 @@ /// \endcond #include "adios2/ADIOSConfig.h" -#include "adios2/ADIOS_MPI.h" +#include "adios2/ADIOSMPICommOnly.h" #include "adios2/core/IOChrono.h" namespace adios @@ -32,7 +32,7 @@ public: std::string m_AccessMode; ///< from Open bool m_IsOpen = false; - MPI_Comm m_MPIComm = MPI_COMM_SELF; + MPI_Comm m_MPIComm; int m_RankMPI = 0; ///< current MPI rank process int m_SizeMPI = 1; ///< current MPI processes size diff --git a/source/adios2/core/adiosFunctions.cpp b/source/adios2/core/adiosFunctions.cpp index ffb5c81f43a4d32adb732e4a59d934ceebce419e..3c18cd3c225f9db1ffd9c6b0eace7a748723d48b 100644 --- a/source/adios2/core/adiosFunctions.cpp +++ b/source/adios2/core/adiosFunctions.cpp @@ -24,6 +24,7 @@ #include <stdexcept> #include <thread> //std::thread +#include "adios2/ADIOSMPI.h" #include "adios2/core/Support.h" #ifdef ADIOS2_HAVE_BZIP2 diff --git a/source/adios2/core/adiosFunctions.h b/source/adios2/core/adiosFunctions.h index 07f05fae2b3bec413f680f18ba5c339e2b071545..791661b2d8169a15b5369e4b7276fd8515b30788 100644 --- a/source/adios2/core/adiosFunctions.h +++ b/source/adios2/core/adiosFunctions.h @@ -20,7 +20,7 @@ /// \endcond #include "adios2/ADIOSConfig.h" -#include "adios2/ADIOS_MPI.h" +#include "adios2/ADIOSMPICommOnly.h" #include "adios2/core/Transform.h" namespace adios diff --git a/source/adios2/engine/adios1/ADIOS1Reader.h b/source/adios2/engine/adios1/ADIOS1Reader.h index 720acbad605dd5ac6fb6802816f859cdad44ed5d..e600754ea8e4b0e977e10cc04243ced07542879e 100644 --- a/source/adios2/engine/adios1/ADIOS1Reader.h +++ b/source/adios2/engine/adios1/ADIOS1Reader.h @@ -15,12 +15,22 @@ #include <iostream> //this must go away -#include <adios_read_v2.h> - #include "adios2/ADIOSConfig.h" #include "adios2/capsule/heap/STLVector.h" #include "adios2/core/Engine.h" +// Fake out the include guard from ADIOS1's mpidummy.h to prevent it from +// getting included +#ifdef _NOMPI +#define __MPI_DUMMY_H__ +#define MPI_Comm int +#endif +#include <adios_read_v2.h> +#ifdef _NOMPI +#undef MPI_Comm +#undef __MPI_DUMMY_H__ +#endif + namespace adios { diff --git a/source/adios2/engine/adios1/ADIOS1Writer.h b/source/adios2/engine/adios1/ADIOS1Writer.h index c02de6a815a93980e8c807d220d67b8df882ea61..bc9ebe4502dde8c8e5eb71867c6fdfe3b9ad591c 100644 --- a/source/adios2/engine/adios1/ADIOS1Writer.h +++ b/source/adios2/engine/adios1/ADIOS1Writer.h @@ -13,11 +13,21 @@ #ifndef ADIOS2_ENGINE_ADIOS1_ADIOS1WRITER_H_ #define ADIOS2_ENGINE_ADIOS1_ADIOS1WRITER_H_ -#include <adios.h> - #include "adios2/ADIOSConfig.h" #include "adios2/core/Engine.h" +// Fake out the include guard from ADIOS1's mpidummy.h to prevent it from +// getting included +#ifdef _NOMPI +#define __MPI_DUMMY_H__ +#define MPI_Comm int +#endif +#include <adios.h> +#ifdef _NOMPI +#undef MPI_Comm +#undef __MPI_DUMMY_H__ +#endif + namespace adios { diff --git a/source/adios2/engine/dataman/DataManWriter.cpp b/source/adios2/engine/dataman/DataManWriter.cpp index 1cf180ffe0fb5bbf3ec55ea8e8756ce948cdd4c5..39825a6ace651337c3fb41e01bd2970f060f2485 100644 --- a/source/adios2/engine/dataman/DataManWriter.cpp +++ b/source/adios2/engine/dataman/DataManWriter.cpp @@ -9,6 +9,7 @@ */ #include "DataManWriter.h" +#include "DataManWriter.tcc" #include <iostream> //needs to go away, this is just for demo purposes diff --git a/source/adios2/engine/dataman/DataManWriter.h b/source/adios2/engine/dataman/DataManWriter.h index 44567dddff6d6fc6b497d17cfbe713b738c413db..1420ccc1f4994c4a638e607dc05d29f52d119d39 100644 --- a/source/adios2/engine/dataman/DataManWriter.h +++ b/source/adios2/engine/dataman/DataManWriter.h @@ -127,56 +127,7 @@ private: const std::map<std::string, std::string> &mdtmParameters); template <class T> - void WriteVariableCommon(Variable<T> &variable, const T *values) - { - // here comes your magic at Writing now variable.m_UserValues has the - // data - // passed by the user - // set variable - variable.m_AppValues = values; - m_WrittenVariables.insert(variable.m_Name); - - // This part will go away, this is just to monitor variables per rank - - json jmsg; - jmsg["doid"] = m_Name; - jmsg["var"] = variable.m_Name; - jmsg["dtype"] = GetType<T>(); - jmsg["putshape"] = variable.m_LocalDimensions; - if (variable.m_GlobalDimensions.size() == 0) - variable.m_GlobalDimensions = variable.m_LocalDimensions; - jmsg["varshape"] = variable.m_GlobalDimensions; - if (variable.m_Offsets.size() == 0) - variable.m_Offsets.assign(variable.m_LocalDimensions.size(), 0); - jmsg["offset"] = variable.m_Offsets; - jmsg["timestep"] = 0; - m_Man.put(values, jmsg); - - if (m_DoMonitor) - { - MPI_Barrier(m_MPIComm); - std::cout << "I am hooked to the DataMan library\n"; - std::cout << "putshape " << variable.m_LocalDimensions.size() - << std::endl; - std::cout << "varshape " << variable.m_GlobalDimensions.size() - << std::endl; - std::cout << "offset " << variable.m_Offsets.size() << std::endl; - for (int i = 0; i < m_SizeMPI; ++i) - { - if (i == m_RankMPI) - { - std::cout << "Rank: " << m_RankMPI << "\n"; - variable.Monitor(std::cout); - std::cout << std::endl; - } - else - { - sleep(1); - } - } - MPI_Barrier(m_MPIComm); - } - } + void WriteVariableCommon(Variable<T> &variable, const T *values); }; } // end namespace adios diff --git a/source/adios2/engine/dataman/DataManWriter.tcc b/source/adios2/engine/dataman/DataManWriter.tcc new file mode 100644 index 0000000000000000000000000000000000000000..e22d2e4b5fa9483030349cc094cc62c466fe0044 --- /dev/null +++ b/source/adios2/engine/dataman/DataManWriter.tcc @@ -0,0 +1,75 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * DataMan.h + * + * Created on: Jan 10, 2017 + * Author: wfg + */ + +#ifndef ADIOS2_ENGINE_DATAMAN_DATAMAN_WRITER_TCC_ +#define ADIOS2_ENGINE_DATAMAN_DATAMAN_WRITER_TCC_ + +#include "DataManWriter.h" + +#include "adios2/ADIOSMPI.h" + +namespace adios +{ + +template <class T> +void DataManWriter::WriteVariableCommon(Variable<T> &variable, const T *values) +{ + // here comes your magic at Writing now variable.m_UserValues has the + // data + // passed by the user + // set variable + variable.m_AppValues = values; + m_WrittenVariables.insert(variable.m_Name); + + // This part will go away, this is just to monitor variables per rank + + json jmsg; + jmsg["doid"] = m_Name; + jmsg["var"] = variable.m_Name; + jmsg["dtype"] = GetType<T>(); + jmsg["putshape"] = variable.m_LocalDimensions; + if (variable.m_GlobalDimensions.size() == 0) + variable.m_GlobalDimensions = variable.m_LocalDimensions; + jmsg["varshape"] = variable.m_GlobalDimensions; + if (variable.m_Offsets.size() == 0) + variable.m_Offsets.assign(variable.m_LocalDimensions.size(), 0); + jmsg["offset"] = variable.m_Offsets; + jmsg["timestep"] = 0; + m_Man.put(values, jmsg); + + if (m_DoMonitor) + { + MPI_Barrier(m_MPIComm); + std::cout << "I am hooked to the DataMan library\n"; + std::cout << "putshape " << variable.m_LocalDimensions.size() + << std::endl; + std::cout << "varshape " << variable.m_GlobalDimensions.size() + << std::endl; + std::cout << "offset " << variable.m_Offsets.size() << std::endl; + for (int i = 0; i < m_SizeMPI; ++i) + { + if (i == m_RankMPI) + { + std::cout << "Rank: " << m_RankMPI << "\n"; + variable.Monitor(std::cout); + std::cout << std::endl; + } + else + { + sleep(1); + } + } + MPI_Barrier(m_MPIComm); + } +} + +} // end namespace adios + +#endif /* ADIOS2_ENGINE_DATAMAN_DATAMAN_WRITER_H_ */ diff --git a/source/adios2/engine/hdf5/HDF5WriterP.cpp b/source/adios2/engine/hdf5/HDF5WriterP.cpp index 87daeb882e5d839d866a2c81b69855a652ac0496..16640b6ce7643eca219aaa101baa36211539de30 100644 --- a/source/adios2/engine/hdf5/HDF5WriterP.cpp +++ b/source/adios2/engine/hdf5/HDF5WriterP.cpp @@ -14,6 +14,7 @@ #include "adios2/core/Support.h" #include "adios2/core/adiosFunctions.h" //CSVToVector +#include "adiso2/ADIOSMPI.h" namespace adios { diff --git a/source/adios2/engine/hdf5/HDF5WriterP.h b/source/adios2/engine/hdf5/HDF5WriterP.h index 33807473988c9d91aa0e42bfa9feded67d3f1dfd..cca6b53ee38edc4b55ca5613b7889a9654a4ed9c 100644 --- a/source/adios2/engine/hdf5/HDF5WriterP.h +++ b/source/adios2/engine/hdf5/HDF5WriterP.h @@ -13,7 +13,7 @@ #define ADIOS2_ENGINE_HDF5_HDF5WRITERP_H__ #include "adios2/ADIOSConfig.h" -#include "adios2/ADIOS_MPI.h" +#include "adios2/ADIOSMPICommOnly.h" #include "adios2/capsule/heap/STLVector.h" #include "adios2/core/Engine.h" diff --git a/source/adios2/transport/file/MPI_File.h b/source/adios2/transport/file/MPI_File.h index d1098669b5bc6269414b80f8ec6968dda4b9d043..255d55983cc75e2ba111d1cc126f9caa3ae02380 100644 --- a/source/adios2/transport/file/MPI_File.h +++ b/source/adios2/transport/file/MPI_File.h @@ -12,7 +12,7 @@ #define ADIOS2_TRANSPORT_FILE_MPI_FILE_H_ #include "adios2/ADIOSConfig.h" -#include "adios2/ADIOS_MPI.h" +#include "adios2/ADIOSMPICommOnly.h" namespace adios { diff --git a/source/adios2/utilities/format/bp1/BP1Aggregator.cpp b/source/adios2/utilities/format/bp1/BP1Aggregator.cpp index b26215f186ef1194d5a98977dddf31fc8c90c907..b1e8693c228dcd1fec2f539da43cbb4a25ca431c 100644 --- a/source/adios2/utilities/format/bp1/BP1Aggregator.cpp +++ b/source/adios2/utilities/format/bp1/BP1Aggregator.cpp @@ -14,6 +14,8 @@ #include <stdexcept> #include <vector> +#include "adios2/ADIOSMPI.h" + namespace adios { namespace format @@ -26,8 +28,6 @@ BP1Aggregator::BP1Aggregator(MPI_Comm mpiComm, const bool debugMode) MPI_Comm_size(m_MPIComm, &m_SizeMPI); } -BP1Aggregator::~BP1Aggregator() {} - void BP1Aggregator::WriteProfilingLog(const std::string fileName, const std::string &rankLog) { diff --git a/source/adios2/utilities/format/bp1/BP1Aggregator.h b/source/adios2/utilities/format/bp1/BP1Aggregator.h index f1fc6c61fe986b5864f107c7814b281f5dde691b..de82b269533cfdc5e5f554d1c59ed102af216ee5 100644 --- a/source/adios2/utilities/format/bp1/BP1Aggregator.h +++ b/source/adios2/utilities/format/bp1/BP1Aggregator.h @@ -16,7 +16,7 @@ /// \endcond #include "adios2/ADIOSConfig.h" -#include "adios2/ADIOS_MPI.h" +#include "adios2/ADIOSMPICommOnly.h" namespace adios { @@ -30,9 +30,9 @@ class BP1Aggregator { public: - MPI_Comm m_MPIComm = MPI_COMM_SELF; ///< MPI communicator from Engine - int m_RankMPI = 0; ///< current MPI rank process - int m_SizeMPI = 1; ///< current MPI processes size + MPI_Comm m_MPIComm; ///< MPI communicator from Engine + int m_RankMPI = 0; ///< current MPI rank process + int m_SizeMPI = 1; ///< current MPI processes size /** * Unique constructor @@ -40,7 +40,7 @@ public: */ BP1Aggregator(MPI_Comm mpiComm, const bool debugMode = false); - ~BP1Aggregator(); + ~BP1Aggregator() = default; /** * Function that aggregates and writes (from rank = 0) profiling.log in diff --git a/source/adios2/utilities/format/bp1/BP1Base.cpp b/source/adios2/utilities/format/bp1/BP1Base.cpp index 86da561c739e14a4855385f6d2bc9bc4203df254..7a62c0a8d204304e609f0926b3985d0921555a26 100644 --- a/source/adios2/utilities/format/bp1/BP1Base.cpp +++ b/source/adios2/utilities/format/bp1/BP1Base.cpp @@ -10,6 +10,7 @@ #include "BP1Base.h" +#include "adios2/ADIOSMPI.h" #include "adios2/core/adiosFunctions.h" namespace adios diff --git a/source/adios2/utilities/format/bp1/BP1Base.h b/source/adios2/utilities/format/bp1/BP1Base.h index f9ce6493881909421cfca6ef094d9ba3e11b1f7d..dba0727cf7547511b2584ae4d010ae254329d294 100644 --- a/source/adios2/utilities/format/bp1/BP1Base.h +++ b/source/adios2/utilities/format/bp1/BP1Base.h @@ -19,7 +19,7 @@ /// \endcond #include "adios2/ADIOSConfig.h" -#include "adios2/ADIOS_MPI.h" +#include "adios2/ADIOSMPICommOnly.h" #include "adios2/core/Transport.h" namespace adios