← Documentation
ADS-IDAC Engine 5.0.0
RestartNodeInfo.cpp
Go to the documentation of this file.
1// RestartNodeInfo.cpp: implementation of the RestartNodeInfo class.
2//
4
5#include "RestartNodeInfo.h"
6#include <boost/serialization/export.hpp>
7#include "SimulationContext.h"
8//BOOST_CLASS_EXPORT(RestartNodeInfo)
9#include <boost/archive/binary_oarchive.hpp>
10#include <boost/archive/binary_iarchive.hpp>
11#include <chrono>
12#include <cstdio>
13#include <cstdlib>
14#include <sstream>
15BOOST_CLASS_EXPORT_IMPLEMENT(RestartNodeInfo)
16using namespace std;
17
18namespace {
22template <typename T>
23std::pair<size_t, size_t> snap_blob_sig(const T& obj) {
24 std::ostringstream oss(std::ios::binary);
25 boost::archive::binary_oarchive oa(oss);
26 oa << obj;
27 const std::string blob = oss.str();
28 return {blob.size(), std::hash<std::string>{}(blob)};
29}
30} // namespace
31
32
34// Construction/Destruction
36
38
39}
40
45}
48 // Per-member snapshot weight diagnostic. Enabled when the environment
49 // variable ADSIDAC_SNAPSHOT_PROFILE is set to any value (read once per
50 // process, default off): prints a "[SNAP-PROF]" line on stderr with copy
51 // time, serialized size and content hash for every member of every snapshot.
52 static const bool snap_prof = getenv("ADSIDAC_SNAPSHOT_PROFILE") != nullptr;
53 auto timed = [](const char* name, auto&& copy_fn, auto&& sig_fn) {
54 if (!snap_prof) { copy_fn(); return; }
55 auto t0 = std::chrono::steady_clock::now();
56 copy_fn();
57 auto us = std::chrono::duration_cast<std::chrono::microseconds>(
58 std::chrono::steady_clock::now() - t0).count();
59 auto sig = sig_fn();
60 fprintf(stderr, "[SNAP-PROF] %s copy_us=%lld bytes=%zu hash=%zx\n",
61 name, static_cast<long long>(us), sig.first, sig.second);
62 };
63 timed("ControlPanel",
65 [&]{ return snap_blob_sig(r_Indicator); });
66 timed("CommandControlCenter",
68 [&]{ return snap_blob_sig(r_Command_handler); });
69 timed("AnalysisInfoContainer",
71 [&]{ return snap_blob_sig(r_Aux_info); });
72 timed("Procedures",
74 [&]{ return snap_blob_sig(r_All_procedure); });
75 timed("InitiatingEventController",
77 [&]{ return snap_blob_sig(r_IE); });
78 timed("OperatorDM",
80 [&]{ return snap_blob_sig(r_Decision_Maker); });
81 timed("OperatorAT",
83 [&]{ return snap_blob_sig(r_Action_Taker); });
84 timed("HWReliabilityModule",
86 [&]{ return snap_blob_sig(r_System_reliability); });
87// r_Support_system.copySupportSystemModule(Support_system_reliability);
88 timed("KeyParameterHistory",
90 [&]{ return snap_blob_sig(r_KPS); });
91 timed("CalculationAid",
93 [&]{ return snap_blob_sig(r_All_polynomial); });
94 // Whole-snapshot single-archive size: Boost object tracking dedups shared
95 // subobjects WITHIN one archive, so this (what actually travels) can be
96 // smaller than the per-member sum above.
97 if (snap_prof) {
98 auto whole = snap_blob_sig(*this);
99 fprintf(stderr, "[SNAP-PROF] WHOLE_RINFO copy_us=0 bytes=%zu hash=%zx\n",
100 whole.first, whole.second);
101 }
102}
Checkpoint/restart state snapshot — captures entire C++ simulation state at a branching point.
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
Single struct holding all mutable simulation state.
void copyAnalysisInfoContainer(AnalysisInfoContainer &)
int getIDOfRecentGeneratedBranchCluster()
void copyCalculationAidToRestartInfoForRestart(const CalculationAid &)
void copyCommandControlCenterToRestartInfo(CommandControlCenter &)
void copyControlPanel(ControlPanel &)
void copyHWReliabilityModule(HWReliabilityModule &)
Appends deep copies of the units of another module and copies its state of activation....
void copyInitiatingEventController(InitiatingEventController &)
void copyKeyParameterHistory(KeyParameterHistory &)
void copyOperatorATToRestartInfo(OperatorAT &)
void clearOperatorATFromRestartInfo()
void copyOperatorDMToRestartInfo(OperatorDM &)
void clearOperatorDMFromRestartInfo()
void copyProceduresToRestartInfoForRestart(Procedures &)
Definition: Procedures.cpp:192
void setCorrespondingBranchClusterID(int)
CommandControlCenter r_Command_handler
ControlPanel r_Indicator
InitiatingEventController r_IE
OperatorAT r_Action_Taker
HWReliabilityModule r_System_reliability
CalculationAid r_All_polynomial
OperatorDM r_Decision_Maker
Procedures r_All_procedure
AnalysisInfoContainer r_Aux_info
KeyParameterHistory r_KPS
int corresponding_branch_cluster_ID
int getCorrespondingBranchClusterID()
virtual ~RestartNodeInfo()
Procedures All_procedure
Emergency operating procedures.
OperatorAT Action_Taker
Crew action execution model.
KeyParameterHistory KPS
Time-series parameter recording.
ControlPanel Indicator
Control room panel state.
HWReliabilityModule System_reliability
Hardware fault trees.
OperatorDM Decision_Maker
Crew decision-making model.
CommandControlCenter Command_handler
Command/control dispatch.
InitiatingEventController IE
Initiating event definition.
AnalysisInfoContainer Aux_info
Analysis records.
BranchRecord Branch_center
Dynamic event tree state.
CalculationAid All_polynomial
Polynomial calculations.