SST  8.0.0
StructuralSimulationToolkit
rankSyncParallelSkip.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_RANKSYNCPARALLELSKIP_H
13 #define SST_CORE_RANKSYNCPARALLELSKIP_H
14 
15 #include "sst/core/sst_types.h"
16 #include <sst/core/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 public:
35  /** Create a new Sync object which fires with a specified period */
36  RankSyncParallelSkip(RankInfo num_ranks, TimeConverter* minPartTC);
37  virtual ~RankSyncParallelSkip();
38 
39  /** Register a Link which this Sync Object is responsible for */
40  ActivityQueue* registerLink(const RankInfo& to_rank, const RankInfo& from_rank, LinkId_t link_id, 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  SimTime_t getNextSyncTime() override { return myNextSyncTime; }
51 
52  uint64_t getDataSize() const override;
53 
54 private:
55 
56  static SimTime_t myNextSyncTime;
57 
58  // Function that actually does the exchange during run
59  void exchange_master(int thread);
60  void exchange_slave(int thread);
61 
62  struct comm_send_pair {
63  RankInfo to_rank;
64  SyncQueue* squeue; // SyncQueue
65  char* sbuf;
66  uint32_t remote_size;
67  };
68 
69  struct comm_recv_pair {
70  uint32_t remote_rank;
71  uint32_t local_thread;
72  char* rbuf; // receive buffer
73  std::vector<Activity*> activity_vec;
74  uint32_t local_size;
75  bool recv_done;
76 #ifdef SST_CONFIG_HAVE_MPI
77  MPI_Request req;
78 #endif
79  };
80 
81  typedef std::map<RankInfo, comm_send_pair > comm_send_map_t;
82  typedef std::map<RankInfo, comm_recv_pair > comm_recv_map_t;
83  typedef std::map<LinkId_t, Link*> link_map_t;
84 
85  // TimeConverter* period;
86  comm_send_map_t comm_send_map;
87  comm_recv_map_t comm_recv_map;
88  link_map_t link_map;
89 
90  double mpiWaitTime;
91  double deserializeTime;
92 
93  int* recv_count;
94  int send_count;
95 
96  std::atomic<int32_t> remaining_deser;
101 
102  void deserializeMessage(comm_recv_pair* msg);
103 
104 
105  Core::ThreadSafe::Barrier serializeReadyBarrier;
106  Core::ThreadSafe::Barrier slaveExchangeDoneBarrier;
107  Core::ThreadSafe::Barrier allDoneBarrier;
108 };
109 
110 
111 } // namespace SST
112 
113 #endif // SST_CORE_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:25
Definition: syncManager.h:33
Definition: rankSyncParallelSkip.h:33
void finalizeLinkConfigurations() override
Finish link configuration.
Definition: rankSyncParallelSkip.cc:117
void prepareForComplete() override
Prepare for complete() stage.
Definition: rankSyncParallelSkip.cc:130
Definition: rankInfo.h:21
ActivityQueue * registerLink(const RankInfo &to_rank, const RankInfo &from_rank, LinkId_t link_id, Link *link) override
Register a Link which this Sync Object is responsible for.
Definition: rankSyncParallelSkip.cc:84
Internal API.
Definition: syncQueue.h:31
void exchangeLinkUntimedData(int thread, std::atomic< int > &msg_count) override
Cause an exchange of Untimed Data to occur.
Definition: rankSyncParallelSkip.cc:350
RankSyncParallelSkip(RankInfo num_ranks, TimeConverter *minPartTC)
Create a new Sync object which fires with a specified period.
Definition: rankSyncParallelSkip.cc:41
Base Class for a queue of Activities.
Definition: activityQueue.h:22
Definition: threadsafe.h:45