diff --git a/CMakeLists.txt b/CMakeLists.txt index 874ef37fbc5ff05792703b722f2e87bd76922c3a..bbf244496dd5c2b5cba43cd19fc2f001e3e9872f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,11 @@ endif() # Top level options #------------------------------------------------------------------------------# +# Default to a debug build if not specified +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE) +endif() + # Force C++11 set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -61,6 +66,10 @@ if(ADIOS_ENABLE_PIC) endif() option(ADIOS_USE_MPI "Enable the MPI version of ADIOS" ON) +if(ADIOS_USE_MPI) + # Workaround for OpenMPI forcing th elink of C++ bindings + add_definitions(-DOMPI_SKIP_MPICXX) +endif() option(ADIOS_USE_BZip2 "Enable support for BZip2 transforms" ON) option(ADIOS_USE_ADIOS1 "Enable support for the ADIOS 1 engine" OFF) option(ADIOS_USE_DataMan "Enable support for the DataMan engine" OFF) @@ -68,8 +77,9 @@ option(ADIOS_USE_DataMan "Enable support for the DataMan engine" OFF) #------------------------------------------------------------------------------# # Third party libraries #------------------------------------------------------------------------------# -option(ADIOS_BUILD_TESTING "Build ADIOS tests" OFF) -set(BUILD_TESTING ${ADIOS_BUILD_TESTING} CACHE INTERNAL "") +option(ADIOS_BUILD_TESTING "Build ADIOS tests" ON) +set(BUILD_TESTING ${ADIOS_BUILD_TESTING}) +mark_as_advanced(BUILD_TESTING) include(CTest) add_subdirectory(thirdparty) @@ -113,10 +123,11 @@ message("") message(" Installation prefix: ${CMAKE_INSTALL_PREFIX}") message(" Features:") if(BUILD_SHARED_LIBS) - message(" Type: shared") + message(" Library Type: shared") else() - message(" Type: static") + message(" Library Type: static") endif() +message(" Build Type: ${CMAKE_BUILD_TYPE}") message(" Testing: ${BUILD_TESTING}") message(" MPI: ${ADIOS_USE_MPI}") message(" BZip2: ${ADIOS_USE_BZip2}") diff --git a/examples/hello/bpWriter/CMakeLists.txt b/examples/hello/bpWriter/CMakeLists.txt index 3518b42787191b823fce4f840f9275693867b8f3..67e193342b05fe0c7d99881038a69e5233706fda 100644 --- a/examples/hello/bpWriter/CMakeLists.txt +++ b/examples/hello/bpWriter/CMakeLists.txt @@ -8,7 +8,16 @@ if(ADIOS_USE_MPI) add_executable(hello_bpWriter helloBPWriter.cpp) target_include_directories(hello_bpWriter PRIVATE ${MPI_C_INCLUDE_PATH}) target_link_libraries(hello_bpWriter adios2 ${MPI_C_LIBRARIES}) + + if(ADIOS_BUILD_TESTING) + add_test( NAME Example::hello::bpWriter COMMAND hello_bpWriter) + endif() +else() + add_executable(hello_bpWriter_nompi helloBPWriter_nompi.cpp) + target_link_libraries(hello_bpWriter_nompi adios2) + + if(ADIOS_BUILD_TESTING) + add_test( NAME Example::hello::bpWriter_nompi COMMAND hello_bpWriter_nompi) + endif() endif() -add_executable(hello_bpWriter_nompi helloBPWriter_nompi.cpp) -target_link_libraries(hello_bpWriter_nompi adios2) diff --git a/examples/hello/bpWriter/helloBPWriter.cpp b/examples/hello/bpWriter/helloBPWriter.cpp index 1be2cececb66a16a6c09d2b5b050bc019f53fe05..abc680ffdcfb93be169f51dc41570122713c2458 100644 --- a/examples/hello/bpWriter/helloBPWriter.cpp +++ b/examples/hello/bpWriter/helloBPWriter.cpp @@ -11,9 +11,7 @@ #include <iostream> #include <vector> -#define OMPI_SKIP_MPICXX 1 // workaround for OpenMPI forcing C++ bindings #include <mpi.h> -#undef OMPI_SKIP_MPICXX #include "ADIOS_CPP.h" diff --git a/examples/hello/bpWriter/helloBPWriter_nompi.cpp b/examples/hello/bpWriter/helloBPWriter_nompi.cpp index edb09e086fd8a8d9b20c8b3a04ea51070e5135d8..3936d3eab4aa6f06db4188809cc7a32e0a6d6263 100644 --- a/examples/hello/bpWriter/helloBPWriter_nompi.cpp +++ b/examples/hello/bpWriter/helloBPWriter_nompi.cpp @@ -8,12 +8,14 @@ * Author: wfg */ +#include <ios> #include <iostream> +#include <stdexcept> #include <vector> #include "ADIOS_CPP.h" -int main(int argc, char *argv[]) +int main(int /*argc*/, char ** /*argv*/) { const bool adiosDebug = true; adios::ADIOS adios(adios::Verbose::WARN, adiosDebug); @@ -55,7 +57,9 @@ int main(int argc, char *argv[]) adios::IOMode::COLLECTIVE); if (bpFileWriter == nullptr) + { throw std::ios_base::failure("ERROR: couldn't create bpWriter at Open\n"); + } bpFileWriter->Write<double>( ioMyDoubles, myDoubles.data()); // Base class Engine own the Write<T> diff --git a/examples/hello/datamanReader/CMakeLists.txt b/examples/hello/datamanReader/CMakeLists.txt index f32a2283869203b1157cdb67dc540fe19b7ef90d..3aa3e264ad829cf697e9cd91a6336d6fcf8b668d 100644 --- a/examples/hello/datamanReader/CMakeLists.txt +++ b/examples/hello/datamanReader/CMakeLists.txt @@ -3,8 +3,26 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_datamanReader helloDataManReader.cpp) -target_link_libraries(hello_datamanReader adios2) +if(ADIOS_USE_MPI) + find_package(MPI COMPONENTS C REQUIRED) -add_executable(hello_datamanReader_nompi helloDataManReader_nompi.cpp) -target_link_libraries(hello_datamanReader_nompi adios2) + add_executable(hello_datamanReader helloDataManReader.cpp) + target_link_libraries(hello_datamanReader adios2) + target_include_directories(hello_datamanReader PRIVATE ${MPI_C_INCLUDE_PATH}) + target_link_libraries(hello_datamanReader adios2 ${MPI_C_LIBRARIES}) + + if(ADIOS_BUILD_TESTING) + add_test(NAME Example::hello::datamanReader COMMAND hello_datamanReader) + endif() +else() + add_executable(hello_datamanReader_nompi helloDataManReader_nompi.cpp) + target_link_libraries(hello_datamanReader_nompi adios2) + + if(ADIOS_BUILD_TESTING) + add_test( + NAME Example::hello::datamanReader_nompi + COMMAND hello_datamanReader_nompi + ) + endif() +endif() + diff --git a/examples/hello/datamanWriter/CMakeLists.txt b/examples/hello/datamanWriter/CMakeLists.txt index dee5f38e1823c4a55f22d53954d09c440e1c6ff4..7defd6c40b3bd2eba1802a4e6e99dd41f5de1697 100644 --- a/examples/hello/datamanWriter/CMakeLists.txt +++ b/examples/hello/datamanWriter/CMakeLists.txt @@ -3,8 +3,26 @@ # accompanying file Copyright.txt for details. #------------------------------------------------------------------------------# -add_executable(hello_datamanWriter helloDataManWriter.cpp) -target_link_libraries(hello_datamanWriter adios2) +if(ADIOS_USE_MPI) + find_package(MPI COMPONENTS C REQUIRED) + + add_executable(hello_datamanWriter helloDataManWriter.cpp) + target_link_libraries(hello_datamanWriter adios2) + target_include_directories(hello_datamanWriter PRIVATE ${MPI_C_INCLUDE_PATH}) + target_link_libraries(hello_datamanWriter adios2 ${MPI_C_LIBRARIES}) + + if(ADIOS_BUILD_TESTING) + add_test(NAME Example::hello::datamanWriter COMMAND hello_datamanWriter) + endif() +else() + add_executable(hello_datamanWriter_nompi helloDataManWriter_nompi.cpp) + target_link_libraries(hello_datamanWriter_nompi adios2) + + if(ADIOS_BUILD_TESTING) + add_test( + NAME Example::hello::datamanWriter_nompi + COMMAND hello_datamanWriter_nompi + ) + endif() +endif() -add_executable(hello_datamanWriter_nompi helloDataManWriter_nompi.cpp) -target_link_libraries(hello_datamanWriter_nompi adios2) diff --git a/examples/hello/timeBP/CMakeLists.txt b/examples/hello/timeBP/CMakeLists.txt index a0e38282532c2bf6cd2c2c726a809e2dd2ea2cac..d86828c90625a3a4e34952730fcd6ed9631c2949 100644 --- a/examples/hello/timeBP/CMakeLists.txt +++ b/examples/hello/timeBP/CMakeLists.txt @@ -9,8 +9,18 @@ if(ADIOS_USE_MPI) target_link_libraries(hello_timeBPWriter adios2) target_include_directories(hello_timeBPWriter PRIVATE ${MPI_C_INCLUDE_PATH}) target_link_libraries(hello_timeBPWriter adios2 ${MPI_C_LIBRARIES}) -endif() + if(ADIOS_BUILD_TESTING) + add_test(NAME Example::hello::timeBPWriter COMMAND hello_timeBPWriter) + endif() +else() + add_executable(hello_timeBPWriter_nompi timeBPWriter_nompi.cpp) + target_link_libraries(hello_timeBPWriter_nompi adios2) -add_executable(hello_timeBPWriter_nompi timeBPWriter_nompi.cpp) -target_link_libraries(hello_timeBPWriter_nompi adios2) + if(ADIOS_BUILD_TESTING) + add_test( + NAME Example::hello::timeBPWriter_nompi + COMMAND hello_timeBPWriter_nompi + ) + endif() +endif() diff --git a/examples/hello/timeBP/timeBPWriter.cpp b/examples/hello/timeBP/timeBPWriter.cpp index 846151357b20798aa26070aa8e6044267558bb30..280e97e1e7eb08761a1b7ce5f0eba11bb4ed66e6 100644 --- a/examples/hello/timeBP/timeBPWriter.cpp +++ b/examples/hello/timeBP/timeBPWriter.cpp @@ -11,9 +11,7 @@ #include <iostream> #include <vector> -#define OMPI_SKIP_MPICXX 1 // workaround for OpenMPI forcing C++ bindings #include <mpi.h> -#undef OMPI_SKIP_MPICXX #include "ADIOS_CPP.h" diff --git a/examples/hello/timeBP/timeBPWriter_nompi.cpp b/examples/hello/timeBP/timeBPWriter_nompi.cpp index dc4135216764e46c753656f5cac4a3f4a1fdc4d9..48fdd2bbf3111f3c36b550c927d03b475893bf4e 100644 --- a/examples/hello/timeBP/timeBPWriter_nompi.cpp +++ b/examples/hello/timeBP/timeBPWriter_nompi.cpp @@ -13,7 +13,7 @@ #include "ADIOS_CPP.h" -int main(int argc, char *argv[]) +int main(int /*argc*/, char ** /*argv*/) { const bool adiosDebug = true; adios::ADIOS adios(adios::Verbose::ERROR, adiosDebug); diff --git a/include/core/Method.h b/include/core/Method.h index 686391f96e01de5dae3cae4d2e7de29e91ce3802..f213022eb7ee26dab41c5ac9bad4e548dd77a4f0 100644 --- a/include/core/Method.h +++ b/include/core/Method.h @@ -58,9 +58,9 @@ public: * @param name is a label that can be used in the config file to set up the * method at runtime */ - Method(const std::string name, const bool debugMode = false); + Method(std::string name, bool debugMode = false); - ~Method(); + ~Method() = default; /** Check if the method was defined by the user in the config file. * @return true if the method was user-defined, false otherwise when method is @@ -135,6 +135,6 @@ private: const std::vector<std::string> ¶meters); }; -} // end namespace +} // end namespace adios #endif /* METHOD_H_ */ diff --git a/include/core/Support.h b/include/core/Support.h index 481f8fb4185ec57f73c60369a1fc8a019152d1af..bb9b451e842f07afbe38d9d3b36da864594e0c65 100644 --- a/include/core/Support.h +++ b/include/core/Support.h @@ -51,6 +51,6 @@ struct Support }; }; -} // end namespace +} // end namespace adios #endif /* SUPPORT_H_ */ diff --git a/include/core/Transform.h b/include/core/Transform.h index 190541dac62c8c84f93abf05eb20d9a6e65194fd..a6a6dc75ab80f232f8f08e724837d6b83655b7e2 100644 --- a/include/core/Transform.h +++ b/include/core/Transform.h @@ -33,9 +33,9 @@ public: * Initialize parent method * @param method zlib, bzip2, szip */ - Transform(const std::string method); + Transform(std::string method); - virtual ~Transform(); + virtual ~Transform() = default; virtual void Compress(const std::vector<char> &bufferIn, std::vector<char> &bufferOut); @@ -44,5 +44,5 @@ public: std::vector<char> &bufferOut); }; -} // end namespace +} // end namespace adios #endif /* TRANSFORM_H_ */ diff --git a/include/core/Transport.h b/include/core/Transport.h index 8b768825a2a5a28688540a5ed581de4d58b21783..0851a9b745462907db42bfd843fa224fd2471c4a 100644 --- a/include/core/Transport.h +++ b/include/core/Transport.h @@ -44,9 +44,9 @@ public: * @param mpiComm passed to m_MPIComm * @param debugMode passed to m_DebugMode */ - Transport(const std::string type, MPI_Comm mpiComm, const bool debugMode); + Transport(std::string type, MPI_Comm mpiComm, bool debugMode); - virtual ~Transport(); ///< empty destructor, using STL for memory management + virtual ~Transport() = default; /** * Open Output file accesing a mode @@ -82,6 +82,6 @@ protected: const bool m_DebugMode = false; ///< if true: additional checks and exceptions }; -} // end namespace +} // end namespace adios #endif /* TRANSPORT_H_ */ diff --git a/include/engine/bp/BPFileReader.h b/include/engine/bp/BPFileReader.h index 3613ef2833a3e50d86fa6653f0e86105ae7de874..4f4c451532db4769ed6f296e7b342b93cf36c857 100644 --- a/include/engine/bp/BPFileReader.h +++ b/include/engine/bp/BPFileReader.h @@ -35,13 +35,12 @@ public: * @param debugMode * @param hostLanguage */ - BPFileReader(ADIOS &adios, const std::string name, - const std::string accessMode, MPI_Comm mpiComm, - const Method &method, const IOMode iomode, - const float timeout_sec, const bool debugMode = false, - const unsigned int nthreads = 1); + BPFileReader(ADIOS &adios, std::string name, std::string accessMode, + MPI_Comm mpiComm, const Method &method, IOMode iomode, + float timeout_sec, bool debugMode = false, + unsigned int nthreads = 1); - ~BPFileReader(); + virtual ~BPFileReader() = default; Variable<void> *InquireVariable(const std::string name, const bool readIn = true); diff --git a/include/mpidummy.h b/include/mpidummy.h index 65b380f5cd4a229e87ddffad8bb24c806bf452a6..86122ede8af34481a719166a9df32f9cddacd835 100644 --- a/include/mpidummy.h +++ b/include/mpidummy.h @@ -73,34 +73,35 @@ int MPI_Comm_size(MPI_Comm comm, int *size); int MPI_Comm_free(MPI_Comm *comm); MPI_Comm MPI_Comm_f2c(MPI_Fint comm); -int MPI_Gather(void *sendbuf, int sendcnt, MPI_Datatype sendtype, void *recvbuf, - int recvcnt, MPI_Datatype recvtype, int root, MPI_Comm comm); -int MPI_Gatherv(void *sendbuf, int sendcnt, MPI_Datatype sendtype, - void *recvbuf, int *recvcnts, int *displs, +int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, + void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, + MPI_Comm comm); +int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, + void *recvbuf, const int *recvcounts, const int *displs, MPI_Datatype recvtype, int root, MPI_Comm comm); -int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, +int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm); -int MPI_Scatter(void *sendbuf, int sendcnt, MPI_Datatype sendtype, - void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, +int MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype, + void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm); -int MPI_Scatterv(void *sendbuf, int *sendcnts, int *displs, - MPI_Datatype sendtype, void *recvbuf, int recvcnt, +int MPI_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs, + MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm); -int MPI_Recv(void *recvbuffer, int count, MPI_Datatype type, int source, - int tag, MPI_Comm comm, MPI_Status *status); -int MPI_Irecv(void *recvbuffer, int count, MPI_Datatype type, int source, - int tag, MPI_Comm comm, MPI_Request *request); -int MPI_Send(void *sendbuffer, int count, MPI_Datatype type, int destination, +int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, + MPI_Comm comm, MPI_Status *status); +int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source, int tag, + MPI_Comm comm, MPI_Request *request); +int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm); -int MPI_Isend(void *recvbuffer, int count, MPI_Datatype type, int source, +int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request); int MPI_Wait(MPI_Request *request, MPI_Status *status); -int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, +int MPI_File_open(MPI_Comm comm, const char *filename, int amode, MPI_Info info, MPI_File *fh); int MPI_File_close(MPI_File *fh); int MPI_File_get_size(MPI_File fh, MPI_Offset *size); @@ -108,7 +109,7 @@ int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status); int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence); -int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count); +int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count); int MPI_Error_string(int errorcode, char *string, int *resultlen); int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *comm_out); diff --git a/include/transport/file/FStream.h b/include/transport/file/FStream.h index 163b96478e23334fcf2fc0ab8afe1b824789d9f2..8553c35981ebdb87048631033f293404f3774f88 100644 --- a/include/transport/file/FStream.h +++ b/include/transport/file/FStream.h @@ -31,7 +31,7 @@ class FStream : public Transport public: FStream(MPI_Comm mpiComm, const bool debugMode); - ~FStream(); + virtual ~FStream() = default; void Open(const std::string name, const std::string accessMode); @@ -48,6 +48,6 @@ private: }; } // end namespace transport -} // end namespace +} // end namespace adios #endif /* FSTREAM_H_ */ diff --git a/source/ADIOS.cpp b/source/ADIOS.cpp index a517acd273f08d25b7b40a0fa9eee56913e5c987..d752a127d699ea3726e0db798976356f1eff62e6 100644 --- a/source/ADIOS.cpp +++ b/source/ADIOS.cpp @@ -10,12 +10,14 @@ /// \cond EXCLUDE_FROM_DOXYGEN #include <fstream> +#include <ios> //std::ios_base::failure #include <iostream> #include <sstream> #include <utility> /// \endcond #include "ADIOS.h" + #include "functions/adiosFunctions.h" // Engines diff --git a/source/core/Engine.cpp b/source/core/Engine.cpp index 4f2cb8a44bd1b01054bdb357193cf31c861f1c36..971c29df864270332439466237d7da307315b7d9 100644 --- a/source/core/Engine.cpp +++ b/source/core/Engine.cpp @@ -8,6 +8,8 @@ * Author: wfg */ +#include <ios> //std::ios_base::failure + #include "core/Engine.h" #include "core/Support.h" #include "functions/adiosFunctions.h" diff --git a/source/core/Method.cpp b/source/core/Method.cpp index a97f101fc86f334a5c94bee6d8cdd07d133a4f1c..905b04f9e4c50d6b172c20cfaee909be7309dcb9 100644 --- a/source/core/Method.cpp +++ b/source/core/Method.cpp @@ -8,24 +8,24 @@ * Author: wfg */ +#include <utility> + #include "core/Method.h" #include "functions/adiosFunctions.h" namespace adios { -Method::Method(const std::string name, const bool debugMode) -: m_Name{name}, m_DebugMode{debugMode} +Method::Method(std::string name, bool debugMode) +: m_Name{std::move(name)}, m_DebugMode{debugMode} { // m_Type can stay empty (forcing the choice of the default engine) m_nThreads = 1; } -Method::~Method() {} - bool Method::isUserDefined() { - return false; // TODO: check if XML has the method defined + return false; // TODO(wfg): check if XML has the method defined } void Method::SetEngine(const std::string type) { m_Type = type; } @@ -33,9 +33,13 @@ void Method::SetEngine(const std::string type) { m_Type = type; } void Method::AllowThreads(const int nThreads) { if (nThreads > 1) + { m_nThreads = nThreads; + } else + { m_nThreads = 1; + } } // PRIVATE Functions @@ -45,8 +49,10 @@ void Method::AddTransportParameters(const std::string type, if (m_DebugMode == true) { if (type.empty() || type.find("=") != type.npos) + { throw std::invalid_argument("ERROR: first argument in AddTransport must " "be a single word for transport\n"); + } } std::map<std::string, std::string> mapParameters = @@ -54,13 +60,15 @@ void Method::AddTransportParameters(const std::string type, if (m_DebugMode == true) { if (mapParameters.count("transport") == 1) + { std::invalid_argument( "ERROR: transport can't be redefined with \"transport=type\", " "type must be the first argument\n"); + } } mapParameters["transport"] = type; m_TransportParameters.push_back(mapParameters); } -} // end namespace +} // end namespace adios diff --git a/source/core/Support.cpp b/source/core/Support.cpp index 02be66d86108af579eeafd5805adad1e5a1537b4..65cac135af7ca6a6b428ba5fb5c3a15aedbf7324 100644 --- a/source/core/Support.cpp +++ b/source/core/Support.cpp @@ -19,10 +19,9 @@ const std::string Support::Version{"2.00"}; const std::set<std::string> Support::HostLanguages{{"C++", "C", "Fortran"}}; const std::set<std::string> Support::Transports{ - {"NULL", "POSIX", "FStream", - "MdtmMan"} // "MPI", "MPI_LUSTRE", "MPI_AGGREGATE", "DATASPACES", "DIMES", - // "FLEXPATH", "PHDF5", "NC4", "ICEE" } -}; + {"NULL", "POSIX", "FStream", "MdtmMan"}}; +// TODO(chuckatkins): Add transports MPI, MPI_LUSTRE, MPI_AGGREGATE, +// DATASPACES, DIMES, FLEXPATH, PHDF5, NC4, ICEE const std::set<std::string> Support::Transforms{ {"none", "identity", "bzip2", "isobar", "szip", "zlib"}}; @@ -90,4 +89,4 @@ const std::map<std::string, std::set<std::string>> Support::DatatypesAliases{ const std::set<std::string> Support::FileTransports{ {"POSIX", "File", "FStream", "MPIFile"}}; -} // end namespace +} // end namespace adios diff --git a/source/core/Transform.cpp b/source/core/Transform.cpp index 0b719ccc86bcdf858a93c1417f662982817e45c3..7549342b26640480331644a5bdcc0adaded88a55 100644 --- a/source/core/Transform.cpp +++ b/source/core/Transform.cpp @@ -7,24 +7,23 @@ * Created on: Dec 5, 2016 * Author: wfg */ +#include <utility> #include "core/Transform.h" namespace adios { -Transform::Transform(const std::string method) : m_Method(method) {} +Transform::Transform(std::string method) : m_Method(std::move(method)) {} -Transform::~Transform() {} - -void Transform::Compress(const std::vector<char> &bufferIn, - std::vector<char> &bufferOut) +void Transform::Compress(const std::vector<char> & /*bufferIn*/, + std::vector<char> & /*bufferOut*/) { } -void Transform::Decompress(const std::vector<char> &bufferIn, - std::vector<char> &bufferOut) +void Transform::Decompress(const std::vector<char> & /*bufferIn*/, + std::vector<char> & /*bufferOut*/) { } -} // end namespace +} // end namespace adios diff --git a/source/core/Transport.cpp b/source/core/Transport.cpp index 3f3fd7728137341166862eaa09b6634d80b89942..29fbc773e19e3ecd398f6d4bd79fcae8fe185cda 100644 --- a/source/core/Transport.cpp +++ b/source/core/Transport.cpp @@ -8,22 +8,21 @@ * Author: wfg */ +#include <utility> + #include "core/Transport.h" namespace adios { -Transport::Transport(const std::string type, MPI_Comm mpiComm, - const bool debugMode) -: m_Type{type}, m_MPIComm{mpiComm}, m_DebugMode{debugMode} +Transport::Transport(std::string type, MPI_Comm mpiComm, bool debugMode) +: m_Type{std::move(type)}, m_MPIComm{mpiComm}, m_DebugMode{debugMode} { MPI_Comm_rank(m_MPIComm, &m_RankMPI); MPI_Comm_size(m_MPIComm, &m_SizeMPI); } -Transport::~Transport() {} - -void Transport::SetBuffer(char *buffer, size_t size) {} +void Transport::SetBuffer(char * /*buffer*/, size_t /*size*/) {} void Transport::Flush() {} @@ -35,13 +34,19 @@ void Transport::InitProfiler(const std::string accessMode, m_Profiler.m_Timers.emplace_back("open", Support::Resolutions::mus); if (accessMode == "w" || accessMode == "write") + { m_Profiler.m_Timers.emplace_back("write", resolution); + } else if (accessMode == "a" || accessMode == "append") + { m_Profiler.m_Timers.emplace_back("append", resolution); + } else if (accessMode == "r" || accessMode == "read") + { m_Profiler.m_Timers.emplace_back("read", resolution); + } m_Profiler.m_Timers.emplace_back("close", Support::Resolutions::mus); @@ -49,4 +54,4 @@ void Transport::InitProfiler(const std::string accessMode, m_Profiler.m_IsActive = true; } -} // end namespace +} // end namespace adios diff --git a/source/engine/bp/BPFileReader.cpp b/source/engine/bp/BPFileReader.cpp index 406c752d39d2e8357c1a0a008c2d2a975cf80425..e658e5580d3046b6cde1847a09c65f2d71d5de4e 100644 --- a/source/engine/bp/BPFileReader.cpp +++ b/source/engine/bp/BPFileReader.cpp @@ -21,24 +21,23 @@ namespace adios { -BPFileReader::BPFileReader(ADIOS &adios, const std::string name, - const std::string accessMode, MPI_Comm mpiComm, - const Method &method, const IOMode iomode, - const float timeout_sec, const bool debugMode, - const unsigned int nthreads) -: Engine(adios, "BPFileReader", name, accessMode, mpiComm, method, debugMode, - nthreads, " BPFileReader constructor (or call to ADIOS Open).\n"), +BPFileReader::BPFileReader(ADIOS &adios, std::string name, + std::string accessMode, MPI_Comm mpiComm, + const Method &method, IOMode /*iomode*/, + float /*timeout_sec*/, bool debugMode, + unsigned int nthreads) +: Engine(adios, "BPFileReader", std::move(name), std::move(accessMode), mpiComm, + method, debugMode, nthreads, + " BPFileReader constructor (or call to ADIOS Open).\n"), m_Buffer(accessMode, m_RankMPI, m_DebugMode) { Init(); } -BPFileReader::~BPFileReader() {} - -Variable<void> * -BPFileReader::InquireVariable(const std::string name, - const bool readIn) // not yet implemented +Variable<void> *BPFileReader::InquireVariable(const std::string /*name*/, + const bool /*readIn*/) { + // not yet implemented return nullptr; } @@ -138,13 +137,14 @@ BPFileReader::InquireVariableCLDouble(const std::string name, const bool readIn) return InquireVariableCommon<std::complex<long double>>(name, readIn); } -VariableCompound *BPFileReader::InquireVariableCompound(const std::string name, - const bool readIn) +VariableCompound * +BPFileReader::InquireVariableCompound(const std::string /*name*/, + const bool /*readIn*/) { return nullptr; } -void BPFileReader::Close(const int transportIndex) {} +void BPFileReader::Close(const int /*transportIndex*/) {} // PRIVATE void BPFileReader::Init() @@ -152,9 +152,11 @@ void BPFileReader::Init() if (m_DebugMode == true) { if (m_AccessMode != "r" && m_AccessMode != "read") + { throw std::invalid_argument( "ERROR: BPFileReader doesn't support access mode " + m_AccessMode + ", in call to ADIOS Open or BPFileReader constructor\n"); + } } InitCapsules(); @@ -214,19 +216,23 @@ void BPFileReader::InitTransports() // maybe move this? else { if (m_DebugMode == true) + { throw std::invalid_argument( "ERROR: file transport library " + itLibrary->second + " not supported, in " + m_Name + m_EndMessage); + } } } else { if (m_DebugMode == true) + { throw std::invalid_argument("ERROR: transport " + itTransport->second + " (you mean File?) not supported, in " + m_Name + m_EndMessage); + } } } } -} // end namespace +} // end namespace adios diff --git a/source/engine/bp/BPFileWriter.cpp b/source/engine/bp/BPFileWriter.cpp index 2785781f002d0b499a7bbc328173080f435fb2ff..14f0d149bb0c0e80c266337208bff5c00c99d973 100644 --- a/source/engine/bp/BPFileWriter.cpp +++ b/source/engine/bp/BPFileWriter.cpp @@ -21,8 +21,8 @@ namespace adios BPFileWriter::BPFileWriter(ADIOS &adios, const std::string name, const std::string accessMode, MPI_Comm mpiComm, - const Method &method, const IOMode iomode, - const float timeout_sec, const bool debugMode, + const Method &method, const IOMode /*iomode*/, + const float /*timeout_sec*/, const bool debugMode, const unsigned int nthreads) : Engine(adios, "BPFileWriter", name, accessMode, mpiComm, method, debugMode, nthreads, " BPFileWriter constructor (or call to ADIOS Open).\n"), @@ -34,7 +34,7 @@ BPFileWriter::BPFileWriter(ADIOS &adios, const std::string name, Init(); } -BPFileWriter::~BPFileWriter() {} +BPFileWriter::~BPFileWriter() = default; void BPFileWriter::Init() { @@ -133,7 +133,10 @@ void BPFileWriter::Write(Variable<std::complex<long double>> &variable, WriteVariableCommon(variable, values); } -void BPFileWriter::Write(VariableCompound &variable, const void *values) {} +void BPFileWriter::Write(VariableCompound & /*variable*/, + const void * /*values*/) +{ +} // String version void BPFileWriter::Write(const std::string variableName, const char *values) @@ -232,12 +235,12 @@ void BPFileWriter::Write(const std::string variableName, m_ADIOS.GetVariable<std::complex<long double>>(variableName), values); } -void BPFileWriter::Write(const std::string variableName, - const void *values) // Compound type +void BPFileWriter::Write(const std::string /*variableName*/, + const void * /*values*/) // Compound type { } -void BPFileWriter::Advance(float timeout_sec) +void BPFileWriter::Advance(float /*timeout_sec*/) { m_BP1Writer.Advance(m_MetadataSet, m_Buffer); } @@ -247,10 +250,11 @@ void BPFileWriter::Close(const int transportIndex) CheckTransportIndex(transportIndex); if (transportIndex == -1) { - for (auto &transport : - m_Transports) // by reference or value or it doesn't matter? + for (auto &transport : m_Transports) + { // by reference or value or it doesn't matter? m_BP1Writer.Close(m_MetadataSet, m_Buffer, *transport, m_IsFirstClose, false); // false: not using aggregation for now + } } else { @@ -292,9 +296,11 @@ void BPFileWriter::InitParameters() if (m_DebugMode == true) { if (growthFactor == 1.f) + { throw std::invalid_argument( "ERROR: buffer_growth argument can't be less of equal than 1, in " + m_EndMessage + "\n"); + } } m_BP1Writer.m_GrowthFactor = growthFactor; @@ -307,9 +313,11 @@ void BPFileWriter::InitParameters() if (m_DebugMode == true) { if (m_GrowthFactor <= 1.f) + { throw std::invalid_argument("ERROR: Method buffer_growth argument " "can't be less of equal than 1, in " + m_EndMessage + "\n"); + } } m_MaxBufferSize = std::stoul(itMaxBufferSize->second) * @@ -323,9 +331,11 @@ void BPFileWriter::InitParameters() if (m_DebugMode == true) { if (verbosity < 0 || verbosity > 5) + { throw std::invalid_argument("ERROR: Method verbose argument must be an " "integer in the range [0,5], in call to " "Open or Engine constructor\n"); + } } m_BP1Writer.m_Verbosity = verbosity; } @@ -336,25 +346,33 @@ void BPFileWriter::InitParameters() auto &profiler = m_MetadataSet.Log; if (itProfile->second == "mus" || itProfile->second == "microseconds") + { profiler.m_Timers.emplace_back("buffering", Support::Resolutions::mus); - + } else if (itProfile->second == "ms" || itProfile->second == "milliseconds") + { profiler.m_Timers.emplace_back("buffering", Support::Resolutions::ms); - + } else if (itProfile->second == "s" || itProfile->second == "seconds") + { profiler.m_Timers.emplace_back("buffering", Support::Resolutions::s); - + } else if (itProfile->second == "min" || itProfile->second == "minutes") + { profiler.m_Timers.emplace_back("buffering", Support::Resolutions::m); - + } else if (itProfile->second == "h" || itProfile->second == "hours") + { profiler.m_Timers.emplace_back("buffering", Support::Resolutions::h); + } else { if (m_DebugMode == true) + { throw std::invalid_argument("ERROR: Method profile_buffering_units " "argument must be mus, ms, s, min or h, in " "call to Open or Engine constructor\n"); + } } profiler.m_IsActive = true; @@ -383,26 +401,33 @@ void BPFileWriter::InitTransports() if (itProfile != parameters.end()) { if (itProfile->second == "mus" || itProfile->second == "microseconds") + { resolution = Support::Resolutions::mus; - + } else if (itProfile->second == "ms" || itProfile->second == "milliseconds") + { resolution = Support::Resolutions::ms; - + } else if (itProfile->second == "s" || itProfile->second == "seconds") + { resolution = Support::Resolutions::s; - + } else if (itProfile->second == "min" || itProfile->second == "minutes") + { resolution = Support::Resolutions::m; - + } else if (itProfile->second == "h" || itProfile->second == "hours") + { resolution = Support::Resolutions::h; - + } else { if (m_DebugMode == true) + { throw std::invalid_argument("ERROR: Transport profile_units argument " "must be mus, ms, s, min or h " + m_EndMessage); + } } doProfiling = true; } @@ -418,7 +443,9 @@ void BPFileWriter::InitTransports() auto file = std::make_shared<transport::FileDescriptor>(m_MPIComm, m_DebugMode); if (doProfiling == true) + { file->InitProfiler(m_AccessMode, resolution); + } m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); m_Transports.push_back(std::move(file)); @@ -428,7 +455,9 @@ void BPFileWriter::InitTransports() auto file = std::make_shared<transport::FilePointer>(m_MPIComm, m_DebugMode); if (doProfiling == true) + { file->InitProfiler(m_AccessMode, resolution); + } m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); m_Transports.push_back(std::move(file)); @@ -440,7 +469,9 @@ void BPFileWriter::InitTransports() std::make_shared<transport::FStream>(m_MPIComm, m_DebugMode); if (doProfiling == true) + { file->InitProfiler(m_AccessMode, resolution); + } m_BP1Writer.OpenRankFiles(m_Name, m_AccessMode, *file); m_Transports.push_back(std::move(file)); @@ -451,17 +482,21 @@ void BPFileWriter::InitTransports() else { if (m_DebugMode == true) + { throw std::invalid_argument( "ERROR: file transport library " + itLibrary->second + " not supported, in " + m_Name + m_EndMessage); + } } } else { if (m_DebugMode == true) + { throw std::invalid_argument("ERROR: transport " + itTransport->second + " (you mean File?) not supported, in " + m_Name + m_EndMessage); + } } } } @@ -469,7 +504,9 @@ void BPFileWriter::InitTransports() void BPFileWriter::InitProcessGroup() { if (m_MetadataSet.Log.m_IsActive == true) + { m_MetadataSet.Log.m_Timers[0].SetInitialTime(); + } if (m_AccessMode == "a") { @@ -480,7 +517,9 @@ void BPFileWriter::InitProcessGroup() WriteProcessGroupIndex(); if (m_MetadataSet.Log.m_IsActive == true) + { m_MetadataSet.Log.m_Timers[0].SetTime(); + } } void BPFileWriter::WriteProcessGroupIndex() diff --git a/source/format/BP1.cpp b/source/format/BP1.cpp index c81e7b6fe34fcbb63f5e7e62472051ea99cbd672..e9ec112c5753ab5e7905a016cf17815ad7daa1bc 100644 --- a/source/format/BP1.cpp +++ b/source/format/BP1.cpp @@ -21,10 +21,13 @@ std::string BP1::GetDirectoryName(const std::string name) const noexcept std::string directory; if (name.find(".bp") == name.size() - 3) + { directory = name; + } else + { directory = name + ".bp"; - + } return directory; } @@ -48,15 +51,25 @@ std::vector<std::uint8_t> BP1::GetMethodIDs( auto lf_GetMethodID = [](const std::string method) -> std::uint8_t { int id = METHOD_UNKNOWN; if (method == "NULL") + { id = METHOD_NULL; + } else if (method == "POSIX") + { id = METHOD_POSIX; + } else if (method == "FStream") + { id = METHOD_FSTREAM; + } else if (method == "File") + { id = METHOD_FILE; + } else if (method == "MPI") + { id = METHOD_MPI; + } return id; }; @@ -65,7 +78,9 @@ std::vector<std::uint8_t> BP1::GetMethodIDs( methodIDs.reserve(transports.size()); for (const auto &transport : transports) + { methodIDs.push_back(lf_GetMethodID(transport->m_Type)); + } return methodIDs; } diff --git a/source/format/BP1Aggregator.cpp b/source/format/BP1Aggregator.cpp index c81a72bbffa7ebc2e25a4b3fb9e8873883264202..f0de393a3ef307ed0b1c4959301ca0b3d0b18677 100644 --- a/source/format/BP1Aggregator.cpp +++ b/source/format/BP1Aggregator.cpp @@ -28,7 +28,7 @@ BP1Aggregator::BP1Aggregator(MPI_Comm mpiComm, const bool debugMode) MPI_Comm_size(m_MPIComm, &m_SizeMPI); } -BP1Aggregator::~BP1Aggregator() {} +BP1Aggregator::~BP1Aggregator() = default; void BP1Aggregator::WriteProfilingLog(const std::string fileName, const std::string &rankLog) @@ -44,8 +44,10 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName, // first receive sizes for (unsigned int i = 1; i < sizeMPI; ++i) + { MPI_Irecv(&rankLogsSizes[i - 1], 1, MPI_INT, i, 0, m_MPIComm, &requests[i]); + } for (unsigned int i = 1; i < sizeMPI; ++i) { @@ -53,20 +55,26 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName, if (m_DebugMode == true) { if (rankLogsSizes[i - 1] == -1) + { throw std::runtime_error("ERROR: couldn't get size from rank " + std::to_string(i) + ", in ADIOS aggregator for Profiling.log\n"); + } } rankLogs[i - 1].resize(rankLogsSizes[i - 1]); // allocate with zeros } // receive rankLog from other ranks for (unsigned int i = 1; i < sizeMPI; ++i) + { MPI_Irecv(rankLogs[i - 1].data(), rankLogsSizes[i - 1], MPI_CHAR, i, 1, m_MPIComm, &requests[i]); + } for (unsigned int i = 1; i < sizeMPI; ++i) + { MPI_Wait(&requests[i], &statuses[i]); + } // write file std::string logFile("log = { \n"); @@ -90,8 +98,8 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName, MPI_Isend(&rankLogSize, 1, MPI_INT, 0, 0, m_MPIComm, &requestSize); MPI_Request requestRankLog; - MPI_Isend(const_cast<char *>(rankLog.c_str()), rankLogSize, MPI_CHAR, 0, 1, - m_MPIComm, &requestRankLog); + MPI_Isend(rankLog.data(), rankLogSize, MPI_CHAR, 0, 1, m_MPIComm, + &requestRankLog); } } diff --git a/source/format/BP1Writer.cpp b/source/format/BP1Writer.cpp index b5aed5404ca9804d498b9f1220bc997f93643a14..97b717eebf8846f119326761578b14fb988ce6c9 100644 --- a/source/format/BP1Writer.cpp +++ b/source/format/BP1Writer.cpp @@ -71,7 +71,7 @@ void BP1Writer::WriteProcessGroupIndex( // offset to pg in data in metadata which is the current absolute position CopyToBuffer(metadataBuffer, - reinterpret_cast<std::uint64_t *>(&heap.m_DataAbsolutePosition)); + static_cast<uint64_t *>(&heap.m_DataAbsolutePosition)); // Back to writing metadata pg index length (length of group) const std::uint16_t metadataPGIndexLength = @@ -121,17 +121,23 @@ void BP1Writer::Close(BP1MetadataSet &metadataSet, capsule::STLVector &heap, const bool doAggregation) const noexcept { if (metadataSet.Log.m_IsActive == true) + { metadataSet.Log.m_Timers[0].SetInitialTime(); + } if (isFirstClose == true) { if (metadataSet.DataPGIsOpen == true) + { FlattenData(metadataSet, heap); + } FlattenMetadata(metadataSet, heap); if (metadataSet.Log.m_IsActive == true) + { metadataSet.Log.m_Timers[0].SetInitialTime(); + } if (doAggregation == true) // N-to-M where 1 <= M <= N-1, might need a new // Log metadataSet.Log.m_Timers just for @@ -177,7 +183,9 @@ std::string BP1Writer::GetRankProfilingLog( rankLog += "'lib': " + transports[t]->m_Type + ", "; for (unsigned int i = 0; i < 3; ++i) + { lf_WriterTimer(rankLog, timers[i]); + } rankLog += "}, "; } @@ -196,7 +204,7 @@ void BP1Writer::WriteDimensionsRecord( auto lf_WriteFlaggedDim = [](std::vector<char> &buffer, const char no, const std::size_t dimension) { CopyToBuffer(buffer, &no); - CopyToBuffer(buffer, reinterpret_cast<const std::uint64_t *>(&dimension)); + CopyToBuffer(buffer, static_cast<const uint64_t *>(&dimension)); }; // BODY Starts here @@ -216,8 +224,7 @@ void BP1Writer::WriteDimensionsRecord( { for (const auto &localDimension : localDimensions) { - CopyToBuffer(buffer, - reinterpret_cast<const std::uint64_t *>(&localDimension)); + CopyToBuffer(buffer, static_cast<const uint64_t *>(&localDimension)); buffer.insert(buffer.end(), skip, 0); } } @@ -238,12 +245,11 @@ void BP1Writer::WriteDimensionsRecord( { for (unsigned int d = 0; d < localDimensions.size(); ++d) { - CopyToBuffer(buffer, reinterpret_cast<const std::uint64_t *>( - &localDimensions[d])); - CopyToBuffer(buffer, reinterpret_cast<const std::uint64_t *>( - &globalDimensions[d])); - CopyToBuffer( - buffer, reinterpret_cast<const std::uint64_t *>(&globalOffsets[d])); + CopyToBuffer(buffer, + static_cast<const uint64_t *>(&localDimensions[d])); + CopyToBuffer(buffer, + static_cast<const uint64_t *>(&globalDimensions[d])); + CopyToBuffer(buffer, static_cast<const uint64_t *>(&globalOffsets[d])); } } } @@ -391,7 +397,9 @@ void BP1Writer::FlattenMetadata(BP1MetadataSet &metadataSet, heap.m_DataAbsolutePosition += footerSize; if (metadataSet.Log.m_IsActive == true) + { metadataSet.Log.m_TotalBytes.push_back(heap.m_DataAbsolutePosition); + } } } // end namespace format diff --git a/source/functions/adiosFunctions.cpp b/source/functions/adiosFunctions.cpp index 0886e029ad14a4e6fc4dd8b04b296071175d3678..78393c641f2c502c35728c46e590252ff8580749 100644 --- a/source/functions/adiosFunctions.cpp +++ b/source/functions/adiosFunctions.cpp @@ -37,10 +37,12 @@ void DumpFileToString(const std::string fileName, std::string &fileContent) { std::ifstream fileStream(fileName); - if (fileStream.good() == false) // check file + if (fileStream.good() == false) + { // check file throw std::ios_base::failure( "ERROR: file " + fileName + " could not be opened. Check permissions or file existence\n"); + } std::ostringstream fileSS; fileSS << fileStream.rdbuf(); @@ -48,7 +50,9 @@ void DumpFileToString(const std::string fileName, std::string &fileContent) fileContent = fileSS.str(); // convert to string and check if (fileContent.empty()) + { throw std::invalid_argument("ERROR: file " + fileName + " is empty\n"); + } } void GetSubString(const std::string initialTag, const std::string finalTag, @@ -101,25 +105,35 @@ void GetSubString(const std::string initialTag, const std::string finalTag, (singleQuotePosition == content.npos && end < doubleQuotePosition) || (doubleQuotePosition == content.npos && end < singleQuotePosition) || (end < singleQuotePosition && end < doubleQuotePosition)) + { break; + } // find the closing corresponding quote std::string::size_type closingQuotePosition; - if (singleQuotePosition == content.npos) // no ' anywhere + if (singleQuotePosition == content.npos) + { // no ' anywhere lf_SetPositions('\"', doubleQuotePosition, content, currentPosition, closingQuotePosition); - else if (doubleQuotePosition == content.npos) // no " anywhere + } + else if (doubleQuotePosition == content.npos) + { // no " anywhere lf_SetPositions('\'', singleQuotePosition, content, currentPosition, closingQuotePosition); + } else { if (singleQuotePosition < doubleQuotePosition) + { lf_SetPositions('\'', singleQuotePosition, content, currentPosition, closingQuotePosition); - else // find the closing " + } + else + { // find the closing " lf_SetPositions('\"', doubleQuotePosition, content, currentPosition, closingQuotePosition); + } } if (closingQuotePosition == @@ -132,7 +146,9 @@ void GetSubString(const std::string initialTag, const std::string finalTag, currentPosition = closingQuotePosition + 1; if (closingQuotePosition < end) + { continue; + } // if this point is reached it means it's a value inside " " or ' ', move to // the next end @@ -151,8 +167,10 @@ void GetQuotedValue(const char quote, auto nextQuotePosition = currentTag.find(quote); if (nextQuotePosition == currentTag.npos) + { throw std::invalid_argument("ERROR: Invalid attribute in..." + currentTag + "...check XML file\n"); + } value = currentTag.substr(0, nextQuotePosition); currentTag = currentTag.substr(nextQuotePosition + 1); @@ -201,8 +219,10 @@ void GetPairsFromTag( ">"); // check for closing tagName if (fileContent.find(closingTagName) == fileContent.npos) + { throw std::invalid_argument("ERROR: closing tag " + closingTagName + " missing, check XML file\n"); + } GetPairs(tag, pairs); } @@ -411,7 +431,9 @@ std::size_t GetTotalSize(const std::vector<std::size_t> &dimensions) std::size_t product = 1; for (const auto dimension : dimensions) + { product *= dimension; + } return product; } @@ -420,13 +442,17 @@ void CreateDirectory(const std::string fullPath) noexcept { auto lf_Mkdir = [](const std::string directory, struct stat &st) { if (stat(directory.c_str(), &st) == -1) + { mkdir(directory.c_str(), 0777); + } }; auto directoryPosition = fullPath.find("/"); - if (fullPath[0] == '/' || fullPath[0] == '.') // find the second '/' + if (fullPath[0] == '/' || fullPath[0] == '.') + { // find the second '/' directoryPosition = fullPath.find("/", directoryPosition + 1); + } struct stat st = {0}; if (directoryPosition == fullPath.npos) // no subdirectories @@ -464,9 +490,11 @@ void SetTransformsHelper(const std::vector<std::string> &transformNames, if (debugMode == true) { if (colonPosition == transformName.size() - 1) + { throw std::invalid_argument("ERROR: wrong format for transform " + transformName + ", in call to SetTransform\n"); + } } transformMethod = transformName.substr(0, colonPosition); @@ -528,14 +556,18 @@ BuildParametersMap(const std::vector<std::string> ¶meters, if (debugMode == true) { if (equalPosition == parameter.npos) + { throw std::invalid_argument("ERROR: wrong format for parameter " + parameter + ", format must be field=value \n"); + } if (equalPosition == parameter.size() - 1) + { throw std::invalid_argument("ERROR: empty value in parameter " + parameter + ", format must be field=value \n"); + } } field = parameter.substr(0, equalPosition); @@ -553,8 +585,10 @@ BuildParametersMap(const std::vector<std::string> ¶meters, if (debugMode == true) { if (parametersOutput.count(field) == 1) + { throw std::invalid_argument("ERROR: parameter " + field + " already exists, must be unique\n"); + } } parametersOutput[field] = value; @@ -567,7 +601,9 @@ std::vector<int> CSVToVectorInt(const std::string csv) { std::vector<int> numbers; if (csv.empty()) + { return numbers; + } if (csv.find(",") == csv.npos) // check if no commas, one int { @@ -600,7 +636,9 @@ bool CheckBufferAllocation(const std::size_t newSize, const float growthFactor, bool doTransportsFlush = (requiredDataSize > maxBufferSize) ? true : false; if (GrowBuffer(requiredDataSize, growthFactor, buffer) == -1) + { doTransportsFlush = true; + } return doTransportsFlush; } @@ -639,8 +677,8 @@ int GrowBuffer(const std::size_t incomingDataSize, const float growthFactor, bool IsLittleEndian() noexcept { - std::uint16_t hexa = 0x1234; - return *reinterpret_cast<std::uint8_t *>(&hexa) != 0x12; + uint16_t hexa = 0x1234; + return *reinterpret_cast<uint8_t *>(&hexa) != 0x12; // NOLINT } -} // end namespace +} // namespace adios diff --git a/source/mpidummy.cpp b/source/mpidummy.cpp index a0675138b3bf50af3f0a9e1108da5734207f9289..f85e40a44a64c84718691452db59a420e1b8f369 100644 --- a/source/mpidummy.cpp +++ b/source/mpidummy.cpp @@ -20,9 +20,10 @@ #include <cstring> //#define _LARGEFILE64_SOURCE +#include <unistd.h> + #include <sys/time.h> #include <sys/types.h> -#include <unistd.h> /// \endcond #include "mpidummy.h" @@ -95,8 +96,9 @@ int MPI_Comm_free(MPI_Comm *comm) MPI_Comm MPI_Comm_f2c(MPI_Fint comm) { return comm; } -int MPI_Gather(void *sendbuf, int sendcnt, MPI_Datatype sendtype, void *recvbuf, - int recvcnt, MPI_Datatype recvtype, int root, MPI_Comm comm) +int MPI_Gather(const void *sendbuf, int sendcnt, MPI_Datatype sendtype, + void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, + MPI_Comm comm) { int ier = MPI_SUCCESS; size_t n = 0, nsent = 0, nrecv = 0; @@ -146,8 +148,8 @@ int MPI_Gather(void *sendbuf, int sendcnt, MPI_Datatype sendtype, void *recvbuf, return ier; } -int MPI_Gatherv(void *sendbuf, int sendcnt, MPI_Datatype sendtype, - void *recvbuf, int *recvcnts, int *displs, +int MPI_Gatherv(const void *sendbuf, int sendcnt, MPI_Datatype sendtype, + void *recvbuf, const int *recvcnts, const int *displs, MPI_Datatype recvtype, int root, MPI_Comm comm) { int ier = MPI_SUCCESS; @@ -165,7 +167,7 @@ int MPI_Gatherv(void *sendbuf, int sendcnt, MPI_Datatype sendtype, return ier; } -int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, +int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) { @@ -173,7 +175,7 @@ int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, 0, comm); } -int MPI_Scatter(void *sendbuf, int sendcnt, MPI_Datatype sendtype, +int MPI_Scatter(const void *sendbuf, int sendcnt, MPI_Datatype sendtype, void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, MPI_Comm comm) { @@ -216,7 +218,7 @@ int MPI_Scatter(void *sendbuf, int sendcnt, MPI_Datatype sendtype, if (ier == MPI_SUCCESS) { - memcpy(sendbuf, recvbuf, nsent); + memcpy(recvbuf, sendbuf, nsent); } else { @@ -226,7 +228,7 @@ int MPI_Scatter(void *sendbuf, int sendcnt, MPI_Datatype sendtype, return ier; } -int MPI_Scatterv(void *sendbuf, int *sendcnts, int *displs, +int MPI_Scatterv(const void *sendbuf, const int *sendcnts, const int *displs, MPI_Datatype sendtype, void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, MPI_Comm comm) { @@ -260,13 +262,13 @@ int MPI_Irecv(void * /*recvbuffer*/, int /*count*/, MPI_Datatype /*type*/, return 0; } -int MPI_Send(void * /*sendbuffer*/, int /*count*/, MPI_Datatype /*type*/, +int MPI_Send(const void * /*sendbuffer*/, int /*count*/, MPI_Datatype /*type*/, int /*destination*/, int /*tag*/, MPI_Comm /*comm*/) { return 0; } -int MPI_Isend(void * /*recvbuffer*/, int /*count*/, MPI_Datatype /*type*/, +int MPI_Isend(const void * /*recvbuffer*/, int /*count*/, MPI_Datatype /*type*/, int /*source*/, int /*tag*/, MPI_Comm /*comm*/, MPI_Request * /*request*/) { @@ -275,7 +277,7 @@ int MPI_Isend(void * /*recvbuffer*/, int /*count*/, MPI_Datatype /*type*/, int MPI_Wait(MPI_Request * /*request*/, MPI_Status * /*status*/) { return 0; } -int MPI_File_open(MPI_Comm /*comm*/, char *filename, int amode, +int MPI_File_open(MPI_Comm /*comm*/, const char *filename, int amode, MPI_Info /*info*/, MPI_File *fh) { *fh = open64(filename, amode); @@ -327,7 +329,7 @@ int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence) return MPI_SUCCESS; } -int MPI_Get_count(MPI_Status *status, MPI_Datatype, int *count) +int MPI_Get_count(const MPI_Status *status, MPI_Datatype, int *count) { *count = static_cast<int>(*status); return MPI_SUCCESS; diff --git a/source/transform/BZip2.cpp b/source/transform/BZip2.cpp index 646b8bc6c75ba201e575cf245c54380eff9e712f..c267af7540249968dd42d9e9bb210b2917661150 100644 --- a/source/transform/BZip2.cpp +++ b/source/transform/BZip2.cpp @@ -17,15 +17,15 @@ namespace transform BZIP2::BZIP2() : Transform("bzip2") {} -BZIP2::~BZIP2() {} +BZIP2::~BZIP2() = default; -void BZIP2::Compress(const std::vector<char> &bufferIn, - std::vector<char> &bufferOut) +void BZIP2::Compress(const std::vector<char> & /*bufferIn*/, + std::vector<char> & /*bufferOut*/) { } -void BZIP2::Decompress(const std::vector<char> &bufferIn, - std::vector<char> &bufferOut) +void BZIP2::Decompress(const std::vector<char> & /*bufferIn*/, + std::vector<char> & /*bufferOut*/) { } diff --git a/source/transport/file/FStream.cpp b/source/transport/file/FStream.cpp index 15bf60b58072ae17c4fa5fe171ef65789ea1c395..2a404ae6a96a10471e5ccd97acd547617a73fdb0 100644 --- a/source/transport/file/FStream.cpp +++ b/source/transport/file/FStream.cpp @@ -9,6 +9,7 @@ */ /// \cond EXCLUDED_FROM_DOXYGEN +#include <ios> // std::ios_base::failure #include <stdexcept> /// \endcond @@ -19,33 +20,37 @@ namespace adios namespace transport { -FStream::FStream(MPI_Comm mpiComm, const bool debugMode) +FStream::FStream(MPI_Comm mpiComm, bool debugMode) : Transport("fstream", mpiComm, debugMode) { } -FStream::~FStream() {} - void FStream::Open(const std::string name, const std::string accessMode) { m_Name = name; m_AccessMode = accessMode; if (accessMode == "w" || accessMode == "write") + { m_FStream.open(name, std::fstream::out); - + } else if (accessMode == "a" || accessMode == "append") + { m_FStream.open(name, std::fstream::out | std::fstream::app); - + } else if (accessMode == "r" || accessMode == "read") + { m_FStream.open(name, std::fstream::in); + } if (m_DebugMode == true) { if (!m_FStream) + { throw std::ios_base::failure( "ERROR: couldn't open file " + name + ", in call to Open from FStream transport\n"); + } } } @@ -61,8 +66,10 @@ void FStream::Write(const char *buffer, std::size_t size) if (m_DebugMode == true) { if (!m_FStream) + { throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name + ", in call to FStream write\n"); + } } } @@ -71,4 +78,4 @@ void FStream::Flush() { m_FStream.flush(); } void FStream::Close() { m_FStream.close(); } } // end namespace transport -} // end namespace +} // end namespace adios diff --git a/source/transport/file/FileDescriptor.cpp b/source/transport/file/FileDescriptor.cpp index d3433d2e50aa1613ef16aa95daf7d4553c51dc49..0d6a87c96826042d79581ec356b9c96d796a85cf 100644 --- a/source/transport/file/FileDescriptor.cpp +++ b/source/transport/file/FileDescriptor.cpp @@ -45,87 +45,115 @@ void FileDescriptor::Open(const std::string name, const std::string accessMode) if (accessMode == "w" || accessMode == "write") { if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[0].SetInitialTime(); + } m_FileDescriptor = open(m_Name.c_str(), O_WRONLY | O_CREAT, 0777); if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[0].SetTime(); + } } else if (accessMode == "a" || accessMode == "append") { if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[0].SetInitialTime(); + } m_FileDescriptor = open(m_Name.c_str(), O_WRONLY | O_APPEND); // we need to change this if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[0].SetTime(); + } } else if (accessMode == "r" || accessMode == "read") { if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[0].SetInitialTime(); + } m_FileDescriptor = open(m_Name.c_str(), O_RDONLY); if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[0].SetTime(); + } } if (m_DebugMode == true) { if (m_FileDescriptor == -1) + { throw std::ios_base::failure("ERROR: couldn't open file " + m_Name + ", from call to Open in FD transport using " "POSIX open. Does file exists?\n"); + } } } void FileDescriptor::Write(const char *buffer, std::size_t size) { if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[1].SetInitialTime(); + } auto writtenSize = write(m_FileDescriptor, buffer, size); if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[1].SetTime(); + } if (m_DebugMode == true) { if (writtenSize == -1) + { throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name + ", in call to POSIX write\n"); + } if (static_cast<std::size_t>(writtenSize) != size) + { throw std::ios_base::failure( "ERROR: written size + " + std::to_string(writtenSize) + " is not equal to intended size " + std::to_string(size) + " in file " + m_Name + ", in call to POSIX write\n"); + } } } void FileDescriptor::Close() { if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[2].SetInitialTime(); + } int status = close(m_FileDescriptor); if (m_Profiler.m_IsActive == true) + { m_Profiler.m_Timers[2].SetTime(); + } if (m_DebugMode == true) { if (status == -1) + { throw std::ios_base::failure("ERROR: couldn't close file " + m_Name + ", in call to POSIX write\n"); + } } m_IsOpen = false; } } // end namespace transport -} // end namespace +} // namespace adios diff --git a/source/transport/file/FilePointer.cpp b/source/transport/file/FilePointer.cpp index 704b93f08d55ad410d25f9a04a501c73d60d49a7..1ba57204e6a6827c7454c688b37b8e2f1d62e2c9 100644 --- a/source/transport/file/FilePointer.cpp +++ b/source/transport/file/FilePointer.cpp @@ -26,8 +26,10 @@ FilePointer::FilePointer(MPI_Comm mpiComm, const bool debugMode) FilePointer::~FilePointer() { - if (m_File != NULL) + if (m_File != nullptr) + { fclose(m_File); + } } void FilePointer::Open(const std::string name, const std::string accessMode) @@ -36,20 +38,26 @@ void FilePointer::Open(const std::string name, const std::string accessMode) m_AccessMode = accessMode; if (accessMode == "w" || accessMode == "write") + { m_File = fopen(name.c_str(), "w"); - + } else if (accessMode == "a" || accessMode == "append") + { m_File = fopen(name.c_str(), "a"); - + } else if (accessMode == "r" || accessMode == "read") + { m_File = fopen(name.c_str(), "r"); + } if (m_DebugMode == true) { - if (m_File == NULL) + if (m_File == nullptr) + { throw std::ios_base::failure("ERROR: couldn't open file " + name + ", " "in call to Open from File* transport\n"); + } } } @@ -60,8 +68,10 @@ void FilePointer::SetBuffer(char *buffer, std::size_t size) if (m_DebugMode == true) { if (status == 1) + { throw std::ios_base::failure("ERROR: could not set buffer in rank " + std::to_string(m_RankMPI) + "\n"); + } } } @@ -72,8 +82,10 @@ void FilePointer::Write(const char *buffer, std::size_t size) if (m_DebugMode == true) { if (ferror(m_File)) + { throw std::ios_base::failure("ERROR: couldn't write to file " + m_Name + ", in call to File* write\n"); + } } } @@ -87,4 +99,4 @@ void FilePointer::Close() } } // end namespace transport -} // end namespace +} // namespace adios diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 0825c4704eca3867613ee2f58fdd5636d2fdee5b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,41 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -set(ADIOS_THIRDPARTY_DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/downloads - CACHE PATH "Download directory for third party dependencies") - -include(ExternalProject) - -# Boilerplate settings for a common external project infrastructure -set(EP_ARGS - DOWNLOAD_DIR ${ADIOS_THIRDPARTY_DOWNLOAD_DIR} - PREFIX . - SOURCE_DIR source - BINARY_DIR build - STAMP_DIR stamp - INSTALL_DIR install) - -# Use Google Test for a unit testing framework -cmake_dependent_option(ADIOS_USE_SYSTEM_GOOGLETEST - "Use a system-supplied Google Test framework" ON - "BUILD_TESTING" OFF) -if(BUILD_TESTING) - if(ADIOS_USE_SYSTEM_GOOGLETEST) - find_package(GTest REQUIRED) - if(NOT GTEST_FOUND) - message(WARNING - "Unable to find Google Test framework. " - "Using an internal version") - set(ADIOS_USE_SYSTEM_GOOGLETEST OFF - CACHE BOOL "Use a system-supplied Google Test framework" FORCE) - endif() - endif() - if(NOT ADIOS_USE_SYSTEM_GOOGLETEST) - add_subdirectory(googletest) - find_package(GTest REQUIRED) - add_dependencies(GTest::GTest googletest) - add_dependencies(GTest::Main googletest) - endif() -endif() diff --git a/thirdparty/googletest/CMakeLists.txt b/thirdparty/googletest/CMakeLists.txt deleted file mode 100644 index 5fc4fa9ee1dfe938e27473fbc1ae7ea0b9c90aea..0000000000000000000000000000000000000000 --- a/thirdparty/googletest/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------------------------------------# -# Distributed under the OSI-approved Apache License, Version 2.0. See -# accompanying file Copyright.txt for details. -#------------------------------------------------------------------------------# - -ExternalProject_Add(googletest - URL https://github.com/google/googletest/archive/release-1.8.0.zip - URL_MD5 adfafc8512ab65fd3cf7955ef0100ff5 - ${EP_ARGS} - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install - -DCMAKE_POLICY_DEFAULT_CMP0048=OLD - -DCMAKE_POLICY_DEFAULT_CMP0063=NEW - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} - -DBUILD_GMOCK=OFF - -DBUILD_GTEST=ON - -Dgtest_build_samples=OFF - -Dgtest_build_tests=OFF - -Dgtest_hide_internal_symbols=ON - -Dgtest_disable_pthreads=OFF - -Dgtest_force_shared_crt=OFF) - -function(get_libfile var name) - if(BUILD_SHARED_LIBS) - set(${var} ${CMAKE_SHARED_LIBRARY_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX} PARENT_SCOPE) - else() - set(${var} ${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX} PARENT_SCOPE) - endif() -endfunction() - -get_libfile(GTEST_LIBRARY gtest) -get_libfile(GTEST_MAIN_LIBRARY gtest_main) -set(GTEST_ROOT ${CMAKE_CURRENT_BINARY_DIR}/install) -set(GTEST_INCLUDE_DIR ${GTEST_ROOT}/include - CACHE PATH "") -set(GTEST_LIBRARY ${GTEST_ROOT}/lib/${GTEST_LIBRARY} - CACHE FILEPATH "") -set(GTEST_MAIN_LIBRARY ${GTEST_ROOT}/lib/${GTEST_MAIN_LIBRARY} - CACHE FILEPATH "")