8#include "boost/range/irange.hpp"
121 int rankOffset = 0) = 0;
142 int requesterCommunicatorSize) = 0;
163 int requesterCommunicatorSize) = 0;
183 int requesterRank) = 0;
233 virtual void reduceSum(
int itemToSend,
int &itemToReceive,
Rank primaryRank);
234 virtual void reduceSum(
int itemsToSend,
int &itemsToReceive);
239 virtual void allreduceSum(
double itemToSend,
double &itemToReceive,
Rank primaryRank);
240 virtual void allreduceSum(
double itemToSend,
double &itemToReceive);
242 virtual void allreduceSum(
int itemToSend,
int &itemToReceive,
Rank primaryRank);
243 virtual void allreduceSum(
int itemToSend,
int &itemToReceive);
254 virtual void broadcast(
int &itemToReceive,
Rank rankBroadcaster);
259 virtual void broadcast(
double itemToSend);
260 virtual void broadcast(
double &itemToReceive,
Rank rankBroadcaster);
263 virtual void broadcast(
bool &itemToReceive,
Rank rankBroadcaster);
294 virtual void send(
double itemToSend,
Rank rankReceiver) = 0;
301 virtual void send(
int itemToSend,
Rank rankReceiver) = 0;
308 virtual void send(
bool itemToSend,
Rank rankReceiver) = 0;
Interface for all interprocess communication classes.
virtual void receive(bool &itemToReceive, Rank rankSender)=0
Receives a bool from process with given rank.
virtual void cleanupEstablishment(std::string const &acceptorName, std::string const &requesterName)
Clean-up environment used to establish the communication.
virtual void receive(double &itemToReceive, Rank rankSender)=0
Receives a double from process with given rank.
virtual void receive(int &itemToReceive, Rank rankSender)=0
Receives an int from process with given rank.
virtual PtrRequest aSend(const double &itemToSend, Rank rankReceiver)=0
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.
virtual void requestConnectionAsClient(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, std::set< int > const &acceptorRanks, int requesterRank)=0
Connects to another communicator, which has to call acceptConnectionAsServer().
void setRankOffset(Rank rankOffset)
Set rank offset.
virtual void send(precice::span< const int > itemsToSend, Rank rankReceiver)=0
Sends an array of integer values.
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 void send(int itemToSend, Rank rankReceiver)=0
Sends an int to process with given rank.
virtual bool isConnected()
Returns true, if a connection to a remote participant has been setup.
virtual size_t getRemoteCommunicatorSize()=0
Returns the number of processes in the remote communicator.
virtual void acceptConnectionAsServer(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, int acceptorRank, int requesterCommunicatorSize)=0
Accepts connection from another communicator, which has to call requestConnectionAsClient().
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().
Communication & operator=(Communication &&)=delete
virtual PtrRequest aReceive(double &itemToReceive, Rank rankSender)=0
Asynchronously receives a double from process with given rank.
int _rankOffset
Rank offset for primaries-secondary communication, since ranks are from 0 to size-2.
virtual ~Communication()
Destructor, empty.
virtual PtrRequest aSend(precice::span< const double > itemsToSend, Rank rankReceiver)=0
virtual void send(precice::span< const double > itemsToSend, Rank rankReceiver)=0
Sends an array of double values.
virtual void send(bool itemToSend, Rank rankReceiver)=0
Sends a bool to process with given rank.
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 receive(precice::span< int > itemsToReceive, Rank rankSender)=0
Receives an array of integer values.
virtual PtrRequest aReceive(bool &itemToReceive, Rank rankSender)=0
Asynchronously receives a bool from process with given rank.
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 void receive(precice::span< double > itemsToReceive, Rank rankSender)=0
Receives an array of double values.
virtual PtrRequest aReceive(precice::span< double > itemsToReceive, int rankSender)=0
Asynchronously receives an array of double values.
virtual void send(double itemToSend, Rank rankReceiver)=0
Sends a double to process with given rank.
virtual PtrRequest aSend(const int &itemToSend, Rank rankReceiver)=0
virtual void allreduceSum(precice::span< double const > itemsToSend, precice::span< double > itemsToReceive, Rank primaryRank)
virtual PtrRequest aSend(const bool &itemToSend, Rank rankReceiver)=0
virtual void send(std::string const &itemToSend, Rank rankReceiver)=0
Sends a std::string to process with given rank.
virtual void closeConnection()=0
Disconnects from communication space, i.e. participant.
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 PtrRequest aReceive(int &itemToReceive, Rank rankSender)=0
Asynchronously receives an int from process with given rank.
virtual void broadcast(precice::span< const int > itemsToSend)
This class provides a lightweight logger.
A C++ 11 implementation of the non-owning C++20 std::span type.
void connectCircularComm(std::string const &participantName, std::string const &tag, int rank, int size, com::Communication &left, com::Communication &right)
Main namespace of the precice library.