SST 16.0.0
Structural Simulation Toolkit
rankSyncSerialSkip.h
1// Copyright 2009-2026 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2026, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_SYNC_RANKSYNCSERIALSKIP_H
13#define SST_CORE_SYNC_RANKSYNCSERIALSKIP_H
14
15#include "sst/core/sst_types.h"
16#include "sst/core/sync/syncManager.h"
17#include "sst/core/threadsafe.h"
18
19#include <atomic>
20#include <cstdint>
21#include <map>
22#include <string>
23
24namespace SST {
25
26class RankSyncQueue;
27class TimeConverter;
28
29namespace Profile {
31};
32
33class RankSyncSerialSkip : public RankSync
34{
35public:
36 /** Create a new Sync object which fires with a specified period */
37 explicit RankSyncSerialSkip(RankInfo num_ranks);
38 RankSyncSerialSkip() {} // For serialization
39 virtual ~RankSyncSerialSkip();
40
41 /** Register a Link which this Sync Object is responsible for */
42 ActivityQueue* registerLink(const RankInfo& to_rank, const RankInfo& from_rank, Link* link) override;
43 void execute(int thread) override;
44
45 /** Cause an exchange of Untimed Data to occur */
46 void exchangeLinkUntimedData(int thread, std::atomic<int>& msg_count) override;
47 /** Finish link configuration */
48 void finalizeLinkConfigurations() override;
49 /** Prepare for the complete() stage */
50 void prepareForComplete() override;
51
52 /** Set signals to exchange during sync */
53 void setSignals(int end, int usr, int alrm) override;
54 /** Return exchanged signals after sync */
55 bool getSignals(int& end, int& usr, int& alrm) override;
56
57 /** Set interactive flags to exchange during sync */
58 // Separated enter_interactive from from shutdown since they may be needed separately
59 void setShutdownFlags(bool enter_shutdown, Simulation::ShutdownMode_t shutdown_mode) override;
60 void setCkptFlag(bool generate_ckpt) override;
61 void setFlags(bool enter_interactive, bool enter_shutdown, Simulation::ShutdownMode_t shutdown_mode) override;
62 /** Return exchanged interactive flags after sync */
63 void getShutdownFlags(bool& enter_shutdown, Simulation::ShutdownMode_t& shutdown_mode) override;
64 void getCkptFlag(bool& generate_ckpt) override;
65 void getFlags(bool& enter_interactive, bool& enter_shutdown, Simulation::ShutdownMode_t& shutdown_mode) override;
66 /** Clear interactive flags before next run */
67 void clearFlags() override;
68
69 SimTime_t getNextSyncTime() override { return myNextSyncTime; }
70
71 void setRestartTime(SimTime_t time) override;
72
73 uint64_t getDataSize() const override;
74
75 void setProfileToolList(Profile::SyncProfileToolList* profile_tools) override;
76
77private:
78 static SimTime_t myNextSyncTime;
79
80 // Function that actually does the exchange during run
81 void exchange();
82
83 struct comm_pair : public SST::Core::Serialization::serializable
84 {
85 RankSyncQueue* squeue; // RankSyncQueue
86 char* rbuf; // receive buffer
87 uint32_t local_size;
88 uint32_t remote_size;
89
90 void serialize_order(SST::Core::Serialization::serializer& UNUSED(ser)) override {}
91 ImplementSerializable(comm_pair)
92 };
93
94 using comm_map_t = std::map<int, comm_pair>;
95 using link_map_t = std::map<std::string, uintptr_t>;
96
97 // TimeConverter* period;
98 comm_map_t comm_map;
99 link_map_t link_map;
100
101 double mpiWaitTime;
102 double deserializeTime;
103
104 Profile::SyncProfileToolList* profile_tools_ = nullptr;
105
107 static int sig_end_;
108 static int sig_usr_;
109 static int sig_alrm_;
110 static std::atomic<bool> enter_interactive_;
111 static std::atomic<bool> enter_shutdown_;
112 static std::atomic<unsigned> shutdown_mode_;
113 static std::atomic<bool> generate_ckpt_;
114};
115
116} // namespace SST
117
118#endif // SST_CORE_SYNC_RANKSYNCSERIALSKIP_H
Base Class for a queue of Activities.
Definition activityQueue.h:22
Definition serializable.h:25
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:43
Definition threadsafe.h:138
Definition syncProfileTool.h:145
Definition rankInfo.h:24
Definition syncQueue.h:62
void setShutdownFlags(bool enter_shutdown, Simulation::ShutdownMode_t shutdown_mode) override
Set interactive flags to exchange during sync.
Definition rankSyncSerialSkip.cc:127
void setSignals(int end, int usr, int alrm) override
Set signals to exchange during sync.
Definition rankSyncSerialSkip.cc:110
void prepareForComplete() override
Prepare for the complete() stage.
Definition rankSyncSerialSkip.cc:106
bool getSignals(int &end, int &usr, int &alrm) override
Return exchanged signals after sync.
Definition rankSyncSerialSkip.cc:118
void clearFlags() override
Clear interactive flags before next run.
Definition rankSyncSerialSkip.cc:182
void finalizeLinkConfigurations() override
Finish link configuration.
Definition rankSyncSerialSkip.cc:102
void exchangeLinkUntimedData(int thread, std::atomic< int > &msg_count) override
Cause an exchange of Untimed Data to occur.
Definition rankSyncSerialSkip.cc:346
ActivityQueue * registerLink(const RankInfo &to_rank, const RankInfo &from_rank, Link *link) override
Register a Link which this Sync Object is responsible for.
Definition rankSyncSerialSkip.cc:70
RankSyncSerialSkip(RankInfo num_ranks)
Create a new Sync object which fires with a specified period.
Definition rankSyncSerialSkip.cc:48
void getShutdownFlags(bool &enter_shutdown, Simulation::ShutdownMode_t &shutdown_mode) override
Return exchanged interactive flags after sync.
Definition rankSyncSerialSkip.cc:152
A class to convert between a component's view of time and the core's view of time.
Definition timeConverter.h:31