Skip to content

Commit 209cad4

Browse files
authored
Merge pull request #1390 from LLNL/feature/white238/split_slic_rank_and_rank_count
Split RANK_COUNT out of RANK in SLIC message formatting
2 parents 4bbe8ef + 2ca7f1d commit 209cad4

File tree

8 files changed

+45
-22
lines changed

8 files changed

+45
-22
lines changed

RELEASE-NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
6565
external `fmt` and axom's vendored copy.
6666
- Turn off CMake finding dependencies on system paths.
6767
- `axom::Array`: trivially-copyable types with a non-trivial constructor are now initialized on the GPU.
68+
- SLIC no longer outputs the rank count in the `RANK` format string in parallel loggers. You can access
69+
the rank count via new format option `RANK_COUNT`.
6870

6971
### Removed
7072
- Removes config option `AXOM_ENABLE_ANNOTATIONS`. Annotations are now provided by `caliper`

src/axom/slic/core/LogStream.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ std::string LogStream::getFormatedMessage(const std::string& msgLevel,
6969
const std::string& message,
7070
const std::string& tagName,
7171
const std::string& rank,
72+
const std::string& rank_count,
7273
const std::string& fileName,
7374
int line)
7475
{
@@ -79,6 +80,7 @@ std::string LogStream::getFormatedMessage(const std::string& msgLevel,
7980
this->replaceKey(msg, "<TAG>", tagName);
8081
this->replaceKey(msg, "<FILE>", fileName);
8182
this->replaceKey(msg, "<RANK>", rank);
83+
this->replaceKey(msg, "<RANK_COUNT>", rank_count);
8284

8385
if(line != MSG_IGNORE_LINE)
8486
{

src/axom/slic/core/LogStream.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class LogStream
5858
* <li> <TAG> user-supplied tag </li>
5959
* <li> <FILE> with the filename </li>
6060
* <li> <LINE> with the line number </li>
61-
* <li> <LINE> with the MPI rank </li>
61+
* <li> <RANK> with the MPI rank(s) </li>
62+
* <li> <RANK_COUNT> with the number of MPI ranks </li>
6263
* <li> <TIMESTAMP> date/time the message is logged </li>
6364
* </ul>
6465
*
@@ -73,6 +74,7 @@ class LogStream
7374
* std::string( "* FILE=<FILE>\n" ) +
7475
* std::string( "* LINE=<LINE>\n" ) +
7576
* std::string( "* RANK=<RANK>\n" ) +
77+
* std::string( "* RANK_COUNT=<RANK_COUNT>\n" ) +
7678
* std::string( "***********************************\n" );
7779
* \endcode
7880
*/
@@ -151,6 +153,8 @@ class LogStream
151153
* \param [in] tagName user-supplied tag, may be MSG_IGNORE_TAG
152154
* \param [in] fileName filename where this message is logged, may be
153155
* MSG_IGNORE_FILE to ignore this field.
156+
* \param [in] rank The MPI rank(s) that emitted this message
157+
* \param [in] rank_count the number of MPI ranks that emitted this message
154158
* \param [in] line the line number within the file where the message is
155159
* logged. Likewise, may be set to MSG_IGNORE_LINE to ignore this field.
156160
*
@@ -161,6 +165,7 @@ class LogStream
161165
const std::string& message,
162166
const std::string& tagName,
163167
const std::string& rank,
168+
const std::string& rank_count,
164169
const std::string& fileName,
165170
int line);
166171

src/axom/slic/docs/sphinx/sections/architecture.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,14 @@ The list of keywords is summarized in the table below.
151151
| **<TAG>** | A string tag associated with a given message, e.g., for|
152152
| | filtering during post-processing, etc. |
153153
+---------------------+--------------------------------------------------------+
154-
| **<RANK>** | The MPI rank that emitted the message. Only applicable |
155-
| | when the `Axom Toolkit`_ is compiled with MPI enabled |
154+
| **<RANK>** | The MPI rank(s) that emitted the message. |
155+
| | Only applicable when Axom is compiled with MPI enabled |
156+
| | and with MPI-aware :ref:`LogStream` instances, such as,|
157+
| | the :ref:`SynchronizedStream` and |
158+
| | :ref:`LumberjackStream`. |
159+
+---------------------+--------------------------------------------------------+
160+
| **<RANK_COUNT>** | The number of MPI ranks that emitted the message. |
161+
| | Only applicable when Axom is compiled with MPI enabled |
156162
| | and with MPI-aware :ref:`LogStream` instances, such as,|
157163
| | the :ref:`SynchronizedStream` and |
158164
| | :ref:`LumberjackStream`. |
@@ -221,7 +227,7 @@ Generic Output Stream
221227
The :ref:`GenericOutputStream`, is a concrete implementation of the
222228
:ref:`LogStream` base class, that can be constructed by specifying:
223229

224-
#. A C++ ``std::ostream`` object instance, e.g., ``std::cout`, ``std::cerr`` for
230+
#. A C++ ``std::ostream`` object instance, e.g., ``std::cout``, ``std::cerr`` for
225231
console output, or to a file by passing a C++ ``std::ofstream`` object, and,
226232

227233
#. Optionally, a string that specifies the :ref:`logMessageFormat`.
@@ -423,12 +429,13 @@ The ``MyStream`` class implements the ``LogStream::append()`` method of the
423429
int line,
424430
bool AXOM_UNUSED_PARAM(filtered_duplicates) )
425431
{
426-
assert( m_stream != nillptr );
432+
assert( m_stream != nullptr );
427433

428434
(*m_stream) << this->getFormatedMessage( message::getLevelAsString(msgLevel),
429435
message,
430436
tagName,
431437
"",
438+
"",
432439
fileName,
433440
line );
434441
}

src/axom/slic/examples/basic/lumberjack_logging.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ int main(int argc, char** argv)
3939
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
4040

4141
// Initialize SLIC
42-
std::string format = std::string("<MESSAGE>\n") +
43-
std::string("\t<TIMESTAMP>\n") + std::string("\tLEVEL=<LEVEL>\n") +
44-
std::string("\tRANKS=<RANK>\n") + std::string("\tFILE=<FILE>\n") +
45-
std::string("\tLINE=<LINE>\n");
42+
constexpr const char* format = R"(
43+
<MESSAGE>
44+
\t<TIMESTAMP>
45+
\tLEVEL=<LEVEL>
46+
\tRANKS=<RANK>
47+
\tRANK_COUNT=<RANK_COUNT>
48+
\tFILE=<FILE>
49+
\tLINE=<LINE>
50+
)";
4651
slic::initialize();
4752

