diff options
Diffstat (limited to 'Source/Utils/MsgLogger')
-rw-r--r-- | Source/Utils/MsgLogger/MsgLogger.H | 7 | ||||
-rw-r--r-- | Source/Utils/MsgLogger/MsgLogger.cpp | 18 |
2 files changed, 12 insertions, 13 deletions
diff --git a/Source/Utils/MsgLogger/MsgLogger.H b/Source/Utils/MsgLogger/MsgLogger.H index ca55289b2..d5d7e207c 100644 --- a/Source/Utils/MsgLogger/MsgLogger.H +++ b/Source/Utils/MsgLogger/MsgLogger.H @@ -280,10 +280,9 @@ namespace MsgLogger{ #endif - int m_rank = 0 /*! MPI rank of the current process*/; - int m_num_procs = 0 /*! Number of MPI ranks*/; - int m_io_rank = 0 /*! Rank of the I/O process*/; - bool m_am_i_io = false /*! Flag to store if the process is responsible for I/O*/; + const int m_rank /*! MPI rank of the current process*/; + const int m_num_procs /*! Number of MPI ranks*/; + const int m_io_rank /*! Rank of the I/O process*/; std::map<Msg, std::int64_t> m_messages /*! This stores a map to associate warning messages with the corresponding counters*/; }; diff --git a/Source/Utils/MsgLogger/MsgLogger.cpp b/Source/Utils/MsgLogger/MsgLogger.cpp index 9b310a6b7..0120fb2b4 100644 --- a/Source/Utils/MsgLogger/MsgLogger.cpp +++ b/Source/Utils/MsgLogger/MsgLogger.cpp @@ -206,12 +206,11 @@ MsgWithCounterAndRanks::deserialize (std::vector<char>::const_iterator&& it) return MsgWithCounterAndRanks::deserialize(it); } -Logger::Logger(){ - m_rank = amrex::ParallelDescriptor::MyProc(); - m_num_procs = amrex::ParallelDescriptor::NProcs(); - m_io_rank = amrex::ParallelDescriptor::IOProcessorNumber(); - m_am_i_io = (m_rank == m_io_rank); -} +Logger::Logger() : + m_rank{amrex::ParallelDescriptor::MyProc()}, + m_num_procs{amrex::ParallelDescriptor::NProcs()}, + m_io_rank{amrex::ParallelDescriptor::IOProcessorNumber()} +{} void Logger::record_msg(Msg msg) { @@ -250,7 +249,7 @@ Logger::collective_gather_msgs_with_counter_and_ranks() const // Find out who is the "gather rank" and how many messages it has const auto my_msgs = get_msgs(); - const auto how_many_msgs = my_msgs.size(); + const auto how_many_msgs = static_cast<int>(my_msgs.size()); const auto [gather_rank, gather_rank_how_many_msgs] = find_gather_rank_and_its_msgs(how_many_msgs); @@ -323,13 +322,14 @@ std::pair<int,int> Logger::find_gather_rank_and_its_msgs(int how_many_msgs) cons const auto num_msg = amrex::ParallelDescriptor::Gather(how_many_msgs, m_io_rank); + const auto m_am_i_io = (m_rank == m_io_rank); if (m_am_i_io){ const auto it_max = std::max_element(num_msg.begin(), num_msg.end()); max_items = *it_max; //In case of an "ex aequo" the I/O rank should be the gather rank max_rank = (max_items == how_many_msgs) ? - m_io_rank : it_max - num_msg.begin(); + m_io_rank : static_cast<int>(it_max - num_msg.begin()); } auto package = std::array<int,2>{max_rank, max_items}; @@ -575,7 +575,7 @@ gather_all_data( static_cast<int>(package_for_gather_rank.size()), gather_rank); amrex::ParallelDescriptor::Gatherv( package_for_gather_rank.data(), - package_for_gather_rank.size(), + static_cast<int>(package_for_gather_rank.size()), all_data.data(), package_lengths, displacements, |