Skip to content

Commit

Permalink
run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
leekillough committed Nov 9, 2024
1 parent 4b00c3f commit a443327
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 28 deletions.
35 changes: 21 additions & 14 deletions src/sst/core/exit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ Exit::computeEndTime()
end_time = end_value;
}
#endif
if ( single_rank ) { endSimulation(end_time); }
if ( single_rank ) {
endSimulation(end_time);
}
return end_time;
}

Expand All @@ -161,16 +163,20 @@ Exit::check()
int out;

#ifdef SST_CONFIG_HAVE_MPI
if ( !single_rank ) { MPI_Allreduce(&value, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); }
if ( !single_rank ) {
MPI_Allreduce(&value, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
}
else {
out = value;
}
#else
out = value;
out = value;
#endif
global_count = out;
// If out is 0, then it's time to end
if ( !out ) { computeEndTime(); }
if ( !out ) {
computeEndTime();
}
// else {
// // Reinsert into TimeVortex. We do this even when ending so that
// // it will get deleted with the TimeVortex on termination. We do
Expand Down Expand Up @@ -206,22 +212,23 @@ Exit::serialize_order(SST::Core::Serialization::serializer& ser)
ser& single_rank;
}

[[noreturn]] void SST_Exit(int exit_code)
[[noreturn]] void
SST_Exit(int exit_code)
{
// Make sure only one thread calls MPI_Abort() or exit() in the
// case where two threads call fatal() at the same time
// Only one thread initializes the function-local static variable
// Other threads are blocked
// Make sure only one thread calls MPI_Abort() or exit() in the
// case where two threads call fatal() at the same time
// Only one thread initializes the function-local static variable
// Other threads are blocked

#ifdef SST_CONFIG_HAVE_MPI
// If MPI exists, abort
static int exit_once = (MPI_Abort(MPI_COMM_WORLD, exit_code), 0);
// If MPI exists, abort
static int exit_once = (MPI_Abort(MPI_COMM_WORLD, exit_code), 0);
#else
static int exit_once = (exit(exit_code), 0);
static int exit_once = (exit(exit_code), 0);
#endif

// Should never get here
std::terminate();
// Should never get here
std::terminate();
}

} // namespace SST
34 changes: 25 additions & 9 deletions src/sst/core/output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include "sst/core/output.h"

// Core Headers
#include "sst/core/exit.h"
#include "sst/core/simulation_impl.h"
#include "sst/core/warnmacros.h"
#include "sst/core/exit.h"

// C++ System Headers
#include <atomic>
Expand Down Expand Up @@ -235,7 +235,9 @@ Output::setFileName(const std::string& filename) /* STATIC METHOD */
}