4853
// Set SLIC logging level and Lumberjack Logging stream

src/axom/slic/streams/GenericOutputStream.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void GenericOutputStream::append(message::Level msgLevel,
7474
message,
7575
tagName,
7676
"",
77+
"",
7778
fileName,
7879
line);
7980
}

src/axom/slic/streams/LumberjackStream.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,22 @@ void LumberjackStream::write(bool local)
139139

140140
if(m_lj->isOutputNode() || local)
141141
{
142-
std::vector<axom::lumberjack::Message*> messages = m_lj->getMessages();
143-
144-
const int nmessages = static_cast<int>(messages.size());
145-
std::string rankString;
146-
for(int i = 0; i < nmessages; ++i)
142+
for(const auto* curr_message : m_lj->getMessages())
147143
{
148-
rankString = std::to_string(messages[i]->count()) + ": " +
149-
messages[i]->stringOfRanks();
144+
if(curr_message == nullptr)
145+
{
146+
continue;
147+
}
148+
150149
(*m_stream) << this->getFormatedMessage(
151150
message::getLevelAsString(
152-
static_cast<message::Level>(messages[i]->level())),
153-
messages[i]->text(),
154-
messages[i]->tag(),
155-
rankString,
156-
messages[i]->fileName(),
157-
messages[i]->lineNumber());
151+
static_cast<message::Level>(curr_message->level())),
152+
curr_message->text(),
153+
curr_message->tag(),
154+
curr_message->stringOfRanks(),
155+
std::to_string(curr_message->count()),
156+
curr_message->fileName(),
157+
curr_message->lineNumber());
158158
}
159159

160160
m_stream->flush();

src/axom/slic/streams/SynchronizedStream.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ void SynchronizedStream::append(message::Level msgLevel,
9292
message,
9393
tagName,
9494
std::to_string(rank),
95+
"1",
9596
fileName,
9697
line));
9798
}

0 commit comments

Comments
 (0)