Skip to content

Commit

Permalink
Merge pull request #1163 from sstsimulator/devel
Browse files Browse the repository at this point in the history
Automatically Merged using SST Master Branch Merger
  • Loading branch information
sst-autotester authored Oct 11, 2024
2 parents 7848d80 + d622a26 commit 6854da5
Show file tree
Hide file tree
Showing 81 changed files with 3,019 additions and 416 deletions.
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.mypy]
explicit_package_bases = true
mypy_path = "$MYPY_CONFIG_FILE_DIR/src/sst/core/testingframework"

warn_unused_ignores = true

warn_return_any = true
warn_unused_configs = true

disallow_untyped_defs = true

exclude = [
'^scripts/',
'^tests/',
]

[[tool.mypy.overrides]]
module = "sst"
ignore_missing_imports = true
5 changes: 3 additions & 2 deletions scripts/format-diff
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import re
from subprocess import check_output,STDOUT
from typing import List

choke_points = [
"ser &",
Expand All @@ -11,11 +12,11 @@ choke_points = [
commit = sys.argv[1]
paths = sys.argv[2:]

def getoutput(cmd_arr):
def getoutput(cmd_arr: List[str]) -> str:
result = check_output(cmd_arr,stderr=STDOUT,stdin=None).decode("utf-8").rstrip("\n")
return result

def format_diff(commit, path):
def format_diff(commit: str, path: str) -> None:
cmd = ["git", "diff", commit, "HEAD", path ]
diff_text = getoutput(cmd)

Expand Down
7 changes: 7 additions & 0 deletions src/sst/core/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ nobase_dist_sst_HEADERS = \
from_string.h \
heartbeat.h \
initQueue.h \
interactiveConsole.h \
link.h \
mempool.h \
memuse.h \
Expand Down Expand Up @@ -94,13 +95,16 @@ nobase_dist_sst_HEADERS = \
serialization/serializable_base.h \
serialization/serialize.h \
serialization/serialize_impl_fwd.h \
serialization/objectMap.h \
serialization/objectMapDeferred.h \
serialization/impl/serialize_array.h \
serialization/impl/serialize_atomic.h \
serialization/impl/ser_buffer_accessor.h \
serialization/impl/serialize_deque.h \
serialization/impl/serialize_list.h \
serialization/impl/serialize_map.h \
serialization/impl/serialize_multiset.h \
serialization/impl/mapper.h \
serialization/impl/packer.h \
serialization/impl/serialize_priority_queue.h \
serialization/impl/serialize_set.h \
Expand Down Expand Up @@ -186,6 +190,8 @@ sst_core_sources = \
factory.cc \
heartbeat.cc \
initQueue.cc \
interactiveAction.h \
interactiveConsole.cc \
link.cc \
linkMap.h \
linkPair.h \
Expand Down Expand Up @@ -213,6 +219,7 @@ sst_core_sources = \
ssthandler.cc \
sstpart.cc \
timeVortex.cc \
serialization/objectMap.cc \
serialization/serializable_base.cc \
serialization/serializable.cc \
serialization/serializer.cc \
Expand Down
1 change: 1 addition & 0 deletions src/sst/core/activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unordered_map>

// Default Priority Settings
#define INTERACTIVEPRIOIRTY 0
#define THREADSYNCPRIORITY 20
#define SYNCPRIORITY 25
#define STOPACTIONPRIORITY 30
Expand Down
56 changes: 53 additions & 3 deletions src/sst/core/baseComponent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "sst/core/linkMap.h"
#include "sst/core/profile/clockHandlerProfileTool.h"
#include "sst/core/profile/eventHandlerProfileTool.h"
#include "sst/core/serialization/serialize.h"
#include "sst/core/simulation_impl.h"
#include "sst/core/statapi/statoutput.h"
#include "sst/core/stringize.h"
Expand Down Expand Up @@ -816,6 +817,14 @@ BaseComponent::getComponentProfileTools(const std::string& point)
return sim_->getProfileTool<Profile::ComponentProfileTool>(point);
}

void
BaseComponent::initiateInteractive(const std::string& msg)
{
sim_->enter_interactive_ = true;
sim_->interactive_msg_ = msg;
}


void
BaseComponent::serialize_order(SST::Core::Serialization::serializer& ser)
{
Expand Down Expand Up @@ -853,6 +862,10 @@ BaseComponent::serialize_order(SST::Core::Serialization::serializer& ser)
}
break;
}
case SST::Core::Serialization::serializer::MAP:
// All variables for BaseComponent are mapped in the
// SerializeBaseComponentHelper class. Nothing to do here.
break;
}
}