// Set the Filename, only if it has not yet been set.
if ( 0 == m_sstGlobalSimFileName.length() ) { m_sstGlobalSimFileName = filename; }
if ( 0 == m_sstGlobalSimFileName.length() ) {
m_sstGlobalSimFileName = filename;
}
else {
fprintf(
stderr, "ERROR: Output::setFileName() - Filename is already set to %s, and cannot be changed.\n",
Expand Down Expand Up @@ -307,7 +309,9 @@ Output::openSSTTargetFile() const

// Now try to open the file
handle = fopen(tempFileName.c_str(), "w");
if ( nullptr != handle ) { *m_targetFileHandleRef = handle; }
if ( nullptr != handle ) {
*m_targetFileHandleRef = handle;
}
else {
// We got an error of some sort
fprintf(
Expand All @@ -325,7 +329,9 @@ Output::closeSSTTargetFile()
{
if ( (true == m_objInitialized) && (FILE == m_targetLoc) ) {
// Decrement the Access count for the file
if ( *m_targetFileAccessCountRef > 0 ) { (*m_targetFileAccessCountRef)--; }
if ( *m_targetFileAccessCountRef > 0 ) {
(*m_targetFileAccessCountRef)--;
}

// If the access count is zero, and the file has been opened, then close it
if ( (0 == *m_targetFileAccessCountRef) && (nullptr != *m_targetFileHandleRef) && (FILE == m_targetLoc) ) {
Expand Down Expand Up @@ -370,23 +376,29 @@ Output::buildPrefixString(uint32_t line, const std::string& file, const std::str
startindex = findindex + 2;
break;
case 'r':
if ( 1 == getMPIWorldSize() ) { rtnstring += ""; }
if ( 1 == getMPIWorldSize() ) {
rtnstring += "";
}
else {
snprintf(tempBuf, 256, "%d", getMPIWorldRank());
rtnstring += tempBuf;
}
startindex = findindex + 2;
break;
case 'R':
if ( 1 == getMPIWorldSize() ) { rtnstring += "0"; }
if ( 1 == getMPIWorldSize() ) {
rtnstring += "0";
}
else {
snprintf(tempBuf, 256, "%d", getMPIWorldRank());
rtnstring += tempBuf;
}
startindex = findindex + 2;
break;
case 'i':
if ( 1 == getNumThreads() ) { rtnstring += ""; }
if ( 1 == getNumThreads() ) {
rtnstring += "";
}
else {
snprintf(tempBuf, 256, "%u", getThreadRank());
rtnstring += tempBuf;
Expand Down Expand Up @@ -529,7 +541,9 @@ TraceFunction::TraceFunction(uint32_t line, const char* file, const char* func,

if ( sim ) {
RankInfo ri = sim->getNumRanks();
if ( ri.rank > 1 || ri.thread > 1 ) { output_obj_.init("@x (@t): " /*prefix*/, 0, 0, Output::STDOUT); }
if ( ri.rank > 1 || ri.thread > 1 ) {
output_obj_.init("@x (@t): " /*prefix*/, 0, 0, Output::STDOUT);
}
else {
output_obj_.init("(@t): ", 0, 0, Output::STDOUT);
}
Expand Down Expand Up @@ -667,7 +681,9 @@ bool
is_trace_function_active()
{
const char* var = getenv("SST_TRACEFUNCTION_ACTIVATE");
if ( var ) { return true; }
if ( var ) {
return true;
}
else {
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions src/sst/core/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

// UNCOMMENT OUT THIS LINE TO ENABLE THE DEBUG METHOD -OR_
// CHOOSE THE --enable-debug OPTION DURING SST CONFIGURATION
//#define __SST_DEBUG_OUTPUT__
// #define __SST_DEBUG_OUTPUT__

// This must be defined before inclusion of intttypes.h
#ifndef __STDC_FORMAT_MACROS
Expand Down Expand Up @@ -394,7 +394,8 @@ class Output
@param format Format string. All valid formats for printf are available.
@param ... Arguments for format.
*/
[[noreturn]] void fatal(uint32_t line, const char* file, const char* func, int exit_code, const char* format, ...) const
[[noreturn]] void
fatal(uint32_t line, const char* file, const char* func, int exit_code, const char* format, ...) const
__attribute__((format(printf, 6, 7)));

// GET / SET METHODS
Expand Down
12 changes: 9 additions & 3 deletions src/sst/core/simulation_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ class Simulation_impl
LinkMap* getComponentLinkMap(ComponentId_t id) const
{
ComponentInfo* info = compInfoMap.getByID(id);
if ( nullptr == info ) { return nullptr; }
if ( nullptr == info ) {
return nullptr;
}
else {
return info->getLinkMap();
}
Expand All @@ -241,7 +243,9 @@ class Simulation_impl
{
ComponentInfo* i = compInfoMap.getByID(id);
// CompInfoMap_t::const_iterator i = compInfoMap.find(id);
if ( nullptr != i ) { return i->getComponent(); }
if ( nullptr != i ) {
return i->getComponent();
}
else {
printf("Simulation::getComponent() couldn't find component with id = %" PRIu64 "\n", id);
SST_Exit(1);
Expand All @@ -253,7 +257,9 @@ class Simulation_impl
{
ComponentInfo* i = compInfoMap.getByID(id);
// CompInfoMap_t::const_iterator i = compInfoMap.find(id);
if ( nullptr != i ) { return i; }
if ( nullptr != i ) {
return i;
}
else {
printf("Simulation::getComponentInfo() couldn't find component with id = %" PRIu64 "\n", id);
SST_Exit(1);
Expand Down

0 comments on commit a443327

Please sign in to comment.