22 std::string primaryName = participantName +
"Primary";
23 std::string secondaryName = participantName +
"Secondary";
25 constexpr Rank rankOffset = 1;
26 int secondaryRanksSize = size - rankOffset;
28 PRECICE_INFO(
"Connecting Primary rank to {} Secondary ranks", secondaryRanksSize);
33 int secondaryRank = rank - rankOffset;
34 PRECICE_INFO(
"Connecting Secondary rank #{} to Primary rank", secondaryRank);
35 requestConnection(primaryName, secondaryName, tag, secondaryRank, secondaryRanksSize);
54 for (
size_t i = 0; i < itemsToReceive.
size(); i++) {
55 itemsToReceive[i] += received[i];
65 auto request =
aSend(itemsToSend, primaryRank);
73 itemToReceive = itemToSend;
79 itemToReceive += itemToSend;
87 auto request =
aSend(itemToSend, primaryRank);
118 reduceSum(itemsToSend, itemsToReceive, primaryRank);
127 itemToReceive = itemToSend;
133 itemToReceive += itemToSend;
148 auto request =
aSend(itemToSend, primaryRank);
158 itemToReceive = itemToSend;
164 itemToReceive += itemToSend;
179 auto request =
aSend(itemToSend, primaryRank);
266 int item = itemToSend;
275 itemToReceive = item;
312 int size = itemsToSend.
size();
313 send(size, rankReceiver);
315 send(itemsToSend, rankReceiver);
321 int size = itemsToSend.
size();
322 send(size, rankReceiver);
324 send(itemsToSend, rankReceiver);
375 const int prevProc = (rank - 1 + size) % size;
376 const int nextProc = (rank + 1) % size;
381 if ((rank % 2) == 0) {
382 left.prepareEstablishment(prevName, thisName);
383 left.acceptConnection(prevName, thisName, tag, 0);
384 left.cleanupEstablishment(prevName, thisName);
386 right.requestConnection(thisName, nextName, tag, 0, 1);
388 right.requestConnection(thisName, nextName, tag, 0, 1);
390 left.prepareEstablishment(prevName, thisName);
391 left.acceptConnection(prevName, thisName, tag, 0);
392 left.cleanupEstablishment(prevName, thisName);
#define PRECICE_TRACE(...)
#define PRECICE_INFO(...)
#define PRECICE_ASSERT(...)
Interface for all interprocess communication classes.
virtual void cleanupEstablishment(std::string const &acceptorName, std::string const &requesterName)
Clean-up environment used to establish the communication.
virtual PtrRequest aSend(precice::span< const int > itemsToSend, Rank rankReceiver)=0
virtual void receive(std::string &itemToReceive, Rank rankSender)=0
Receives a std::string from process with given rank.
std::vector< int > receiveRange(Rank rankSender, AsVectorTag< int >)
Receives a range of ints as a vector<int>
void connectIntraComm(std::string const &participantName, std::string const &tag, int rank, int size)
auto remoteCommunicatorRanks()
Returns a range over all valid remote ranks.
virtual void prepareEstablishment(std::string const &acceptorName, std::string const &requesterName)
Prepare environment used to establish the communication.
virtual size_t getRemoteCommunicatorSize()=0
Returns the number of processes in the remote communicator.
virtual void acceptConnection(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, int acceptorRank, int rankOffset=0)=0
Accepts connection from another communicator, which has to call requestConnection().
int _rankOffset
Rank offset for primaries-secondary communication, since ranks are from 0 to size-2.
void sendRange(precice::span< const double > itemsToSend, Rank rankReceiver)
Sends a range of doubles (size + content)
virtual int adjustRank(Rank rank) const
Adjusts the given rank bases on the _rankOffset.
virtual void requestConnection(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, int requesterRank, int requesterCommunicatorSize)=0
Connects to another communicator, which has to call acceptConnection().
virtual PtrRequest aReceive(precice::span< double > itemsToReceive, int rankSender)=0
Asynchronously receives an array of double values.
virtual void allreduceSum(precice::span< double const > itemsToSend, precice::span< double > itemsToReceive, Rank primaryRank)
virtual void send(std::string const &itemToSend, Rank rankReceiver)=0
Sends a std::string to process with given rank.
virtual void reduceSum(precice::span< double const > itemsToSend, precice::span< double > itemsToReceive, Rank primaryRank)
Performs a reduce summation on the rank given by primaryRank.
virtual void broadcast(precice::span< const int > itemsToSend)
A C++ 11 implementation of the non-owning C++20 std::span type.
constexpr iterator begin() const noexcept
constexpr iterator end() const noexcept
constexpr size_type size() const noexcept
contains the data communication abstraction layer.
void connectCircularComm(std::string const &participantName, std::string const &tag, int rank, int size, com::Communication &left, com::Communication &right)