Expand All @@ -863,15 +876,15 @@ namespace pvt {
static const long null_ptr_id = -1;

void
size_basecomponent(serializable_base* s, serializer& ser)
SerializeBaseComponentHelper::size_basecomponent(serializable_base* s, serializer& ser)
{
long dummy = 0;
ser.size(dummy);
if ( s ) { s->serialize_order(ser); }
}

void
pack_basecomponent(serializable_base* s, serializer& ser)
SerializeBaseComponentHelper::pack_basecomponent(serializable_base* s, serializer& ser)
{
if ( s ) {
long cls_id = s->cls_id();
Expand All @@ -885,7 +898,7 @@ pack_basecomponent(serializable_base* s, serializer& ser)
}

void
unpack_basecomponent(serializable_base*& s, serializer& ser)
SerializeBaseComponentHelper::unpack_basecomponent(serializable_base*& s, serializer& ser)
{
long cls_id;
ser.unpack(cls_id);
Expand All @@ -897,6 +910,43 @@ unpack_basecomponent(serializable_base*& s, serializer& ser)
}
}

void
SerializeBaseComponentHelper::map_basecomponent(serializable_base*& s, serializer& ser, const char* name)
{
if ( nullptr == s ) return;

BaseComponent* comp = static_cast<BaseComponent*>(s);
ObjectMapClass* obj_map = new ObjectMapClass(s, s->cls_name());
ser.report_object_map(obj_map);
ser.mapper().map_hierarchy_start(name, obj_map);

// Put in any subcomponents first
for ( auto it = comp->my_info->subComponents.begin(); it != comp->my_info->subComponents.end(); ++it ) {
std::string name_str = it->second.getShortName();
if ( name_str == "" ) {
// This is an anonymous subcomponent, create a name based
// on slotname and slotnum
name_str += it->second.getSlotName() + "[" + std::to_string(it->second.getSlotNum()) + "]";
}
// sst_map_object(ser, it->second.component, it->second.getShortName().c_str());
sst_map_object(ser, it->second.component, name_str.c_str());
it->second.serialize_comp(ser);
}

// Put in ComponentInfo data
ObjectMap* my_info_dir = new ObjectMapHierarchyOnly();
ser.mapper().map_hierarchy_start("my_info", my_info_dir);
ser.mapper().setNextObjectReadOnly();
sst_map_object(ser, const_cast<ComponentId_t&>(comp->my_info->id), "id");
ser.mapper().setNextObjectReadOnly();
sst_map_object(ser, const_cast<std::string&>(comp->my_info->type), "type");
sst_map_object(ser, comp->my_info->defaultTimeBase, "defaultTimeBase");
ser.mapper().map_hierarchy_end(); // for my_info_dir

s->serialize_order(ser);
ser.mapper().map_hierarchy_end(); // obj_map
}

} // namespace pvt
} // namespace Serialization
} // namespace Core
Expand Down
43 changes: 37 additions & 6 deletions src/sst/core/baseComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ class SubComponentSlotInfo;
class TimeConverter;
class UnitAlgebra;


namespace Core {
namespace Serialization {
namespace pvt {
class SerializeBaseComponentHelper;
} // namespace pvt
} // namespace Serialization
} // namespace Core

/**
* Main component object for the simulation.
*/
Expand Down Expand Up @@ -358,6 +367,8 @@ class BaseComponent : public SST::Core::Serialization::serializable_base
}
}

void initiateInteractive(const std::string& msg);

private:
ImplementSerializable(SST::BaseComponent)
void serialize_order(SST::Core::Serialization::serializer& ser) override;
Expand Down Expand Up @@ -878,6 +889,9 @@ class BaseComponent : public SST::Core::Serialization::serializable_base
std::vector<Profile::ComponentProfileTool*> getComponentProfileTools(const std::string& point);

private:
friend class Core::Serialization::pvt::SerializeBaseComponentHelper;


