Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/sst/core/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ nobase_dist_sst_HEADERS = \
math/sqrt.h \
uninitializedQueue.h \
unitAlgebra.h \
watchPoint.h \
Copy link
Contributor

Choose a reason for hiding this comment

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

If watchPoint.h is added here, it should technically be removed from the sst_core_sources section.

eli/elementinfo.h \
eli/elibase.h \
eli/attributeInfo.h \
Expand Down
17 changes: 12 additions & 5 deletions src/sst/core/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,18 @@ Config::insertOptions()
DEF_SECTION_HEADING("Advanced Options - Debug");
DEF_ARG("run-mode", 0, "MODE", "Set run mode [ init | run | both (default)]", runMode_, true, false, true);
DEF_ARG("interactive-console", 0, "ACTION",
"[EXPERIMENTAL] Set console to use for interactive mode. NOTE: This currently only works for serial jobs and "
"this option will be ignored for parallel runs.",
"[EXPERIMENTAL] Set console to use for interactive mode (overrides default console: "
"sst.interactive.simpledebug). "
"NOTE: This currently only works for serial jobs and will be ignored for parallel runs.",
interactive_console_, true, false, false);
DEF_ARG_OPTVAL("interactive-start", 0, "TIME",
"[EXPERIMENTAL] Drop into interactive mode at specified simulated time. If no time is specified, or the time "
"is 0, then it will "
"drop into interactive mode before any events are processed in the main run loop. This option is ignored if no "
"interactive console was set. NOTE: This currently only works for serial jobs and this option will be ignored "
"is 0, then it will drop into interactive mode before any events are processed in the main run loop. "
"NOTE: This currently only works for serial jobs and this option will be ignored "
"for parallel runs.",
interactive_start_time_, true, false, false);
DEF_ARG("replay-file", 0, "FILE", "Specify file for replaying an interactive debug console session.", replay_file_,
false);
#ifdef USE_MEMPOOL
DEF_ARG("output-undeleted-events", 0, "FILE",
"file to write information about all undeleted events at the end of simulation (STDOUT and STDERR can be used "
Expand All @@ -561,6 +563,10 @@ Config::insertOptions()

/* Advanced Features - Checkpoint */
DEF_SECTION_HEADING("Advanced Options - Checkpointing (EXPERIMENTAL)");
DEF_FLAG("checkpoint-enable", 0,
"Allows checkpoints to be triggered from the interactive debug console. "
"This option is not needed if checkpoint-wall-period, checkpoint-period, or checkpoint-sim-period are used.",
checkpoint_enable_, false, false, false);
DEF_ARG("checkpoint-wall-period", 0, "PERIOD",
"Set approximate frequency for checkpoints to be generated in terms of wall (real) time. PERIOD can be "
"specified in hours, minutes, and seconds with "
Expand Down Expand Up @@ -651,6 +657,7 @@ Config::setOptionFromModel(const std::string& entryName, const std::string& valu
bool
Config::canInitiateCheckpoint()
{
if ( checkpoint_enable_.value == true ) return true;
if ( checkpoint_wall_period_.value != 0 ) return true;
if ( checkpoint_sim_period_.value != "" ) return true;
return false;
Expand Down
9 changes: 9 additions & 0 deletions src/sst/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ class Config : public ConfigShared, public SST::Core::Serialization::serializabl
std::bind(&StandardConfigParsers::from_string_default<std::string>, std::placeholders::_1,
std::placeholders::_2, "0"));

/**
File to replay an interactive console script
*/
SST_CONFIG_DECLARE_OPTION(std::string, replay_file, "", &StandardConfigParsers::from_string<std::string>);

#ifdef USE_MEMPOOL
/**
Expand Down Expand Up @@ -577,6 +581,11 @@ class Config : public ConfigShared, public SST::Core::Serialization::serializabl

/**** Advanced options - Checkpointing ****/

/**
* Enable checkpointing for interactive debug
*/
SST_CONFIG_DECLARE_OPTION(bool, checkpoint_enable, 0, &StandardConfigParsers::flag_set_true);

/**
* Interval at which to create a checkpoint in wall time
*/
Expand Down
14 changes: 13 additions & 1 deletion src/sst/core/from_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#ifndef SST_CORE_FROM_STRING_H
#define SST_CORE_FROM_STRING_H

#include <iomanip>
#include <limits>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
Expand Down Expand Up @@ -107,7 +110,16 @@ template <class T>
std::enable_if_t<!std::is_enum_v<T>, std::string>
to_string(const T& input)
{
if constexpr ( std::is_arithmetic_v<T> )
if constexpr ( std::is_floating_point_v<T> ) {
std::stringstream s;
T abs_val = input < 0 ? -input : input;
if ( abs_val > (T)10e6 || abs_val < (T)10e-6 )
s << std::scientific << std::setprecision(std::numeric_limits<double>::max_digits10) << input;
else
s << std::fixed << std::setprecision(std::numeric_limits<double>::max_digits10) << input;
return s.str().c_str();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest:

if constexpr ( std::is_floating_point_v<T> ) {
   char s[32];
   snprintf(s, sizeof(s), "%.*g", std::numeric_limits<T>::max_digits10, input);
   return s;
}

printf() is much faster and more flexible than C++ <iostream> operators.

The %.*g specifier uses scientific notation for large and small exponents, otherwise not, and its precision, indicated by *, uses the next argument, which std::numeric_limits<T>::max_digits10 returns the number of digits required. This guarantees that a value written out can be read back in by scanf() and the original bits are unchanged.

If a machine is going to be reading/writing the numbers, the %a specifier is exact and prints floating-point in hexadecimal notation.

You probably should add #include <cstdio> at the top of the file. Please run scripts/test-includes.pl to check for needed #includes. It will be added later to CI and maybe pre-commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will get this in near-future PR

else if constexpr ( std::is_arithmetic_v<T> )
return std::to_string(input);
else
return typeid(T).name(); // For now, return a string if the type isn't handled elsewhere
Expand Down
4 changes: 3 additions & 1 deletion src/sst/core/impl/interactive/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@

sst_core_sources += \
impl/interactive/simpleDebug.cc \
impl/interactive/simpleDebug.h
impl/interactive/simpleDebug.h \
impl/interactive/cmdLineEditor.cc \
impl/interactive/cmdLineEditor.h

Loading
Loading