SST  6.0.0
StructuralSimulationToolkit
rankSyncParallelSkip.h
1 // Copyright 2009-2016 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-2016, 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 
19 #include <map>
20 
21 #ifdef SST_CONFIG_HAVE_MPI
22 #include <mpi.h>
23 #endif
24 
25 namespace SST {
26 
27 class SyncQueue;
28 class TimeConverter;
29 
31 public:
32  /** Create a new Sync object which fires with a specified period */
33  // Sync(TimeConverter* period);
35  virtual ~RankSyncParallelSkip();
36 
37  /** Register a Link which this Sync Object is responsible for */
38  ActivityQueue* registerLink(const RankInfo& to_rank, const RankInfo& from_rank, LinkId_t link_id, Link* link);
39  void execute(int thread);
40 
41  /** Cause an exchange of Initialization Data to occur */
42  void exchangeLinkInitData(int thread, std::atomic<int>& msg_count);
43  /** Finish link configuration */
45 
46  SimTime_t getNextSyncTime() { return myNextSyncTime; }
47 
48  uint64_t getDataSize() const;
49 
50 private:
51 
52  static SimTime_t myNextSyncTime;
53  TimeConverter* minPartTC;
54 
55  // Function that actually does the exchange during run
56  void exchange_master(int thread);
57  void exchange_slave(int thread);
58 
59  struct comm_send_pair {
60  RankInfo to_rank;
61  SyncQueue* squeue; // SyncQueue
62  char* sbuf;
63  uint32_t remote_size;
64  };
65 
66  struct comm_recv_pair {
67  uint32_t remote_rank;
68  uint32_t local_thread;
69  char* rbuf; // receive buffer
70  std::vector<Activity*> activity_vec;
71  uint32_t local_size;
72  bool recv_done;
73 #ifdef SST_CONFIG_HAVE_MPI
74  MPI_Request req;
75 #endif
76  };
77 
78  // typedef std::map<int, std::pair<SyncQueueC*, std::vector<char>* > > comm_map_t;
79  typedef std::map<RankInfo, comm_send_pair > comm_send_map_t;
80  typedef std::map<RankInfo, comm_recv_pair > comm_recv_map_t;
81  typedef std::map<LinkId_t, Link*> link_map_t;
82 
83  // TimeConverter* period;
84  comm_send_map_t comm_send_map;
85  comm_recv_map_t comm_recv_map;
86  link_map_t link_map;
87 
88  double mpiWaitTime;
89  double deserializeTime;
90 
91  int* recv_count;
92  int send_count;
93 
94  std::atomic<int32_t> remaining_deser;
99 
100  void deserializeMessage(comm_recv_pair* msg);
101 
102 
103  Core::ThreadSafe::Barrier& barrier;
104 };
105 
106 
107 } // namespace SST
108 
109 #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
RankSyncParallelSkip(RankInfo num_ranks, Core::ThreadSafe::Barrier &barrier, TimeConverter *minPartTC)
Create a new Sync object which fires with a specified period.
Definition: rankSyncParallelSkip.cc:38
Definition: rankSyncParallelSkip.h:30
Definition: rankInfo.h:21
void finalizeLinkConfigurations()
Finish link configuration.
Definition: rankSyncParallelSkip.cc:116
Internal API.
Definition: syncQueue.h:31
Base Class for a queue of Activities.
Definition: activityQueue.h:22
ActivityQueue * registerLink(const RankInfo &to_rank, const RankInfo &from_rank, LinkId_t link_id, Link *link)
Register a Link which this Sync Object is responsible for.
Definition: rankSyncParallelSkip.cc:80
void exchangeLinkInitData(int thread, std::atomic< int > &msg_count)
Cause an exchange of Initialization Data to occur.
Definition: rankSyncParallelSkip.cc:410
Definition: threadsafe.h:42