From 8d65bf5a8d1716bf78b8f9b004131ec9f0375a3d Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 25 Jul 2024 14:40:46 -0700 Subject: [PATCH 1/3] split RANK_COUNT out of RANK for slic message formatting --- RELEASE-NOTES.md | 2 ++ src/axom/slic/core/LogStream.cpp | 2 ++ src/axom/slic/core/LogStream.hpp | 7 +++++- .../docs/sphinx/sections/architecture.rst | 15 ++++++++--- .../examples/basic/lumberjack_logging.cpp | 17 ++++++++++--- src/axom/slic/streams/GenericOutputStream.cpp | 1 + src/axom/slic/streams/LumberjackStream.cpp | 25 +++++++++---------- src/axom/slic/streams/SynchronizedStream.cpp | 1 + 8 files changed, 48 insertions(+), 22 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index e934f14f6e..e09e25104c 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -63,6 +63,8 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/ external `fmt` and axom's vendored copy. - Turn off CMake finding dependencies on system paths. - `axom::Array`: trivially-copyable types with a non-trivial constructor are now initialized on the GPU. +- SLIC no longer outputs the rank count in the `RANK` format string in parallel loggers. You can access + the rank count via new format option `RANK_COUNT`. ### Removed - Removes config option `AXOM_ENABLE_ANNOTATIONS`. Annotations are now provided by `caliper` diff --git a/src/axom/slic/core/LogStream.cpp b/src/axom/slic/core/LogStream.cpp index 17e2efb5c0..42efc78bd9 100644 --- a/src/axom/slic/core/LogStream.cpp +++ b/src/axom/slic/core/LogStream.cpp @@ -69,6 +69,7 @@ std::string LogStream::getFormatedMessage(const std::string& msgLevel, const std::string& message, const std::string& tagName, const std::string& rank, + const std::string& rank_count, const std::string& fileName, int line) { @@ -79,6 +80,7 @@ std::string LogStream::getFormatedMessage(const std::string& msgLevel, this->replaceKey(msg, "", tagName); this->replaceKey(msg, "", fileName); this->replaceKey(msg, "", rank); + this->replaceKey(msg, "", rank_count); if(line != MSG_IGNORE_LINE) { diff --git a/src/axom/slic/core/LogStream.hpp b/src/axom/slic/core/LogStream.hpp index f69eb4218e..9f3b306381 100644 --- a/src/axom/slic/core/LogStream.hpp +++ b/src/axom/slic/core/LogStream.hpp @@ -58,7 +58,8 @@ class LogStream *
  • user-supplied tag
  • *
  • with the filename
  • *
  • with the line number
  • - *
  • with the MPI rank
  • + *
  • with the MPI rank(s)
  • + *
  • with the number of MPI ranks
  • *
  • date/time the message is logged
  • * * @@ -73,6 +74,7 @@ class LogStream * std::string( "* FILE=\n" ) + * std::string( "* LINE=\n" ) + * std::string( "* RANK=\n" ) + + * std::string( "* RANK_COUNT=\n" ) + * std::string( "***********************************\n" ); * \endcode */ @@ -151,6 +153,8 @@ class LogStream * \param [in] tagName user-supplied tag, may be MSG_IGNORE_TAG * \param [in] fileName filename where this message is logged, may be * MSG_IGNORE_FILE to ignore this field. + * \param [in] rank The MPI rank(s) that emitted this message + * \param [in] rank_count the number of MPI ranks that emitted this message * \param [in] line the line number within the file where the message is * logged. Likewise, may be set to MSG_IGNORE_LINE to ignore this field. * @@ -161,6 +165,7 @@ class LogStream const std::string& message, const std::string& tagName, const std::string& rank, + const std::string& rank_count, const std::string& fileName, int line); diff --git a/src/axom/slic/docs/sphinx/sections/architecture.rst b/src/axom/slic/docs/sphinx/sections/architecture.rst index 7b044f2be6..f2df63bc66 100644 --- a/src/axom/slic/docs/sphinx/sections/architecture.rst +++ b/src/axom/slic/docs/sphinx/sections/architecture.rst @@ -151,8 +151,14 @@ The list of keywords is summarized in the table below. | **** | A string tag associated with a given message, e.g., for| | | filtering during post-processing, etc. | +---------------------+--------------------------------------------------------+ -| **** | The MPI rank that emitted the message. Only applicable | -| | when the `Axom Toolkit`_ is compiled with MPI enabled | +| **** | The MPI rank(s) that emitted the message. | +| | Only applicable when Axom is compiled with MPI enabled | +| | and with MPI-aware :ref:`LogStream` instances, such as,| +| | the :ref:`SynchronizedStream` and | +| | :ref:`LumberjackStream`. | ++---------------------+--------------------------------------------------------+ +| **** | The number of MPI ranks that emitted the message. | +| | Only applicable when Axom is compiled with MPI enabled | | | and with MPI-aware :ref:`LogStream` instances, such as,| | | the :ref:`SynchronizedStream` and | | | :ref:`LumberjackStream`. | @@ -221,7 +227,7 @@ Generic Output Stream The :ref:`GenericOutputStream`, is a concrete implementation of the :ref:`LogStream` base class, that can be constructed by specifying: -#. A C++ ``std::ostream`` object instance, e.g., ``std::cout`, ``std::cerr`` for +#. A C++ ``std::ostream`` object instance, e.g., ``std::cout``, ``std::cerr`` for console output, or to a file by passing a C++ ``std::ofstream`` object, and, #. Optionally, a string that specifies the :ref:`logMessageFormat`. @@ -423,12 +429,13 @@ The ``MyStream`` class implements the ``LogStream::append()`` method of the int line, bool AXOM_UNUSED_PARAM(filtered_duplicates) ) { - assert( m_stream != nillptr ); + assert( m_stream != nullptr ); (*m_stream) << this->getFormatedMessage( message::getLevelAsString(msgLevel), message, tagName, "", + "", fileName, line ); } diff --git a/src/axom/slic/examples/basic/lumberjack_logging.cpp b/src/axom/slic/examples/basic/lumberjack_logging.cpp index 1d0b8f5a02..9bcb591a59 100644 --- a/src/axom/slic/examples/basic/lumberjack_logging.cpp +++ b/src/axom/slic/examples/basic/lumberjack_logging.cpp @@ -39,10 +39,19 @@ int main(int argc, char** argv) MPI_Comm_rank(MPI_COMM_WORLD, &rank); // Initialize SLIC - std::string format = std::string("\n") + - std::string("\t\n") + std::string("\tLEVEL=\n") + - std::string("\tRANKS=\n") + std::string("\tFILE=\n") + - std::string("\tLINE=\n"); +constexpr const char* format = R"( + +\t +\tLEVEL= +\tRANKS= +\tRANK_COUNT= +\tFILE= +\tLINE= +)"; + // std::string format = std::string("\n") + + // std::string("\t\n") + std::string("\tLEVEL=\n") + + // std::string("\tRANKS=\n") + std::string("\tFILE=\n") + + // std::string("\tLINE=\n"); slic::initialize(); // Set SLIC logging level and Lumberjack Logging stream diff --git a/src/axom/slic/streams/GenericOutputStream.cpp b/src/axom/slic/streams/GenericOutputStream.cpp index 39de7df769..0922918657 100644 --- a/src/axom/slic/streams/GenericOutputStream.cpp +++ b/src/axom/slic/streams/GenericOutputStream.cpp @@ -74,6 +74,7 @@ void GenericOutputStream::append(message::Level msgLevel, message, tagName, "", + "", fileName, line); } diff --git a/src/axom/slic/streams/LumberjackStream.cpp b/src/axom/slic/streams/LumberjackStream.cpp index c9353cc057..42d24e3a9c 100644 --- a/src/axom/slic/streams/LumberjackStream.cpp +++ b/src/axom/slic/streams/LumberjackStream.cpp @@ -139,22 +139,21 @@ void LumberjackStream::write(bool local) if(m_lj->isOutputNode() || local) { - std::vector messages = m_lj->getMessages(); - - const int nmessages = static_cast(messages.size()); - std::string rankString; - for(int i = 0; i < nmessages; ++i) + for(const auto* curr_message : m_lj->getMessages()) { - rankString = std::to_string(messages[i]->count()) + ": " + - messages[i]->stringOfRanks(); + if (curr_message == nullptr) { + continue; + } + (*m_stream) << this->getFormatedMessage( message::getLevelAsString( - static_cast(messages[i]->level())), - messages[i]->text(), - messages[i]->tag(), - rankString, - messages[i]->fileName(), - messages[i]->lineNumber()); + static_cast(curr_message->level())), + curr_message->text(), + curr_message->tag(), + curr_message->stringOfRanks(), + std::to_string(curr_message->count()), + curr_message->fileName(), + curr_message->lineNumber()); } m_stream->flush(); diff --git a/src/axom/slic/streams/SynchronizedStream.cpp b/src/axom/slic/streams/SynchronizedStream.cpp index 12d00ed33c..0d42274d1d 100644 --- a/src/axom/slic/streams/SynchronizedStream.cpp +++ b/src/axom/slic/streams/SynchronizedStream.cpp @@ -92,6 +92,7 @@ void SynchronizedStream::append(message::Level msgLevel, message, tagName, std::to_string(rank), + "1", fileName, line)); } From c845143e133d10aefc30f8f7db3fc38b430ca8e4 Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 25 Jul 2024 14:45:05 -0700 Subject: [PATCH 2/3] remove old code --- src/axom/slic/examples/basic/lumberjack_logging.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/axom/slic/examples/basic/lumberjack_logging.cpp b/src/axom/slic/examples/basic/lumberjack_logging.cpp index 9bcb591a59..fdf409af49 100644 --- a/src/axom/slic/examples/basic/lumberjack_logging.cpp +++ b/src/axom/slic/examples/basic/lumberjack_logging.cpp @@ -48,10 +48,6 @@ constexpr const char* format = R"( \tFILE= \tLINE= )"; - // std::string format = std::string("\n") + - // std::string("\t\n") + std::string("\tLEVEL=\n") + - // std::string("\tRANKS=\n") + std::string("\tFILE=\n") + - // std::string("\tLINE=\n"); slic::initialize(); // Set SLIC logging level and Lumberjack Logging stream From 6d66fa9c40ea4f9a6e6e50683bfe65fb322b107b Mon Sep 17 00:00:00 2001 From: format-robot Date: Thu, 25 Jul 2024 14:46:43 -0700 Subject: [PATCH 3/3] Apply style updates --- src/axom/slic/examples/basic/lumberjack_logging.cpp | 2 +- src/axom/slic/streams/LumberjackStream.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/axom/slic/examples/basic/lumberjack_logging.cpp b/src/axom/slic/examples/basic/lumberjack_logging.cpp index fdf409af49..c8d8e080bf 100644 --- a/src/axom/slic/examples/basic/lumberjack_logging.cpp +++ b/src/axom/slic/examples/basic/lumberjack_logging.cpp @@ -39,7 +39,7 @@ int main(int argc, char** argv) MPI_Comm_rank(MPI_COMM_WORLD, &rank); // Initialize SLIC -constexpr const char* format = R"( + constexpr const char* format = R"( \t \tLEVEL= diff --git a/src/axom/slic/streams/LumberjackStream.cpp b/src/axom/slic/streams/LumberjackStream.cpp index 42d24e3a9c..0f26c430fa 100644 --- a/src/axom/slic/streams/LumberjackStream.cpp +++ b/src/axom/slic/streams/LumberjackStream.cpp @@ -141,7 +141,8 @@ void LumberjackStream::write(bool local) { for(const auto* curr_message : m_lj->getMessages()) { - if (curr_message == nullptr) { + if(curr_message == nullptr) + { continue; }