ComponentInfo* my_info = nullptr;
Simulation_impl* sim_ = nullptr;
bool isExtension = false;
Expand Down Expand Up @@ -1094,13 +1108,21 @@ namespace Serialization {

namespace pvt {

void size_basecomponent(serializable_base* s, serializer& ser);
class SerializeBaseComponentHelper
{
public:
static void size_basecomponent(serializable_base* s, serializer& ser);

static void pack_basecomponent(serializable_base* s, serializer& ser);

void pack_basecomponent(serializable_base* s, serializer& ser);
static void unpack_basecomponent(serializable_base*& s, serializer& ser);

static void map_basecomponent(serializable_base*& s, serializer& ser, const char* name);
};

void unpack_basecomponent(serializable_base*& s, serializer& ser);
} // namespace pvt


template <class T>
class serialize_impl<T*, typename std::enable_if<std::is_base_of<SST::BaseComponent, T>::value>::type>
{
Expand All @@ -1111,17 +1133,26 @@ class serialize_impl<T*, typename std::enable_if<std::is_base_of<SST::BaseCompon
serializable_base* sp = static_cast<serializable_base*>(s);
switch ( ser.mode() ) {
case serializer::SIZER:
pvt::size_basecomponent(sp, ser);
pvt::SerializeBaseComponentHelper::size_basecomponent(sp, ser);
break;
case serializer::PACK:
pvt::pack_basecomponent(sp, ser);
pvt::SerializeBaseComponentHelper::pack_basecomponent(sp, ser);
break;
case serializer::UNPACK:
pvt::unpack_basecomponent(sp, ser);
pvt::SerializeBaseComponentHelper::unpack_basecomponent(sp, ser);
break;
case serializer::MAP:
// Add your code here
break;
}
s = static_cast<T*>(sp);
}

void operator()(T*& s, serializer& ser, const char* name)
{
serializable_base* sp = static_cast<serializable_base*>(s);
pvt::SerializeBaseComponentHelper::map_basecomponent(sp, ser, name);
}
};

} // namespace Serialization
Expand Down
3 changes: 3 additions & 0 deletions src/sst/core/componentInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ ComponentInfo::serialize_order(SST::Core::Serialization::serializer& ser)
}
break;
}
case SST::Core::Serialization::serializer::MAP:
// Add your code here
break;
}

// Only the parent Component will call serialize_comp directly.
Expand Down
15 changes: 15 additions & 0 deletions src/sst/core/componentInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class ConfigStatistic;
class Simulation_impl;
class TimeConverter;

namespace Core {
namespace Serialization {
namespace pvt {
class SerializeBaseComponentHelper;
} // namespace pvt
} // namespace Serialization
} // namespace Core

class ComponentInfo
{

Expand All @@ -55,6 +63,7 @@ class ComponentInfo
friend class Simulation_impl;
friend class BaseComponent;
friend class ComponentInfoMap;
friend class Core::Serialization::pvt::SerializeBaseComponentHelper;

/**
Component ID.
Expand Down Expand Up @@ -204,6 +213,12 @@ class ComponentInfo
return real_comp->getName();
}

/**
Get the short name for this SubComponent (name not including
any parents, so just slot_name[index])
*/
inline std::string getShortName() const { return name.substr(name.find_last_of(':') + 1); }

inline const std::string& getSlotName() const { return slot_name; }

inline int getSlotNum() const { return slot_num; }
Expand Down
35 changes: 34 additions & 1 deletion src/sst/core/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,21 @@ class ConfigHelper
return cfg->runMode_ != SimulationRunMode::UNKNOWN ? 0 : -1;
}

static int setInteractiveConsole(Config* cfg, const std::string& arg)
{
cfg->interactive_console_ = arg;
return 0;
}

static int setInteractiveStartTime(Config* cfg, const std::string& arg)
{
if ( arg == "" )
cfg->interactive_start_time_ = "0";
else
cfg->interactive_start_time_ = arg;
return 0;
}

// dump undeleted events
#ifdef USE_MEMPOOL
static int setWriteUndeleted(Config* cfg, const std::string& arg)
Expand Down Expand Up @@ -716,6 +731,9 @@ Config::print()
break;
}

std::cout << "interactive_console = " << interactive_console_ << std::endl;
std::cout << "interactive_start_time = " << interactive_start_time_ << std::endl;

#ifdef USE_MEMPOOL
std::cout << "event_dump_file = " << event_dump_file_ << std::endl;
#endif
Expand Down Expand Up @@ -789,7 +807,9 @@ Config::Config(uint32_t num_ranks, bool first_rank) : ConfigShared(!first_rank,
profiling_output_ = "stdout";

// Advanced Options - Debug
runMode_ = SimulationRunMode::BOTH;
runMode_ = SimulationRunMode::BOTH;
interactive_console_ = "";
interactive_start_time_ = "";
#ifdef USE_MEMPOOL
event_dump_file_ = "";
#endif
Expand Down Expand Up @@ -986,6 +1006,19 @@ Config::insertOptions()
DEF_ARG(
"run-mode", 0, "MODE", "Set run mode [ init | run | both (default)]",
std::bind(&ConfigHelper::setRunMode, this, _1), 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.",
std::bind(&ConfigHelper::setInteractiveConsole, this, _1), true);
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 "
"for parallel runs.",
std::bind(&ConfigHelper::setInteractiveStartTime, this, _1), true);
#ifdef USE_MEMPOOL
DEF_ARG(
"output-undeleted-events", 0, "FILE",
Expand Down
Loading

0 comments on commit 6854da5

Please sign in to comment.