diff --git a/src/sst/core/exit.cc b/src/sst/core/exit.cc index a49fb746d..300245320 100644 --- a/src/sst/core/exit.cc +++ b/src/sst/core/exit.cc @@ -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; } @@ -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 @@ -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 diff --git a/src/sst/core/output.cc b/src/sst/core/output.cc index 26d6b15bb..9b2348dbe 100644 --- a/src/sst/core/output.cc +++ b/src/sst/core/output.cc @@ -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 @@ -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", @@ -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( @@ -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) ) { @@ -370,7 +376,9 @@ 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; @@ -378,7 +386,9 @@ Output::buildPrefixString(uint32_t line, const std::string& file, const std::str startindex = findindex + 2; break; case 'R': - if ( 1 == getMPIWorldSize() ) { rtnstring += "0"; } + if ( 1 == getMPIWorldSize() ) { + rtnstring += "0"; + } else { snprintf(tempBuf, 256, "%d", getMPIWorldRank()); rtnstring += tempBuf; @@ -386,7 +396,9 @@ Output::buildPrefixString(uint32_t line, const std::string& file, const std::str startindex = findindex + 2; break; case 'i': - if ( 1 == getNumThreads() ) { rtnstring += ""; } + if ( 1 == getNumThreads() ) { + rtnstring += ""; + } else { snprintf(tempBuf, 256, "%u", getThreadRank()); rtnstring += tempBuf; @@ -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); } @@ -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; } diff --git a/src/sst/core/output.h b/src/sst/core/output.h index 63236e5a3..38a1d017a 100644 --- a/src/sst/core/output.h +++ b/src/sst/core/output.h @@ -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 @@ -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 diff --git a/src/sst/core/simulation_impl.h b/src/sst/core/simulation_impl.h index ec999cee9..2dcfa52f4 100644 --- a/src/sst/core/simulation_impl.h +++ b/src/sst/core/simulation_impl.h @@ -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(); } @@ -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); @@ -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);