SST  13.0.0
StructuralSimulationToolkit
rankSyncParallelSkip.h
1 // Copyright 2009-2023 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-2023, 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_types.h"
16 #include "sst/core/sync/syncManager.h"
17 #include "sst/core/threadsafe.h"
18 #include "sst/core/warnmacros.h"
19 
20 #include <map>
21 
22 #ifdef SST_CONFIG_HAVE_MPI
23 DISABLE_WARN_MISSING_OVERRIDE
24 #include <mpi.h>
25 REENABLE_WARNING
26 #endif
27 
28 namespace SST {
29 
30 class SyncQueue;
31 class TimeConverter;
32 
34 {
35 public:
36  /** Create a new Sync object which fires with a specified period */
37  RankSyncParallelSkip(RankInfo num_ranks, TimeConverter* minPartTC);
38  virtual ~RankSyncParallelSkip();
39 
40  /** Register a Link which this Sync Object is responsible for */
42  registerLink(const RankInfo& to_rank, const RankInfo& from_rank, const std::string& name, 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 complete() stage */
50  void prepareForComplete() override;
51 
52  SimTime_t getNextSyncTime() override { return myNextSyncTime; }
53 
54  uint64_t getDataSize() const override;
55 
56 private:
57  static SimTime_t myNextSyncTime;
58 
59  // Function that actually does the exchange during run
60  void exchange_master(int thread);
61  void exchange_slave(int thread);
62 
63  struct comm_send_pair
64  {
65  RankInfo to_rank;
66  SyncQueue* squeue; // SyncQueue
67  char* sbuf;
68  uint32_t remote_size;
69  };
70 
71  struct comm_recv_pair
72  {
73  uint32_t remote_rank;
74  uint32_t local_thread;
75  char* rbuf; // receive buffer
76  std::vector<Activity*> activity_vec;
77  uint32_t local_size;
78  bool recv_done;
79 #ifdef SST_CONFIG_HAVE_MPI
80  MPI_Request req;
81 #endif
82  };
83 
84  typedef std::map<RankInfo, comm_send_pair> comm_send_map_t;
85  typedef std::map<RankInfo, comm_recv_pair> comm_recv_map_t;
86  // typedef std::map<LinkId_t, Link*> link_map_t;
87  typedef std::map<std::string, uintptr_t> link_map_t;
88 
89  // TimeConverter* period;
90  comm_send_map_t comm_send_map;
91  comm_recv_map_t comm_recv_map;
92  link_map_t link_map;
93 
94  double mpiWaitTime;
95  double deserializeTime;
96 
97  int* recv_count;
98  int send_count;
99 
100  std::atomic<int32_t> remaining_deser;
105 
106  void deserializeMessage(comm_recv_pair* msg);
107 
108  Core::ThreadSafe::Barrier serializeReadyBarrier;
109  Core::ThreadSafe::Barrier slaveExchangeDoneBarrier;
110  Core::ThreadSafe::Barrier allDoneBarrier;
111 
113 };
114 
115 } // namespace SST
116 
117 #endif // SST_CORE_SYNC_RANKSYNCPARALLELSKIP_H
A class to convert between a component&#39;s view of time and the core&#39;s view of time.
Definition: timeConverter.h:26
Definition: syncManager.h:37
Definition: action.cc:18
Definition: rankSyncParallelSkip.h:33
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:93
void finalizeLinkConfigurations() override
Finish link configuration.
Definition: rankSyncParallelSkip.cc:130
void prepareForComplete() override
Prepare for complete() stage.
Definition: rankSyncParallelSkip.cc:140
Definition: rankInfo.h:21
Definition: threadsafe.h:121
Definition: threadsafe.h:253
Internal API.
Definition: syncQueue.h:29
void exchangeLinkUntimedData(int thread, std::atomic< int > &msg_count) override
Cause an exchange of Untimed Data to occur.
Definition: rankSyncParallelSkip.cc:369
RankSyncParallelSkip(RankInfo num_ranks, TimeConverter *minPartTC)
Create a new Sync object which fires with a specified period.
Definition: rankSyncParallelSkip.cc:52
Base Class for a queue of Activities.
Definition: activityQueue.h:21
Definition: threadsafe.h:47
Definition: threadsafe.h:152