SST 16.0.0
Structural Simulation Toolkit
threadSyncSimpleSkip.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_THREADSYNCSIMPLESKIP_H
13#define SST_CORE_SYNC_THREADSYNCSIMPLESKIP_H
14
15#include "sst/core/action.h"
16#include "sst/core/simulation.h"
17#include "sst/core/sst_types.h"
18#include "sst/core/sync/syncManager.h"
19#include "sst/core/sync/syncQueue.h"
20#include "sst/core/threadsafe.h"
21
22#include <atomic>
23#include <cstdint>
24#include <string>
25#include <unordered_map>
26#include <vector>
27
28namespace SST {
29
30class ActivityQueue;
31class Link;
32class TimeConverter;
33class Exit;
34class Event;
35class Simulation;
36class ThreadSyncQueue;
37
38class ThreadSyncSimpleSkip : public ThreadSync
39{
40public:
41 /** Create a new ThreadSync object */
42 ThreadSyncSimpleSkip(int num_threads, int thread, Simulation* sim);
43 ThreadSyncSimpleSkip() {} // For serialization only
45
46 void setMaxPeriod(TimeConverter* period);
47
48 void before() override;
49 void after() override;
50 void execute() 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 setFlags(bool enter_interactive, bool enter_shutdown, Simulation::ShutdownMode_t shutdown_mode) override;
61 /** Return exchanged interactive flags after sync */
62 void getShutdownFlags(bool& enter_shutdown, Simulation::ShutdownMode_t& shutdown_mode) override;
63 void getFlags(bool& enter_interactive, bool& enter_shutdown, Simulation::ShutdownMode_t& shutdown_mode) override;
64 /** Clear interactive flags before next run */
65 void clearFlags() override;
66
67 /** Cause an exchange of Untimed Data to occur */
68 void processLinkUntimedData() override;
69 /** Finish link configuration */
70 void finalizeLinkConfigurations() override;
71 void prepareForComplete() override;
72
73 /** Register a Link which this Sync Object is responsible for */
74 void registerLink(Link* link) override;
75 ActivityQueue* registerRemoteLink(int tid, Link* link) override;
76
77 uint64_t getDataSize() const;
78
79 SimTime_t findSyncInterval() override;
80
81
82 // static void disable() { disabled = true; barrier.disable(); }
83
84private:
85 // Stores the links until they can be intialized with the right
86 // remote data. It will hold whichever thread registers the link
87 // first and will be removed after the second thread registers and
88 // the link is properly initialized with the remote data.
89 std::unordered_map<LinkId_t, Link*> link_map;
90
91 // Need to keep a list of all the Links in order to do the sync interval optimization after the init() phase. After
92 // than optimization pass completes, the vector can be cleared.
93 std::vector<Link*> link_vec;
94
95 std::vector<ThreadSyncQueue*> queues;
96 int num_threads;
97 int thread;
98 static SimTime_t localMinimumNextActivityTime;
99 Simulation* sim;
100 static Core::ThreadSafe::Barrier barrier[3];
101 double totalWaitTime;
102 bool single_rank;
104 static int sig_end_;
105 static int sig_usr_;
106 static int sig_alrm_;
107 static std::atomic<bool> enter_interactive_;
108 static std::atomic<bool> enter_shutdown_;
109 static std::atomic<unsigned> shutdown_mode_;
110};
111
112} // namespace SST
113
114#endif // SST_CORE_SYNC_THREADSYNCSIMPLESKIP_H
Base Class for a queue of Activities.
Definition activityQueue.h:22
Definition threadsafe.h:50
Definition threadsafe.h:138
Base class for Events - Items sent across links to communicate between components.
Definition event.h:41
Exit Action.
Definition exit.h:35
Main control class for a SST Simulation.
Definition simulation.h:121
Definition syncQueue.h:100
ThreadSyncSimpleSkip(int num_threads, int thread, Simulation *sim)
Create a new ThreadSync object.
Definition threadSyncSimpleSkip.cc:31
void registerLink(Link *link) override
Register a Link which this Sync Object is responsible for.
Definition threadSyncSimpleSkip.cc:70
void processLinkUntimedData() override
Cause an exchange of Untimed Data to occur.
Definition threadSyncSimpleSkip.cc:148
void setShutdownFlags(bool enter_shutdown, Simulation::ShutdownMode_t shutdown_mode) override
Set interactive flags to exchange during sync.
Definition threadSyncSimpleSkip.cc:224
void setSignals(int end, int usr, int alrm) override
Set signals to exchange during sync.
Definition threadSyncSimpleSkip.cc:207
bool getSignals(int &end, int &usr, int &alrm) override
Return exchanged signals after sync.
Definition threadSyncSimpleSkip.cc:215
void finalizeLinkConfigurations() override
Finish link configuration.
Definition threadSyncSimpleSkip.cc:164
void clearFlags() override
Clear interactive flags before next run.
Definition threadSyncSimpleSkip.cc:267
void getShutdownFlags(bool &enter_shutdown, Simulation::ShutdownMode_t &shutdown_mode) override
Return exchanged interactive flags after sync.
Definition threadSyncSimpleSkip.cc:242
A class to convert between a component's view of time and the core's view of time.
Definition timeConverter.h:31