Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split RANK_COUNT out of RANK in SLIC message formatting #1390

Merged
merged 4 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 2 additions & 0 deletions src/axom/slic/core/LogStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -79,6 +80,7 @@ std::string LogStream::getFormatedMessage(const std::string& msgLevel,
this->replaceKey(msg, "<TAG>", tagName);
this->replaceKey(msg, "<FILE>", fileName);
this->replaceKey(msg, "<RANK>", rank);
this->replaceKey(msg, "<RANK_COUNT>", rank_count);

if(line != MSG_IGNORE_LINE)
{
Expand Down
7 changes: 6 additions & 1 deletion src/axom/slic/core/LogStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class LogStream
* <li> <TAG> user-supplied tag </li>
* <li> <FILE> with the filename </li>
* <li> <LINE> with the line number </li>
* <li> <LINE> with the MPI rank </li>
* <li> <RANK> with the MPI rank(s) </li>
* <li> <RANK_COUNT> with the number of MPI ranks </li>
* <li> <TIMESTAMP> date/time the message is logged </li>
* </ul>
*
Expand All @@ -73,6 +74,7 @@ class LogStream
* std::string( "* FILE=<FILE>\n" ) +
* std::string( "* LINE=<LINE>\n" ) +
* std::string( "* RANK=<RANK>\n" ) +
* std::string( "* RANK_COUNT=<RANK_COUNT>\n" ) +
* std::string( "***********************************\n" );
* \endcode
*/
Expand Down Expand Up @@ -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.
*
Expand All @@ -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);

Expand Down
15 changes: 11 additions & 4 deletions src/axom/slic/docs/sphinx/sections/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,14 @@ The list of keywords is summarized in the table below.
| **<TAG>** | A string tag associated with a given message, e.g., for|
| | filtering during post-processing, etc. |
+---------------------+--------------------------------------------------------+
| **<RANK>** | The MPI rank that emitted the message. Only applicable |
| | when the `Axom Toolkit`_ is compiled with MPI enabled |
| **<RANK>** | 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`. |
+---------------------+--------------------------------------------------------+
| **<RANK_COUNT>** | 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`. |
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes! How did that compile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't because it is just a code chunk in the documentation. A very good example why we shouldn't do this in general =)


(*m_stream) << this->getFormatedMessage( message::getLevelAsString(msgLevel),
message,
tagName,
"",
"",
fileName,
line );
}
Expand Down
13 changes: 9 additions & 4 deletions src/axom/slic/examples/basic/lumberjack_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ int main(int argc, char** argv)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

// Initialize SLIC
std::string format = std::string("<MESSAGE>\n") +
std::string("\t<TIMESTAMP>\n") + std::string("\tLEVEL=<LEVEL>\n") +
std::string("\tRANKS=<RANK>\n") + std::string("\tFILE=<FILE>\n") +
std::string("\tLINE=<LINE>\n");
constexpr const char* format = R"(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<MESSAGE>
\t<TIMESTAMP>
\tLEVEL=<LEVEL>
\tRANKS=<RANK>
\tRANK_COUNT=<RANK_COUNT>
\tFILE=<FILE>
\tLINE=<LINE>
)";
slic::initialize();

// Set SLIC logging level and Lumberjack Logging stream
Expand Down
1 change: 1 addition & 0 deletions src/axom/slic/streams/GenericOutputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void GenericOutputStream::append(message::Level msgLevel,
message,
tagName,
"",
"",
fileName,
line);
}
Expand Down
26 changes: 13 additions & 13 deletions src/axom/slic/streams/LumberjackStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,22 @@ void LumberjackStream::write(bool local)

if(m_lj->isOutputNode() || local)
{
std::vector<axom::lumberjack::Message*> messages = m_lj->getMessages();

const int nmessages = static_cast<int>(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<message::Level>(messages[i]->level())),
messages[i]->text(),
messages[i]->tag(),
rankString,
messages[i]->fileName(),
messages[i]->lineNumber());
static_cast<message::Level>(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();
Expand Down
1 change: 1 addition & 0 deletions src/axom/slic/streams/SynchronizedStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void SynchronizedStream::append(message::Level msgLevel,
message,
tagName,
std::to_string(rank),
"1",
fileName,
line));
}
Expand Down