From eacc85b0dcb66c09686709256e4e9cd16954d433 Mon Sep 17 00:00:00 2001 From: wfg <wfg@pc0098504.ornl.gov> Date: Fri, 7 Apr 2017 17:55:00 -0400 Subject: [PATCH] Fixing clang-format style in several files --- include/core/Engine.h | 4 +- include/engine/adios1/ADIOS1Writer.h | 5 +- include/utilities/format/bp1/BP1Aggregator.h | 41 +- include/utilities/format/bp1/BP1Base.h | 360 +++++++++--------- include/utilities/format/bp1/BP1Structs.h | 63 +-- include/utilities/profiling/iochrono/Timer.h | 49 +-- source/utilities/format/bp1/BP1Aggregator.cpp | 109 +++--- source/utilities/format/bp1/BP1Base.cpp | 71 ++-- source/utilities/profiling/iochrono/Timer.cpp | 106 +++--- 9 files changed, 412 insertions(+), 396 deletions(-) diff --git a/include/core/Engine.h b/include/core/Engine.h index 2e2b1f423..31fce6ca8 100644 --- a/include/core/Engine.h +++ b/include/core/Engine.h @@ -12,13 +12,13 @@ #define ENGINE_H_ /// \cond EXCLUDE_FROM_DOXYGEN -#include <complex> //std::complex +#include <complex> //std::complex +#include <functional> //std::function #include <map> #include <memory> //std::shared_ptr #include <string> #include <utility> //std::pair #include <vector> -#include <functional> //std::function /// \endcond #include "ADIOS_MPI.h" diff --git a/include/engine/adios1/ADIOS1Writer.h b/include/engine/adios1/ADIOS1Writer.h index 17553a885..11a9eb313 100644 --- a/include/engine/adios1/ADIOS1Writer.h +++ b/include/engine/adios1/ADIOS1Writer.h @@ -75,7 +75,8 @@ public: void Write(const std::string &variableName, const int *values); void Write(const std::string &variableName, const unsigned int *values); void Write(const std::string &variableName, const long int *values); - void Write(const std::string &variableName, const unsigned long int *values); + void Write(const std::string &variableName, + const unsigned long int *values); void Write(const std::string &variableName, const long long int *values); void Write(const std::string &variableName, const unsigned long long int *values); @@ -90,7 +91,7 @@ public: const std::complex<long double> *values); void Write(const std::string &variableName, const void *values); - void Advance( const float timeout_sec = 0. ); + void Advance(const float timeout_sec = 0.); /** * Closes a single transport or all transports diff --git a/include/utilities/format/bp1/BP1Aggregator.h b/include/utilities/format/bp1/BP1Aggregator.h index 13f07844b..6e94270bc 100644 --- a/include/utilities/format/bp1/BP1Aggregator.h +++ b/include/utilities/format/bp1/BP1Aggregator.h @@ -29,28 +29,29 @@ 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 - - /** - * Unique constructor - * @param mpiComm coming from engine - */ - BP1Aggregator(MPI_Comm mpiComm, const bool debugMode = false); - - ~BP1Aggregator(); - - /** - * Function that aggregates and writes (from rank = 0) profiling.log in python - * dictionary format - * @param rankLog contain rank profiling info to be aggregated - */ - void WriteProfilingLog(const std::string fileName, - const std::string &rankLog); + 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 + + /** + * Unique constructor + * @param mpiComm coming from engine + */ + BP1Aggregator(MPI_Comm mpiComm, const bool debugMode = false); + + ~BP1Aggregator(); + + /** + * Function that aggregates and writes (from rank = 0) profiling.log in + * python + * dictionary format + * @param rankLog contain rank profiling info to be aggregated + */ + void WriteProfilingLog(const std::string fileName, + const std::string &rankLog); private: - const bool m_DebugMode = false; + const bool m_DebugMode = false; }; } // end namespace format diff --git a/include/utilities/format/bp1/BP1Base.h b/include/utilities/format/bp1/BP1Base.h index bea6ccfda..bb5173103 100644 --- a/include/utilities/format/bp1/BP1Base.h +++ b/include/utilities/format/bp1/BP1Base.h @@ -34,236 +34,244 @@ class BP1Base { public: - /** - * Checks if input name has .bp extension and returns a .bp directory name - * @param name input (might or not have .bp) - * @return either name.bp (name has no .bp) or name (name has .bp extension) - */ - std::string GetDirectoryName(const std::string name) const noexcept; + /** + * Checks if input name has .bp extension and returns a .bp directory name + * @param name input (might or not have .bp) + * @return either name.bp (name has no .bp) or name (name has .bp extension) + */ + std::string GetDirectoryName(const std::string name) const noexcept; - /** - * Opens rank files in the following format: - * if transport.m_MPIComm different from MPI_Comm_SELF --> - * name.bp.dir/name.bp.rank - * @param name might contain .bp or not, if not .bp will be added - * @param accessMode "write" "w", "r" "read", "append" "a" - * @param transport file I/O transport - */ - void OpenRankFiles(const std::string name, const std::string accessMode, - Transport &file) const; + /** + * Opens rank files in the following format: + * if transport.m_MPIComm different from MPI_Comm_SELF --> + * name.bp.dir/name.bp.rank + * @param name might contain .bp or not, if not .bp will be added + * @param accessMode "write" "w", "r" "read", "append" "a" + * @param transport file I/O transport + */ + void OpenRankFiles(const std::string name, const std::string accessMode, + Transport &file) const; protected: - /** - * method type for file I/O - */ - enum IO_METHOD - { - METHOD_UNKNOWN = -2 //!< ADIOS_METHOD_UNKNOWN - , - METHOD_NULL = -1 //!< ADIOS_METHOD_NULL - , - METHOD_MPI = 0 //!< METHOD_MPI - , - METHOD_DATATAP = 1 // OBSOLETE - , - METHOD_POSIX = 2 //!< METHOD_POSIX - , - METHOD_DATASPACES = 3 //!< METHOD_DATASPACES - , - METHOD_VTK = 4 // non-existent - , - METHOD_POSIX_ASCII = 5 // non-existent - , - METHOD_MPI_CIO = 6 // OBSOLETE - , - METHOD_PHDF5 = 7 //!< METHOD_PHDF5 - , - METHOD_PROVENANCE = 8 // OBSOLETE - , - METHOD_MPI_STRIPE = 9 // OBSOLETE - , - METHOD_MPI_LUSTRE = 10 //!< METHOD_MPI_LUSTRE - , - METHOD_MPI_STAGGER = 11 // OBSOLETE - , - METHOD_MPI_AGG = 12 // OBSOLETE - , - METHOD_ADAPTIVE = 13 // OBSOLETE - , - METHOD_POSIX1 = 14 // OBSOLETE - , - METHOD_NC4 = 15 //!< METHOD_NC4 - , - METHOD_MPI_AMR = 16 //!< METHOD_MPI_AMR - , - METHOD_MPI_AMR1 = 17 // OBSOLETE - , - METHOD_FLEXPATH = 18 //!< METHOD_FLEXPATH - , - METHOD_NSSI_STAGING = 19 //!< METHOD_NSSI_STAGING - , - METHOD_NSSI_FILTER = 20 //!< METHOD_NSSI_FILTER - , - METHOD_DIMES = 21 //!< METHOD_DIMES - , - METHOD_VAR_MERGE = 22 //!< METHOD_VAR_MERGE - , - METHOD_MPI_BGQ = 23 //!< METHOD_MPI_BGQ - , - METHOD_ICEE = 24 //!< METHOD_ICEE - , - METHOD_COUNT = 25 //!< METHOD_COUNT - , - METHOD_FSTREAM = 26, - METHOD_FILE = 27, - METHOD_ZMQ = 28, - METHOD_MDTM = 29 - }; + /** + * method type for file I/O + */ + enum IO_METHOD + { + METHOD_UNKNOWN = -2 //!< ADIOS_METHOD_UNKNOWN + , + METHOD_NULL = -1 //!< ADIOS_METHOD_NULL + , + METHOD_MPI = 0 //!< METHOD_MPI + , + METHOD_DATATAP = 1 // OBSOLETE + , + METHOD_POSIX = 2 //!< METHOD_POSIX + , + METHOD_DATASPACES = 3 //!< METHOD_DATASPACES + , + METHOD_VTK = 4 // non-existent + , + METHOD_POSIX_ASCII = 5 // non-existent + , + METHOD_MPI_CIO = 6 // OBSOLETE + , + METHOD_PHDF5 = 7 //!< METHOD_PHDF5 + , + METHOD_PROVENANCE = 8 // OBSOLETE + , + METHOD_MPI_STRIPE = 9 // OBSOLETE + , + METHOD_MPI_LUSTRE = 10 //!< METHOD_MPI_LUSTRE + , + METHOD_MPI_STAGGER = 11 // OBSOLETE + , + METHOD_MPI_AGG = 12 // OBSOLETE + , + METHOD_ADAPTIVE = 13 // OBSOLETE + , + METHOD_POSIX1 = 14 // OBSOLETE + , + METHOD_NC4 = 15 //!< METHOD_NC4 + , + METHOD_MPI_AMR = 16 //!< METHOD_MPI_AMR + , + METHOD_MPI_AMR1 = 17 // OBSOLETE + , + METHOD_FLEXPATH = 18 //!< METHOD_FLEXPATH + , + METHOD_NSSI_STAGING = 19 //!< METHOD_NSSI_STAGING + , + METHOD_NSSI_FILTER = 20 //!< METHOD_NSSI_FILTER + , + METHOD_DIMES = 21 //!< METHOD_DIMES + , + METHOD_VAR_MERGE = 22 //!< METHOD_VAR_MERGE + , + METHOD_MPI_BGQ = 23 //!< METHOD_MPI_BGQ + , + METHOD_ICEE = 24 //!< METHOD_ICEE + , + METHOD_COUNT = 25 //!< METHOD_COUNT + , + METHOD_FSTREAM = 26, + METHOD_FILE = 27, + METHOD_ZMQ = 28, + METHOD_MDTM = 29 + }; - /** - * DataTypes mapping in BP Format - */ - enum DataTypes - { - type_unknown = -1, //!< type_unknown - type_byte = 0, //!< type_byte - type_short = 1, //!< type_short - type_integer = 2, //!< type_integer - type_long = 4, //!< type_long + /** + * DataTypes mapping in BP Format + */ + enum DataTypes + { + type_unknown = -1, //!< type_unknown + type_byte = 0, //!< type_byte + type_short = 1, //!< type_short + type_integer = 2, //!< type_integer + type_long = 4, //!< type_long - type_unsigned_byte = 50, //!< type_unsigned_byte - type_unsigned_short = 51, //!< type_unsigned_short - type_unsigned_integer = 52, //!< type_unsigned_integer - type_unsigned_long = 54, //!< type_unsigned_long + type_unsigned_byte = 50, //!< type_unsigned_byte + type_unsigned_short = 51, //!< type_unsigned_short + type_unsigned_integer = 52, //!< type_unsigned_integer + type_unsigned_long = 54, //!< type_unsigned_long - type_real = 5, //!< type_real or float - type_double = 6, //!< type_double - type_long_double = 7, //!< type_long_double + type_real = 5, //!< type_real or float + type_double = 6, //!< type_double + type_long_double = 7, //!< type_long_double - type_string = 9, //!< type_string - type_complex = 10, //!< type_complex - type_double_complex = 11, //!< type_double_complex - type_string_array = 12 //!< type_string_array - }; + type_string = 9, //!< type_string + type_complex = 10, //!< type_complex + type_double_complex = 11, //!< type_double_complex + type_string_array = 12 //!< type_string_array + }; - /** - * Characteristic ID in variable metadata - */ - enum VariableCharacteristicID - { - characteristic_value = 0, //!< characteristic_value - characteristic_min = 1, //!< Used to read in older bp file format - characteristic_max = 2, //!< Used to read in older bp file format - characteristic_offset = 3, //!< characteristic_offset - characteristic_dimensions = 4, //!< characteristic_dimensions - characteristic_var_id = 5, //!< characteristic_var_id - characteristic_payload_offset = 6, //!< characteristic_payload_offset - characteristic_file_index = 7, //!< characteristic_file_index - characteristic_time_index = 8, //!< characteristic_time_index - characteristic_bitmap = 9, //!< characteristic_bitmap - characteristic_stat = 10, //!< characteristic_stat - characteristic_transform_type = 11 //!< characteristic_transform_type - }; + /** + * Characteristic ID in variable metadata + */ + enum VariableCharacteristicID + { + characteristic_value = 0, //!< characteristic_value + characteristic_min = 1, //!< Used to read in older bp file format + characteristic_max = 2, //!< Used to read in older bp file format + characteristic_offset = 3, //!< characteristic_offset + characteristic_dimensions = 4, //!< characteristic_dimensions + characteristic_var_id = 5, //!< characteristic_var_id + characteristic_payload_offset = 6, //!< characteristic_payload_offset + characteristic_file_index = 7, //!< characteristic_file_index + characteristic_time_index = 8, //!< characteristic_time_index + characteristic_bitmap = 9, //!< characteristic_bitmap + characteristic_stat = 10, //!< characteristic_stat + characteristic_transform_type = 11 //!< characteristic_transform_type + }; - /** Define statistics type for characteristic ID = 10 in bp1 format */ - enum VariableStatistics - { - statistic_min = 0, - statistic_max = 1, - statistic_cnt = 2, - statistic_sum = 3, - statistic_sum_square = 4, - statistic_hist = 5, - statistic_finite = 6 - }; + /** Define statistics type for characteristic ID = 10 in bp1 format */ + enum VariableStatistics + { + statistic_min = 0, + statistic_max = 1, + statistic_cnt = 2, + statistic_sum = 3, + statistic_sum_square = 4, + statistic_hist = 5, + statistic_finite = 6 + }; - template <class T> struct Stats - { - T Min; - T Max; - std::uint64_t Offset; - std::uint64_t PayloadOffset; - std::uint32_t TimeIndex; - std::uint32_t MemberID; + template <class T> + struct Stats + { + T Min; + T Max; + std::uint64_t Offset; + std::uint64_t PayloadOffset; + std::uint32_t TimeIndex; + std::uint32_t MemberID; - // unsigned long int count; - // long double sum; - // long double sumSquare; - // unsigned long int histogram - // bool finite?? - }; + // unsigned long int count; + // long double sum; + // long double sumSquare; + // unsigned long int histogram + // bool finite?? + }; - /** - * Returns data type index from enum Datatypes - * @param variable input variable - * @return data type - */ - template <class T> inline std::int8_t GetDataType() const noexcept - { - return type_unknown; - } + /** + * Returns data type index from enum Datatypes + * @param variable input variable + * @return data type + */ + template <class T> + inline std::int8_t GetDataType() const noexcept + { + return type_unknown; + } - std::vector<std::uint8_t> - GetMethodIDs(const std::vector<std::shared_ptr<Transport>> &transports) const - noexcept; + std::vector<std::uint8_t> GetMethodIDs( + const std::vector<std::shared_ptr<Transport>> &transports) const + noexcept; }; // Moving template BP1Writer::GetDataType template specializations outside of // the class -template <> inline std::int8_t BP1Base::GetDataType<char>() const noexcept +template <> +inline std::int8_t BP1Base::GetDataType<char>() const noexcept { - return type_byte; + return type_byte; } -template <> inline std::int8_t BP1Base::GetDataType<short>() const noexcept +template <> +inline std::int8_t BP1Base::GetDataType<short>() const noexcept { - return type_short; + return type_short; } -template <> inline std::int8_t BP1Base::GetDataType<int>() const noexcept +template <> +inline std::int8_t BP1Base::GetDataType<int>() const noexcept { - return type_integer; + return type_integer; } -template <> inline std::int8_t BP1Base::GetDataType<long int>() const noexcept +template <> +inline std::int8_t BP1Base::GetDataType<long int>() const noexcept { - return type_long; + return type_long; } template <> inline std::int8_t BP1Base::GetDataType<unsigned char>() const noexcept { - return type_unsigned_byte; + return type_unsigned_byte; } template <> inline std::int8_t BP1Base::GetDataType<unsigned short>() const noexcept { - return type_unsigned_short; + return type_unsigned_short; } template <> inline std::int8_t BP1Base::GetDataType<unsigned int>() const noexcept { - return type_unsigned_integer; + return type_unsigned_integer; } template <> inline std::int8_t BP1Base::GetDataType<unsigned long int>() const noexcept { - return type_unsigned_long; + return type_unsigned_long; } -template <> inline std::int8_t BP1Base::GetDataType<float>() const noexcept +template <> +inline std::int8_t BP1Base::GetDataType<float>() const noexcept { - return type_real; + return type_real; } -template <> inline std::int8_t BP1Base::GetDataType<double>() const noexcept +template <> +inline std::int8_t BP1Base::GetDataType<double>() const noexcept { - return type_double; + return type_double; } template <> inline std::int8_t BP1Base::GetDataType<long double>() const noexcept { - return type_long_double; + return type_long_double; } } // end namespace format diff --git a/include/utilities/format/bp1/BP1Structs.h b/include/utilities/format/bp1/BP1Structs.h index 10ca50eae..c0c50a0a6 100644 --- a/include/utilities/format/bp1/BP1Structs.h +++ b/include/utilities/format/bp1/BP1Structs.h @@ -32,15 +32,15 @@ namespace format */ struct BP1Index { - std::vector<char> Buffer; ///< metadata variable index, start with 100Kb - std::uint64_t Count = - 0; ///< number of characteristics sets (time and spatial aggregation) - const std::uint32_t MemberID; - - BP1Index(const std::uint32_t memberID) : MemberID{memberID} - { - Buffer.reserve(500); - } + std::vector<char> Buffer; ///< metadata variable index, start with 100Kb + std::uint64_t Count = + 0; ///< number of characteristics sets (time and spatial aggregation) + const std::uint32_t MemberID; + + BP1Index(const std::uint32_t memberID) : MemberID{memberID} + { + Buffer.reserve(500); + } }; /** @@ -48,36 +48,37 @@ struct BP1Index */ struct BP1MetadataSet { - std::uint32_t TimeStep; ///< current time step, updated with advance step, if - /// append it will be updated to last, starts with one in ADIOS1 + std::uint32_t + TimeStep; ///< current time step, updated with advance step, if + /// append it will be updated to last, starts with one in ADIOS1 - BP1Index PGIndex = BP1Index(0); ///< single buffer for PGIndex + BP1Index PGIndex = BP1Index(0); ///< single buffer for PGIndex - // no priority for now - /** @brief key: variable name, value: bp metadata variable index */ - std::unordered_map<std::string, BP1Index> VarsIndices; + // no priority for now + /** @brief key: variable name, value: bp metadata variable index */ + std::unordered_map<std::string, BP1Index> VarsIndices; - std::unordered_map<std::string, BP1Index> - AttributesIndices; ///< key: name, value: attribute bp index + std::unordered_map<std::string, BP1Index> + AttributesIndices; ///< key: name, value: attribute bp index - const unsigned int MiniFooterSize = 28; ///< from bpls reader + const unsigned int MiniFooterSize = 28; ///< from bpls reader - // PG (relative) positions in Data buffer to be updated - std::uint64_t DataPGCount = 0; - std::size_t DataPGLengthPosition = 0; ///< current PG initial ( relative ) - /// position, needs to be updated in - /// every advance step or init - std::uint32_t DataPGVarsCount = 0; ///< variables in current PG + // PG (relative) positions in Data buffer to be updated + std::uint64_t DataPGCount = 0; + std::size_t DataPGLengthPosition = 0; ///< current PG initial ( relative ) + /// position, needs to be updated in + /// every advance step or init + std::uint32_t DataPGVarsCount = 0; ///< variables in current PG - /** - * current PG variable count ( relative ) position, needs to be - * updated in very Advance - */ - std::size_t DataPGVarsCountPosition = 0; + /** + * current PG variable count ( relative ) position, needs to be + * updated in very Advance + */ + std::size_t DataPGVarsCountPosition = 0; - bool DataPGIsOpen = false; + bool DataPGIsOpen = false; - profiling::IOChrono Log; ///< object that takes buffering profiling info + profiling::IOChrono Log; ///< object that takes buffering profiling info }; } // end namespace format diff --git a/include/utilities/profiling/iochrono/Timer.h b/include/utilities/profiling/iochrono/Timer.h index 0353fde67..9bc7817a9 100644 --- a/include/utilities/profiling/iochrono/Timer.h +++ b/include/utilities/profiling/iochrono/Timer.h @@ -27,32 +27,33 @@ class Timer { public: - const std::string m_Process; - unsigned long long int m_ProcessTime = 0; - - /** - * Timer object constructor using std::chrono class - * @param process name of process to be measured - * @param resolution time resolution (mus, ms, s, etc.) from Resolutions in - * core/Support.h - * @param debugMode true: additional checks and exceptions, false: no checks - */ - Timer(const std::string process, const Support::Resolutions resolution, - const bool debugMode = false); - - ~Timer(); - - void SetInitialTime(); ///< set time to start counting for a process - void SetTime(); ///< sets time to measure, it will add to overall process time - std::string GetUnits() const; + const std::string m_Process; + unsigned long long int m_ProcessTime = 0; + + /** + * Timer object constructor using std::chrono class + * @param process name of process to be measured + * @param resolution time resolution (mus, ms, s, etc.) from Resolutions in + * core/Support.h + * @param debugMode true: additional checks and exceptions, false: no checks + */ + Timer(const std::string process, const Support::Resolutions resolution, + const bool debugMode = false); + + ~Timer(); + + void SetInitialTime(); ///< set time to start counting for a process + void + SetTime(); ///< sets time to measure, it will add to overall process time + std::string GetUnits() const; private: - const Support::Resolutions m_Resolution; - const bool m_DebugMode = false; - std::chrono::time_point<std::chrono::high_resolution_clock> m_InitialTime; - std::chrono::time_point<std::chrono::high_resolution_clock> m_ElapsedTime; - bool m_InitialTimeSet = false; - long long int GetCurrentTime(); ///< called by SetTime + const Support::Resolutions m_Resolution; + const bool m_DebugMode = false; + std::chrono::time_point<std::chrono::high_resolution_clock> m_InitialTime; + std::chrono::time_point<std::chrono::high_resolution_clock> m_ElapsedTime; + bool m_InitialTimeSet = false; + long long int GetCurrentTime(); ///< called by SetTime }; } // end namespace profiling diff --git a/source/utilities/format/bp1/BP1Aggregator.cpp b/source/utilities/format/bp1/BP1Aggregator.cpp index 2d2ff740a..777aa2f53 100644 --- a/source/utilities/format/bp1/BP1Aggregator.cpp +++ b/source/utilities/format/bp1/BP1Aggregator.cpp @@ -24,8 +24,8 @@ namespace format BP1Aggregator::BP1Aggregator(MPI_Comm mpiComm, const bool debugMode) : m_MPIComm{mpiComm}, m_DebugMode{debugMode} { - MPI_Comm_rank(m_MPIComm, &m_RankMPI); - MPI_Comm_size(m_MPIComm, &m_SizeMPI); + MPI_Comm_rank(m_MPIComm, &m_RankMPI); + MPI_Comm_size(m_MPIComm, &m_SizeMPI); } BP1Aggregator::~BP1Aggregator() {} @@ -33,65 +33,66 @@ BP1Aggregator::~BP1Aggregator() {} void BP1Aggregator::WriteProfilingLog(const std::string fileName, const std::string &rankLog) { - if (m_RankMPI == 0) - { - unsigned int sizeMPI = static_cast<unsigned int>(m_SizeMPI); - std::vector<std::vector<char>> rankLogs(sizeMPI - 1); // other ranks - std::vector<int> rankLogsSizes(sizeMPI - 1, -1); // init with -1 - std::vector<MPI_Request> requests(sizeMPI); - std::vector<MPI_Status> statuses(sizeMPI); + if (m_RankMPI == 0) + { + unsigned int sizeMPI = static_cast<unsigned int>(m_SizeMPI); + std::vector<std::vector<char>> rankLogs(sizeMPI - 1); // other ranks + std::vector<int> rankLogsSizes(sizeMPI - 1, -1); // init with -1 + std::vector<MPI_Request> requests(sizeMPI); + std::vector<MPI_Status> statuses(sizeMPI); - // 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]); + // 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) - { - MPI_Wait(&requests[i], &statuses[i]); - 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 - } + for (unsigned int i = 1; i < sizeMPI; ++i) + { + MPI_Wait(&requests[i], &statuses[i]); + 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]); + // 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]); + for (unsigned int i = 1; i < sizeMPI; ++i) + MPI_Wait(&requests[i], &statuses[i]); - // write file - std::string logFile("log = { \n"); - logFile += rankLog + "\n"; - for (unsigned int i = 1; i < sizeMPI; ++i) - { - const std::string rankLogStr(rankLogs[i - 1].data(), - rankLogs[i - 1].size()); - logFile += rankLogStr + "\n"; - } - logFile += " }\n"; + // write file + std::string logFile("log = { \n"); + logFile += rankLog + "\n"; + for (unsigned int i = 1; i < sizeMPI; ++i) + { + const std::string rankLogStr(rankLogs[i - 1].data(), + rankLogs[i - 1].size()); + logFile += rankLogStr + "\n"; + } + logFile += " }\n"; - std::ofstream logStream(fileName); - logStream.write(logFile.c_str(), logFile.size()); - logStream.close(); - } - else - { - int rankLogSize = static_cast<int>(rankLog.size()); - MPI_Request requestSize; - MPI_Isend(&rankLogSize, 1, MPI_INT, 0, 0, m_MPIComm, &requestSize); + std::ofstream logStream(fileName); + logStream.write(logFile.c_str(), logFile.size()); + logStream.close(); + } + else + { + int rankLogSize = static_cast<int>(rankLog.size()); + MPI_Request requestSize; + 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_Request requestRankLog; + MPI_Isend(const_cast<char *>(rankLog.c_str()), rankLogSize, MPI_CHAR, 0, + 1, m_MPIComm, &requestRankLog); + } } } // end namespace format diff --git a/source/utilities/format/bp1/BP1Base.cpp b/source/utilities/format/bp1/BP1Base.cpp index b6eea6a7f..9c4472457 100644 --- a/source/utilities/format/bp1/BP1Base.cpp +++ b/source/utilities/format/bp1/BP1Base.cpp @@ -18,57 +18,60 @@ namespace format std::string BP1Base::GetDirectoryName(const std::string name) const noexcept { - std::string directory; + std::string directory; - if (name.find(".bp") == name.size() - 3) - directory = name; - else - directory = name + ".bp"; - - return directory; + if (name.find(".bp") == name.size() - 3) + { + directory = name; + } + else + { + directory = name + ".bp"; + } + return directory; } // this should go outside void BP1Base::OpenRankFiles(const std::string name, const std::string accessMode, Transport &file) const { - const std::string directory = GetDirectoryName(name); - CreateDirectory( - directory); // creates a directory and sub-directories recursively + const std::string directory = GetDirectoryName(name); + CreateDirectory( + directory); // creates a directory and sub-directories recursively - std::string fileName(directory + "/" + directory + "." + - std::to_string(file.m_RankMPI)); - file.Open(fileName, accessMode); // opens a file transport under - // name.bp/name.bp.rank reserve that - // location for writing + std::string fileName(directory + "/" + directory + "." + + std::to_string(file.m_RankMPI)); + file.Open(fileName, accessMode); // opens a file transport under + // name.bp/name.bp.rank reserve that + // location for writing } std::vector<std::uint8_t> BP1Base::GetMethodIDs( const std::vector<std::shared_ptr<Transport>> &transports) const noexcept { - 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; + 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; - }; + return id; + }; - std::vector<std::uint8_t> methodIDs; - methodIDs.reserve(transports.size()); + std::vector<std::uint8_t> methodIDs; + methodIDs.reserve(transports.size()); - for (const auto &transport : transports) - methodIDs.push_back(lf_GetMethodID(transport->m_Type)); + for (const auto &transport : transports) + methodIDs.push_back(lf_GetMethodID(transport->m_Type)); - return methodIDs; + return methodIDs; } } // end namespace format diff --git a/source/utilities/profiling/iochrono/Timer.cpp b/source/utilities/profiling/iochrono/Timer.cpp index 7aab0c5a0..797cb32b9 100644 --- a/source/utilities/profiling/iochrono/Timer.cpp +++ b/source/utilities/profiling/iochrono/Timer.cpp @@ -25,75 +25,75 @@ Timer::~Timer() {} void Timer::SetInitialTime() { - m_InitialTime = std::chrono::high_resolution_clock::now(); - m_InitialTimeSet = true; + m_InitialTime = std::chrono::high_resolution_clock::now(); + m_InitialTimeSet = true; } void Timer::SetTime() { - m_ElapsedTime = std::chrono::high_resolution_clock::now(); - m_ProcessTime += GetCurrentTime(); + m_ElapsedTime = std::chrono::high_resolution_clock::now(); + m_ProcessTime += GetCurrentTime(); } std::string Timer::GetUnits() const { - std::string units; - if (m_Resolution == Support::Resolutions::mus) - units = "mus"; - else if (m_Resolution == Support::Resolutions::ms) - units = "ms"; - else if (m_Resolution == Support::Resolutions::s) - units = "s"; - else if (m_Resolution == Support::Resolutions::m) - units = "m"; - else if (m_Resolution == Support::Resolutions::h) - units = "h"; - return units; + std::string units; + if (m_Resolution == Support::Resolutions::mus) + units = "mus"; + else if (m_Resolution == Support::Resolutions::ms) + units = "ms"; + else if (m_Resolution == Support::Resolutions::s) + units = "s"; + else if (m_Resolution == Support::Resolutions::m) + units = "m"; + else if (m_Resolution == Support::Resolutions::h) + units = "h"; + return units; } // PRIVATE long long int Timer::GetCurrentTime() { - if (m_DebugMode == true) - { - if (m_InitialTimeSet == false) - throw std::invalid_argument("ERROR: SetInitialTime() in process " + - m_Process + " not called\n"); - } + if (m_DebugMode == true) + { + if (m_InitialTimeSet == false) + throw std::invalid_argument("ERROR: SetInitialTime() in process " + + m_Process + " not called\n"); + } - if (m_Resolution == Support::Resolutions::mus) - { - return std::chrono::duration_cast<std::chrono::microseconds>(m_ElapsedTime - - m_InitialTime) - .count(); - } - else if (m_Resolution == Support::Resolutions::ms) - { - return std::chrono::duration_cast<std::chrono::milliseconds>(m_ElapsedTime - - m_InitialTime) - .count(); - } - else if (m_Resolution == Support::Resolutions::s) - { - return std::chrono::duration_cast<std::chrono::seconds>(m_ElapsedTime - - m_InitialTime) - .count(); - } - else if (m_Resolution == Support::Resolutions::m) - { - return std::chrono::duration_cast<std::chrono::minutes>(m_ElapsedTime - - m_InitialTime) - .count(); - } - else if (m_Resolution == Support::Resolutions::h) - { - return std::chrono::duration_cast<std::chrono::hours>(m_ElapsedTime - - m_InitialTime) - .count(); - } + if (m_Resolution == Support::Resolutions::mus) + { + return std::chrono::duration_cast<std::chrono::microseconds>( + m_ElapsedTime - m_InitialTime) + .count(); + } + else if (m_Resolution == Support::Resolutions::ms) + { + return std::chrono::duration_cast<std::chrono::milliseconds>( + m_ElapsedTime - m_InitialTime) + .count(); + } + else if (m_Resolution == Support::Resolutions::s) + { + return std::chrono::duration_cast<std::chrono::seconds>(m_ElapsedTime - + m_InitialTime) + .count(); + } + else if (m_Resolution == Support::Resolutions::m) + { + return std::chrono::duration_cast<std::chrono::minutes>(m_ElapsedTime - + m_InitialTime) + .count(); + } + else if (m_Resolution == Support::Resolutions::h) + { + return std::chrono::duration_cast<std::chrono::hours>(m_ElapsedTime - + m_InitialTime) + .count(); + } - return -1; // failure + return -1; // failure } } // end namespace -- GitLab