SST 12.1.0
Structural Simulation Toolkit
rankSyncParallelSkip.h
1// Copyright 2009-2022 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-2022, 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
23DISABLE_WARN_MISSING_OVERRIDE
24#include <mpi.h>
25REENABLE_WARNING
26#endif
27
28namespace SST {
29
30class SyncQueue;
31class TimeConverter;
32
34{
35public:
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
56private:
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};
112
113} // namespace SST
114
115#endif // SST_CORE_SYNC_RANKSYNCPARALLELSKIP_H
Base Class for a queue of Activities.
Definition: activityQueue.h:22
Definition: threadsafe.h:48
Definition: threadsafe.h:153
Definition: threadsafe.h:254
Definition: rankInfo.h:22
Definition: rankSyncParallelSkip.h:34
void finalizeLinkConfigurations() override
Finish link configuration.
Definition: rankSyncParallelSkip.cc:128
void exchangeLinkUntimedData(int thread, std::atomic< int > &msg_count) override
Cause an exchange of Untimed Data to occur.
Definition: rankSyncParallelSkip.cc:367
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 prepareForComplete() override
Prepare for complete() stage.
Definition: rankSyncParallelSkip.cc:138
Definition: syncManager.h:38
Internal API.
Definition: syncQueue.h:30
A class to convert between a component's view of time and the core's view of time.
Definition: timeConverter.h:27