SST  8.0.0
StructuralSimulationToolkit
threadSync.h
1 // Copyright 2009-2018 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-2018, 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_THREADSYNC_H
13 #define SST_CORE_THREADSYNC_H
14 
15 #include "sst/core/sst_types.h"
16 
17 #include <unordered_map>
18 
19 #include "sst/core/action.h"
20 #include "sst/core/threadSyncQueue.h"
21 
22 namespace SST {
23 
24 class SyncQueue;
25 
26 
27 class ActivityQueue;
28 class Link;
29 class TimeConverter;
30 class Exit;
31 class Event;
32 class Simulation;
33 class ThreadSyncQueue;
34 
35 class ThreadSync : public Action {
36 public:
37  /** Create a new ThreadSync object */
38  ThreadSync(int num_threads, Simulation* sim);
39  ~ThreadSync();
40 
41  void setMaxPeriod(TimeConverter* period);
42 
43  /** Register a Link which this Sync Object is responsible for */
44  void registerLink(LinkId_t link_id, Link* link);
45  ActivityQueue* getQueueForThread(int tid);
46 
47  void execute(void) override;
48 
49  /** Cause an exchange of Untimed Data to occur */
51  /** Finish link configuration */
53 
54  uint64_t getDataSize() const;
55 
56  void print(const std::string& header, Output &out) const override;
57 
58  static void disable() { disabled = true; barrier.disable(); }
59 
60 private:
61  std::vector<ThreadSyncQueue*> queues;
62  std::unordered_map<LinkId_t, Link*> link_map;
63  TimeConverter* max_period;
64  int num_threads;
65  Simulation* sim;
66  static bool disabled;
67  static Core::ThreadSafe::Barrier barrier;
68  double totalWaitTime;
69  bool single_rank;
70 };
71 
72 
73 } // namespace SST
74 
75 #endif // SST_CORE_THREADSYNC_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:54
An Action is a schedulable Activity which is not an Event.
Definition: action.h:30
Main control class for a SST Simulation.
Definition: simulation.h:72
A class to convert between a component&#39;s view of time and the core&#39;s view of time.
Definition: timeConverter.h:25
void execute(void) override
Function which will be called when the time for this Activity comes to pass.
Definition: threadSync.cc:75
void finalizeLinkConfigurations()
Finish link configuration.
Definition: threadSync.cc:130
void processLinkUntimedData()
Cause an exchange of Untimed Data to occur.
Definition: threadSync.cc:109
void print(const std::string &header, Output &out) const override
Generic print-print function for this Activity.
Definition: threadSync.cc:144
Definition: threadSync.h:35
ThreadSync(int num_threads, Simulation *sim)
Create a new ThreadSync object.
Definition: threadSync.cc:26
Base Class for a queue of Activities.
Definition: activityQueue.h:22
void registerLink(LinkId_t link_id, Link *link)
Register a Link which this Sync Object is responsible for.
Definition: threadSync.cc:63
Definition: threadsafe.h:45