SST  7.0.0
StructuralSimulationToolkit
rankSyncParallelSkip.h
1 // Copyright 2009-2017 Sandia Corporation. Under the terms
2 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2017, Sandia Corporation
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  // Sync(TimeConverter* period);
37  RankSyncParallelSkip(RankInfo num_ranks, TimeConverter* minPartTC);
38  virtual ~RankSyncParallelSkip();
39 
40  /** Register a Link which this Sync Object is responsible for */
41  ActivityQueue* registerLink(const RankInfo& to_rank, const RankInfo& from_rank, LinkId_t link_id, Link* link) override;
42  void execute(int thread) override;
43 
44  /** Cause an exchange of Initialization Data to occur */
45  void exchangeLinkInitData(int thread, std::atomic<int>& msg_count) override;
46  /** Finish link configuration */
47  void finalizeLinkConfigurations() override;
48 
49  SimTime_t getNextSyncTime() override { return myNextSyncTime; }
50 
51  uint64_t getDataSize() const override;
52 
53 private:
54 
55  static SimTime_t myNextSyncTime;
56 
57  // Function that actually does the exchange during run
58  void exchange_master(int thread);
59  void exchange_slave(int thread);
60 
61  struct comm_send_pair {
62  RankInfo to_rank;
63  SyncQueue* squeue; // SyncQueue
64  char* sbuf;
65  uint32_t remote_size;
66  };
67 
68  struct comm_recv_pair {
69  uint32_t remote_rank;
70  uint32_t local_thread;
71  char* rbuf; // receive buffer
72  std::vector<Activity*> activity_vec;
73  uint32_t local_size;
74  bool recv_done;
75 #ifdef SST_CONFIG_HAVE_MPI
76  MPI_Request req;
77 #endif
78  };
79 
80  // typedef std::map<int, std::pair<SyncQueueC*, std::vector<char>* > > comm_map_t;
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's view of time and the core's view of time.
Definition: timeConverter.h:25
Definition: action.cc:17
Definition: syncManager.h:33
Definition: rankSyncParallelSkip.h:33
void finalizeLinkConfigurations() override
Finish link configuration.
Definition: rankSyncParallelSkip.cc:120
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 exchangeLinkInitData(int thread, std::atomic< int > &msg_count) override
Cause an exchange of Initialization Data to occur.
Definition: rankSyncParallelSkip.cc:399
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:42