SST  14.1.0
StructuralSimulationToolkit
threadSyncSimpleSkip.h
1 // Copyright 2009-2024 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-2024, 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/sst_types.h"
17 #include "sst/core/sync/syncManager.h"
18 #include "sst/core/sync/syncQueue.h"
19 #include "sst/core/threadsafe.h"
20 
21 #include <unordered_map>
22 
23 namespace SST {
24 
25 class ActivityQueue;
26 class Link;
27 class TimeConverter;
28 class Exit;
29 class Event;
30 class Simulation_impl;
31 class ThreadSyncQueue;
32 
34 {
35 public:
36  /** Create a new ThreadSync object */
37  ThreadSyncSimpleSkip(int num_threads, int thread, Simulation_impl* sim);
38  ThreadSyncSimpleSkip() {} // For serialization only
40 
41  void setMaxPeriod(TimeConverter* period);
42 
43  void before() override;
44  void after() override;
45  void execute(void) override;
46 
47  /** Set signals to exchange during sync */
48  void setSignals(int end, int usr, int alrm) override;
49  /** Return exchanged signals after sync */
50  bool getSignals(int& end, int& usr, int& alrm) override;
51 
52  /** Cause an exchange of Untimed Data to occur */
53  void processLinkUntimedData() override;
54  /** Finish link configuration */
55  void finalizeLinkConfigurations() override;
56  void prepareForComplete() override;
57 
58  /** Register a Link which this Sync Object is responsible for */
59  void registerLink(const std::string& name, Link* link) override;
60  ActivityQueue* registerRemoteLink(int tid, const std::string& name, Link* link) override;
61 
62  uint64_t getDataSize() const;
63 
64 
65  // static void disable() { disabled = true; barrier.disable(); }
66 
67 private:
68  // Stores the links until they can be intialized with the right
69  // remote data. It will hold whichever thread registers the link
70  // first and will be removed after the second thread registers and
71  // the link is properly initialized with the remote data.
72  std::unordered_map<std::string, Link*> link_map;
73 
74  std::vector<ThreadSyncQueue*> queues;
75  SimTime_t my_max_period;
76  int num_threads;
77  int thread;
78  static SimTime_t localMinimumNextActivityTime;
79  Simulation_impl* sim;
80  static Core::ThreadSafe::Barrier barrier[3];
81  double totalWaitTime;
82  bool single_rank;
84  static int sig_end_;
85  static int sig_usr_;
86  static int sig_alrm_;
87 };
88 
89 } // namespace SST
90 
91 #endif // SST_CORE_SYNC_THREADSYNCSIMPLESKIP_H
A class to convert between a component&#39;s view of time and the core&#39;s view of time.
Definition: timeConverter.h:27
void setSignals(int end, int usr, int alrm) override
Set signals to exchange during sync.
Definition: threadSyncSimpleSkip.cc:182
Definition: action.cc:18
Definition: threadSyncSimpleSkip.h:33
Definition: syncManager.h:87
void registerLink(const std::string &name, Link *link) override
Register a Link which this Sync Object is responsible for.
Definition: threadSyncSimpleSkip.cc:66
void processLinkUntimedData() override
Cause an exchange of Untimed Data to occur.
Definition: threadSyncSimpleSkip.cc:143
Main control class for a SST Simulation.
Definition: simulation_impl.h:76
void finalizeLinkConfigurations() override
Finish link configuration.
Definition: threadSyncSimpleSkip.cc:159
Definition: threadsafe.h:121
bool getSignals(int &end, int &usr, int &alrm) override
Return exchanged signals after sync.
Definition: threadSyncSimpleSkip.cc:190
Base Class for a queue of Activities.
Definition: activityQueue.h:21
Definition: threadsafe.h:47