SST 15.0
Structural Simulation Toolkit
rankSyncParallelSkip.h
1// Copyright 2009-2025 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-2025, 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_RANKSYNCPARALLELSKIP_H
13#define SST_CORE_SYNC_RANKSYNCPARALLELSKIP_H
14
15#include "sst/core/sst_mpi.h"
16#include "sst/core/sst_types.h"
17#include "sst/core/sync/syncManager.h"
18#include "sst/core/threadsafe.h"
19
20#include <atomic>
21#include <cstdint>
22#include <map>
23#include <string>
24
25namespace SST {
26
27class RankSyncQueue;
28class TimeConverter;
29
30class RankSyncParallelSkip : public RankSync
31{
32public:
33 /** Create a new Sync object which fires with a specified period */
34 explicit RankSyncParallelSkip(RankInfo num_ranks);
35 RankSyncParallelSkip() {} // For serialization
36 virtual ~RankSyncParallelSkip();
37
38 /** Register a Link which this Sync Object is responsible for */
40 const RankInfo& to_rank, const RankInfo& from_rank, const std::string& name, Link* link) override;
41 void execute(int thread) override;
42
43 /** Cause an exchange of Untimed Data to occur */
44 void exchangeLinkUntimedData(int thread, std::atomic<int>& msg_count) override;
45 /** Finish link configuration */
46 void finalizeLinkConfigurations() override;
47 /** Prepare for complete() stage */
48 void prepareForComplete() override;
49
50 /** Set signals to exchange during sync */
51 void setSignals(int end, int usr, int alrm) override;
52 /** Return exchanged signals after sync */
53 bool getSignals(int& end, int& usr, int& alrm) override;
54
55 SimTime_t getNextSyncTime() override { return myNextSyncTime; }
56
57 void setRestartTime(SimTime_t time) override;
58
59 uint64_t getDataSize() const override;
60
61private:
62 static SimTime_t myNextSyncTime;
63
64 // Function that actually does the exchange during run
65 void exchange_master(int thread);
66 void exchange_slave(int thread);
67
68 struct comm_send_pair : public SST::Core::Serialization::serializable
69 {
70 RankInfo to_rank;
71 RankSyncQueue* squeue; // RankSyncQueue
72 char* sbuf;
73 uint32_t remote_size;
74
75 void serialize_order(SST::Core::Serialization::serializer& ser) override
76 {
77 SST_SER(to_rank);
78 // squeue - empty so recreate on restart
79 // sbuf - empty so recreate on restart
80 // remote_size - don't need
81 }
82 ImplementSerializable(comm_send_pair)
83 };
84
85 struct comm_recv_pair : public SST::Core::Serialization::serializable
86 {
87 uint32_t remote_rank;
88 uint32_t local_thread;
89 char* rbuf; // receive buffer
90 std::vector<Activity*> activity_vec;
91 uint32_t local_size;
92 bool recv_done;
93#ifdef SST_CONFIG_HAVE_MPI
94 MPI_Request req;
95#endif
96 void serialize_order(SST::Core::Serialization::serializer& ser) override
97 {
98 SST_SER(remote_rank);
99 SST_SER(local_thread);
100 // activity_vec - empty so recreate on restart
101 // rbuf - empty so recreate on restart
102 // recv_done - don't need
103 // req - don't need
104 }
105 ImplementSerializable(comm_recv_pair)
106 };
107
108 using comm_send_map_t = std::map<RankInfo, comm_send_pair>;
109 using comm_recv_map_t = std::map<RankInfo, comm_recv_pair>;
110 // using link_map_t = std::map<LinkId_t, Link*>;
111 using link_map_t = std::map<std::string, uintptr_t>;
112
113 // TimeConverter* period;
114 comm_send_map_t comm_send_map;
115 comm_recv_map_t comm_recv_map;
116 link_map_t link_map;
117
118 double mpiWaitTime;
119 double deserializeTime;
120
121 int* recv_count;
122 int send_count;
123
124 std::atomic<int32_t> remaining_deser;
129
130 void deserializeMessage(comm_recv_pair* msg);
131
132 Core::ThreadSafe::Barrier serializeReadyBarrier;
133 Core::ThreadSafe::Barrier slaveExchangeDoneBarrier;
134 Core::ThreadSafe::Barrier allDoneBarrier;
135
137 static int sig_end_;
138 static int sig_usr_;
139 static int sig_alrm_;
140};
141
142} // namespace SST
143
144#endif // SST_CORE_SYNC_RANKSYNCPARALLELSKIP_H
Base Class for a queue of Activities.
Definition activityQueue.h:22
Definition serializable.h:24
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:45
Definition threadsafe.h:46
Definition threadsafe.h:163
Definition threadsafe.h:132
Definition threadsafe.h:272
Definition rankInfo.h:24
void finalizeLinkConfigurations() override
Finish link configuration.
Definition rankSyncParallelSkip.cc:130
bool getSignals(int &end, int &usr, int &alrm) override
Return exchanged signals after sync.
Definition rankSyncParallelSkip.cc:152
void setSignals(int end, int usr, int alrm) override
Set signals to exchange during sync.
Definition rankSyncParallelSkip.cc:144
void exchangeLinkUntimedData(int thread, std::atomic< int > &msg_count) override
Cause an exchange of Untimed Data to occur.
Definition rankSyncParallelSkip.cc:390
ActivityQueue * registerLink(const RankInfo &to_rank, const RankInfo &from_rank, const std::string &name, Link *link) override
Register a Link which this Sync Object is responsible for.
Definition rankSyncParallelSkip.cc:85
void prepareForComplete() override
Prepare for complete() stage.
Definition rankSyncParallelSkip.cc:140
RankSyncParallelSkip(RankInfo num_ranks)
Create a new Sync object which fires with a specified period.
Definition rankSyncParallelSkip.cc:46
Definition syncQueue.h:56
A class to convert between a component's view of time and the core's view of time.
Definition timeConverter.h:28