preCICE v3.1.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
precice::com::Communication Class Referenceabstract

Interface for all interprocess communication classes. More...

#include <Communication.hpp>

Inheritance diagram for precice::com::Communication:
[legend]
Collaboration diagram for precice::com::Communication:
[legend]

Public Member Functions

Communicationoperator= (Communication &&)=delete
 
virtual ~Communication ()
 Destructor, empty.
 
void setRankOffset (Rank rankOffset)
 Set rank offset.
 
Connection Setup
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.
 
auto remoteCommunicatorRanks ()
 Returns a range over all valid remote ranks.
 
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().
 
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 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 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 connectIntraComm (std::string const &participantName, std::string const &tag, int rank, int size)
 
virtual void closeConnection ()=0
 Disconnects from communication space, i.e. participant.
 
virtual void prepareEstablishment (std::string const &acceptorName, std::string const &requesterName)
 Prepare environment used to establish the communication.
 
virtual void cleanupEstablishment (std::string const &acceptorName, std::string const &requesterName)
 Clean-up environment used to establish the communication.
 
Reduction
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 reduceSum (precice::span< double const > itemsToSend, precice::span< double > itemsToReceive)
 Performs a reduce summation on the primary rank, every other rank has to call reduceSum.
 
virtual void reduceSum (int itemToSend, int &itemToReceive, Rank primaryRank)
 
virtual void reduceSum (int itemsToSend, int &itemsToReceive)
 
virtual void allreduceSum (precice::span< double const > itemsToSend, precice::span< double > itemsToReceive, Rank primaryRank)
 
virtual void allreduceSum (precice::span< double const > itemsToSend, precice::span< double > itemsToReceive)
 
virtual void allreduceSum (double itemToSend, double &itemToReceive, Rank primaryRank)
 
virtual void allreduceSum (double itemToSend, double &itemToReceive)
 
virtual void allreduceSum (int itemToSend, int &itemToReceive, Rank primaryRank)
 
virtual void allreduceSum (int itemToSend, int &itemToReceive)
 
Broadcast
virtual void broadcast (precice::span< const int > itemsToSend)
 
virtual void broadcast (precice::span< int > itemsToReceive, Rank rankBroadcaster)
 
virtual void broadcast (int itemToSend)
 
virtual void broadcast (int &itemToReceive, Rank rankBroadcaster)
 
virtual void broadcast (precice::span< const double > itemsToSend)
 
virtual void broadcast (precice::span< double > itemsToReceive, Rank rankBroadcaster)
 
virtual void broadcast (double itemToSend)
 
virtual void broadcast (double &itemToReceive, Rank rankBroadcaster)
 
virtual void broadcast (bool itemToSend)
 
virtual void broadcast (bool &itemToReceive, Rank rankBroadcaster)
 
virtual void broadcast (std::vector< int > const &v)
 
virtual void broadcast (std::vector< int > &v, Rank rankBroadcaster)
 
virtual void broadcast (std::vector< double > const &v)
 
virtual void broadcast (std::vector< double > &v, Rank rankBroadcaster)
 
Send
virtual void send (std::string const &itemToSend, Rank rankReceiver)=0
 Sends a std::string to process with given rank.
 
virtual void send (precice::span< const int > itemsToSend, Rank rankReceiver)=0
 Sends an array of integer values.
 
virtual PtrRequest aSend (precice::span< const int > itemsToSend, Rank rankReceiver)=0
 
virtual void send (precice::span< const double > itemsToSend, Rank rankReceiver)=0
 Sends an array of double values.
 
virtual PtrRequest aSend (precice::span< const double > itemsToSend, Rank rankReceiver)=0
 
virtual void send (double itemToSend, Rank rankReceiver)=0
 Sends a double to process with given rank.
 
virtual PtrRequest aSend (const double &itemToSend, Rank rankReceiver)=0
 
virtual void send (int itemToSend, Rank rankReceiver)=0
 Sends an int to process with given rank.
 
virtual PtrRequest aSend (const int &itemToSend, Rank rankReceiver)=0
 
virtual void send (bool itemToSend, Rank rankReceiver)=0
 Sends a bool to process with given rank.
 
virtual PtrRequest aSend (const bool &itemToSend, Rank rankReceiver)=0
 
Receive
virtual void receive (std::string &itemToReceive, Rank rankSender)=0
 Receives a std::string from process with given rank.
 
virtual void receive (precice::span< int > itemsToReceive, Rank rankSender)=0
 Receives an array of integer values.
 
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 receive (double &itemToReceive, Rank rankSender)=0
 Receives a double from process with given rank.
 
virtual PtrRequest aReceive (double &itemToReceive, Rank rankSender)=0
 Asynchronously 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 aReceive (int &itemToReceive, Rank rankSender)=0
 Asynchronously receives an int from process with given rank.
 
virtual void receive (bool &itemToReceive, Rank rankSender)=0
 Receives a bool from process with given rank.
 
virtual PtrRequest aReceive (bool &itemToReceive, Rank rankSender)=0
 Asynchronously receives a bool from process with given rank.
 
Range communication
void sendRange (precice::span< const double > itemsToSend, Rank rankReceiver)
 Sends a range of doubles (size + content)
 
void sendRange (precice::span< const int > itemsToSend, Rank rankReceiver)
 Sends a range of ints (size + content)
 
std::vector< int > receiveRange (Rank rankSender, AsVectorTag< int >)
 Receives a range of ints as a vector<int>
 
std::vector< double > receiveRange (Rank rankSender, AsVectorTag< double >)
 Receives a range of doubles as a vector<double>
 

Protected Member Functions

virtual int adjustRank (Rank rank) const
 Adjusts the given rank bases on the _rankOffset.
 

Protected Attributes

int _rankOffset = 0
 Rank offset for primaries-secondary communication, since ranks are from 0 to size-2.
 
bool _isConnected = false
 

Private Attributes

logging::Logger _log {"com::Communication"}
 

Detailed Description

Interface for all interprocess communication classes.

By default, communication is done within the local communication space. In order to connect to a different communication space, i.e. coupling participant, the methods acceptConnection() and requestConnection() have to called by the two participants which intend to establish a connection. All following communication and process ranking refers to the remote communication space afterwards.

Sending methods prefixed with ‘a’ are asynchronous. It means that they return immediately, even though either the actual sending might have not been started yet or data from user buffer that is being supplied has not been safely stored away (to system buffer) yet. This implies that user buffer cannot be immediately reused (for writing) after asynchronous sending call returns. However, a special corresponding "request" object is returned by all asynchronous sending methods, which could be further used in future in order to properly wait (block execution) until either the corresponding sending request has truly finished or data from user buffer that is being supplied has been safely stored away (to system buffer) and, thus, can be reused (for writing).

The main benefit from asynchronous sending methods is their deterministic behavior, i.e. the guarantee that they can never block the execution (return immediately). The two typical scenarios where this comes handy are:

  1. Robustness — allows one to write deadlock-prone communication algorithms (see point-to-point communication).
  2. Efficiency — allows one to perform some useful computational work while sending is happening on the background.
Attention
All receive methods, that accept a raw array, expect it to be sized appropriately. Asynchronous receive methods also expect the vector be sized correctly.

Definition at line 65 of file Communication.hpp.

Constructor & Destructor Documentation

◆ ~Communication()

virtual precice::com::Communication::~Communication ( )
inlinevirtual

Destructor, empty.

Definition at line 71 of file Communication.hpp.

Member Function Documentation

◆ acceptConnection()

virtual void precice::com::Communication::acceptConnection ( std::string const & acceptorName,
std::string const & requesterName,
std::string const & tag,
int acceptorRank,
int rankOffset = 0 )
pure virtual

Accepts connection from another communicator, which has to call requestConnection().

Establishes a 1-to-N communication, whereas the acceptor's side is the "1". Contrary to acceptConnectionAsServer(), the other side needs to be a proper communicator with ranks from 0 to N-1. It is not necessary to know this "N" a-priori on the acceptor's side. This communication is used for the 1:1 communication between two primary ranks and for the intra-participant communication. For the last case, setRankOffset() has to be set.

Parameters
[in]acceptorNameName of calling participant.
[in]requesterNameName of remote participant to connect to.
[in]tagTag for establishing this connection
[in]acceptorRankRank of the accpeting process, usually the calling one.

Implemented in precice::com::MPIDirectCommunication, precice::com::MPIPortsCommunication, precice::com::MPISinglePortsCommunication, and precice::com::SocketCommunication.

◆ acceptConnectionAsServer()

virtual void precice::com::Communication::acceptConnectionAsServer ( std::string const & acceptorName,
std::string const & requesterName,
std::string const & tag,
int acceptorRank,
int requesterCommunicatorSize )
pure virtual

Accepts connection from another communicator, which has to call requestConnectionAsClient().

Establishes a 1-to-N communication, whereas the acceptor's side is the "1". Contrary to acceptConnection(), the other side can have arbitrary ranks. However, we need to know its size "N" a-priori. This communication is only used in PointToPointCommunication, i.e. for the M-to-N communication between two participants.

Parameters
[in]acceptorNameName of calling participant.
[in]requesterNameName of remote participant to connect to.
[in]tagTag for establishing this connection
[in]acceptorRankRank of accepting server, usually the rank of the current process.
[in]requesterCommunicatorSizeSize of the requester (N)

Implemented in precice::com::MPIDirectCommunication, precice::com::MPIPortsCommunication, precice::com::MPISinglePortsCommunication, and precice::com::SocketCommunication.

◆ adjustRank()

int precice::com::Communication::adjustRank ( Rank rank) const
protectedvirtual

Adjusts the given rank bases on the _rankOffset.

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 354 of file Communication.cpp.

◆ allreduceSum() [1/6]

void precice::com::Communication::allreduceSum ( double itemToSend,
double & itemToReceive )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 123 of file Communication.cpp.

Here is the call graph for this function:

◆ allreduceSum() [2/6]

void precice::com::Communication::allreduceSum ( double itemToSend,
double & itemToReceive,
Rank primaryRank )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 144 of file Communication.cpp.

Here is the call graph for this function:

◆ allreduceSum() [3/6]

void precice::com::Communication::allreduceSum ( int itemToSend,
int & itemToReceive )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 154 of file Communication.cpp.

Here is the call graph for this function:

◆ allreduceSum() [4/6]

void precice::com::Communication::allreduceSum ( int itemToSend,
int & itemToReceive,
Rank primaryRank )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 175 of file Communication.cpp.

Here is the call graph for this function:

◆ allreduceSum() [5/6]

void precice::com::Communication::allreduceSum ( precice::span< double const > itemsToSend,
precice::span< double > itemsToReceive )
virtual
Attention
This method modifies the input buffer.

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 94 of file Communication.cpp.

Here is the call graph for this function:

◆ allreduceSum() [6/6]

void precice::com::Communication::allreduceSum ( precice::span< double const > itemsToSend,
precice::span< double > itemsToReceive,
Rank primaryRank )
virtual
Attention
This method modifies the input buffer.

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 113 of file Communication.cpp.

Here is the call graph for this function:

◆ aReceive() [1/4]

virtual PtrRequest precice::com::Communication::aReceive ( bool & itemToReceive,
Rank rankSender )
pure virtual

Asynchronously receives a bool from process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ aReceive() [2/4]

virtual PtrRequest precice::com::Communication::aReceive ( double & itemToReceive,
Rank rankSender )
pure virtual

Asynchronously receives a double from process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ aReceive() [3/4]

virtual PtrRequest precice::com::Communication::aReceive ( int & itemToReceive,
Rank rankSender )
pure virtual

Asynchronously receives an int from process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ aReceive() [4/4]

virtual PtrRequest precice::com::Communication::aReceive ( precice::span< double > itemsToReceive,
int rankSender )
pure virtual

Asynchronously receives an array of double values.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ aSend() [1/5]

virtual PtrRequest precice::com::Communication::aSend ( const bool & itemToSend,
Rank rankReceiver )
pure virtual

Asynchronously sends a bool to process with given rank.

Attention
The caller must guarantee that the lifetime of the item extends to the completion of the request!

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ aSend() [2/5]

virtual PtrRequest precice::com::Communication::aSend ( const double & itemToSend,
Rank rankReceiver )
pure virtual

Asynchronously sends a double to process with given rank.

Attention
The caller must guarantee that the lifetime of the item extends to the completion of the request!

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ aSend() [3/5]

virtual PtrRequest precice::com::Communication::aSend ( const int & itemToSend,
Rank rankReceiver )
pure virtual

Asynchronously sends an int to process with given rank.

Attention
The caller must guarantee that the lifetime of the item extends to the completion of the request!

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ aSend() [4/5]

virtual PtrRequest precice::com::Communication::aSend ( precice::span< const double > itemsToSend,
Rank rankReceiver )
pure virtual

Asynchronously sends an array of double values.

Attention
The caller must guarantee that the lifetime of the item extends to the completion of the request!

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ aSend() [5/5]

virtual PtrRequest precice::com::Communication::aSend ( precice::span< const int > itemsToSend,
Rank rankReceiver )
pure virtual

Asynchronously sends an array of integer values.

Attention
The caller must guarantee that the lifetime of the item extends to the completion of the request!

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ broadcast() [1/14]

void precice::com::Communication::broadcast ( bool & itemToReceive,
Rank rankBroadcaster )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 270 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [2/14]

void precice::com::Communication::broadcast ( bool itemToSend)
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 263 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [3/14]

void precice::com::Communication::broadcast ( double & itemToReceive,
Rank rankBroadcaster )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 257 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [4/14]

void precice::com::Communication::broadcast ( double itemToSend)
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 244 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [5/14]

void precice::com::Communication::broadcast ( int & itemToReceive,
Rank rankBroadcaster )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 218 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [6/14]

void precice::com::Communication::broadcast ( int itemToSend)
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 205 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [7/14]

void precice::com::Communication::broadcast ( precice::span< const double > itemsToSend)
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 224 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [8/14]

void precice::com::Communication::broadcast ( precice::span< const int > itemsToSend)
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 185 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [9/14]

void precice::com::Communication::broadcast ( precice::span< double > itemsToReceive,
Rank rankBroadcaster )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 237 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [10/14]

void precice::com::Communication::broadcast ( precice::span< int > itemsToReceive,
Rank rankBroadcaster )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 198 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [11/14]

void precice::com::Communication::broadcast ( std::vector< double > & v,
Rank rankBroadcaster )
virtual

Definition at line 300 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [12/14]

void precice::com::Communication::broadcast ( std::vector< double > const & v)
virtual

Definition at line 294 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [13/14]

void precice::com::Communication::broadcast ( std::vector< int > & v,
Rank rankBroadcaster )
virtual

Definition at line 284 of file Communication.cpp.

Here is the call graph for this function:

◆ broadcast() [14/14]

void precice::com::Communication::broadcast ( std::vector< int > const & v)
virtual

Definition at line 278 of file Communication.cpp.

Here is the call graph for this function:

◆ cleanupEstablishment()

virtual void precice::com::Communication::cleanupEstablishment ( std::string const & acceptorName,
std::string const & requesterName )
inlinevirtual

Clean-up environment used to establish the communication.

Parameters
[in]acceptorNameName of calling participant.
[in]requesterNameName of remote participant to connect to.

Reimplemented in precice::com::MPIPortsCommunication, precice::com::MPISinglePortsCommunication, and precice::com::SocketCommunication.

Definition at line 220 of file Communication.hpp.

◆ closeConnection()

virtual void precice::com::Communication::closeConnection ( )
pure virtual

Disconnects from communication space, i.e. participant.

This method is called on destruction.

Implemented in precice::com::MPIDirectCommunication, precice::com::MPIPortsCommunication, precice::com::MPISinglePortsCommunication, and precice::com::SocketCommunication.

◆ connectIntraComm()

void precice::com::Communication::connectIntraComm ( std::string const & participantName,
std::string const & tag,
int rank,
int size )

Establishes the intra-participant communication connection.

Parameters
[in]participantNameName of the calling participant.
[in]tagTag for establishing this connection
[in]rankThe current rank in the participant
[in]sizeTotal size of the participant

Definition at line 14 of file Communication.cpp.

Here is the call graph for this function:

◆ getRemoteCommunicatorSize()

virtual size_t precice::com::Communication::getRemoteCommunicatorSize ( )
pure virtual

Returns the number of processes in the remote communicator.

Precondition
A connection to the remote participant has been set up.

Implemented in precice::com::MPIDirectCommunication, precice::com::MPIPortsCommunication, precice::com::MPISinglePortsCommunication, and precice::com::SocketCommunication.

◆ isConnected()

virtual bool precice::com::Communication::isConnected ( )
inlinevirtual

Returns true, if a connection to a remote participant has been setup.

Definition at line 79 of file Communication.hpp.

◆ operator=()

Communication & precice::com::Communication::operator= ( Communication && )
delete

◆ prepareEstablishment()

virtual void precice::com::Communication::prepareEstablishment ( std::string const & acceptorName,
std::string const & requesterName )
inlinevirtual

Prepare environment used to establish the communication.

Parameters
[in]acceptorNameName of calling participant.
[in]requesterNameName of remote participant to connect to.

Reimplemented in precice::com::MPIPortsCommunication, precice::com::MPISinglePortsCommunication, and precice::com::SocketCommunication.

Definition at line 211 of file Communication.hpp.

◆ receive() [1/6]

virtual void precice::com::Communication::receive ( bool & itemToReceive,
Rank rankSender )
pure virtual

Receives a bool from process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ receive() [2/6]

virtual void precice::com::Communication::receive ( double & itemToReceive,
Rank rankSender )
pure virtual

Receives a double from process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ receive() [3/6]

virtual void precice::com::Communication::receive ( int & itemToReceive,
Rank rankSender )
pure virtual

Receives an int from process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ receive() [4/6]

virtual void precice::com::Communication::receive ( precice::span< double > itemsToReceive,
Rank rankSender )
pure virtual

Receives an array of double values.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ receive() [5/6]

virtual void precice::com::Communication::receive ( precice::span< int > itemsToReceive,
Rank rankSender )
pure virtual

Receives an array of integer values.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ receive() [6/6]

virtual void precice::com::Communication::receive ( std::string & itemToReceive,
Rank rankSender )
pure virtual

Receives a std::string from process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ receiveRange() [1/2]

std::vector< double > precice::com::Communication::receiveRange ( Rank rankSender,
AsVectorTag< double >  )

Receives a range of doubles as a vector<double>

Definition at line 341 of file Communication.cpp.

Here is the call graph for this function:

◆ receiveRange() [2/2]

std::vector< int > precice::com::Communication::receiveRange ( Rank rankSender,
AsVectorTag< int >  )

Receives a range of ints as a vector<int>

Definition at line 328 of file Communication.cpp.

Here is the call graph for this function:

◆ reduceSum() [1/4]

void precice::com::Communication::reduceSum ( int itemsToSend,
int & itemsToReceive )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 69 of file Communication.cpp.

Here is the call graph for this function:

◆ reduceSum() [2/4]

void precice::com::Communication::reduceSum ( int itemToSend,
int & itemToReceive,
Rank primaryRank )
virtual

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 83 of file Communication.cpp.

Here is the call graph for this function:

◆ reduceSum() [3/4]

void precice::com::Communication::reduceSum ( precice::span< double const > itemsToSend,
precice::span< double > itemsToReceive )
virtual

Performs a reduce summation on the primary rank, every other rank has to call reduceSum.

Attention
This method modifies the input buffer.

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 42 of file Communication.cpp.

Here is the call graph for this function:

◆ reduceSum() [4/4]

void precice::com::Communication::reduceSum ( precice::span< double const > itemsToSend,
precice::span< double > itemsToReceive,
Rank primaryRank )
virtual

Performs a reduce summation on the rank given by primaryRank.

Reimplemented in precice::com::MPIDirectCommunication.

Definition at line 60 of file Communication.cpp.

Here is the call graph for this function:

◆ remoteCommunicatorRanks()

auto precice::com::Communication::remoteCommunicatorRanks ( )
inline

Returns a range over all valid remote ranks.

Precondition
A connection to the remote participant has been set up.
See also
getRemoteCommunicatorSize()

Definition at line 98 of file Communication.hpp.

Here is the call graph for this function:

◆ requestConnection()

virtual void precice::com::Communication::requestConnection ( std::string const & acceptorName,
std::string const & requesterName,
std::string const & tag,
int requesterRank,
int requesterCommunicatorSize )
pure virtual

Connects to another communicator, which has to call acceptConnection().

Establishes a 1-to-N communication, whereas the requestor's side is the "N". Contrary to requestConnectionAsClient(), this side needs to be a proper communicator with ranks from 0 to N-1. All ranks need to call this function. This communication is used for the 1:1 communication between two primary ranks, and for the intra-participant communication.

Parameters
[in]acceptorNameName of remote participant to connect to.
[in]requesterNameName of calling participant.
[in]tagTag for establishing this connection
[in]requesterRankRank of the requester (has to go from 0 to N-1)
[in]requesterCommunicatorSizeSize of the requester (N)

Implemented in precice::com::MPIDirectCommunication, precice::com::MPIPortsCommunication, precice::com::MPISinglePortsCommunication, and precice::com::SocketCommunication.

◆ requestConnectionAsClient()

virtual void precice::com::Communication::requestConnectionAsClient ( std::string const & acceptorName,
std::string const & requesterName,
std::string const & tag,
std::set< int > const & acceptorRanks,
int requesterRank )
pure virtual

Connects to another communicator, which has to call acceptConnectionAsServer().

Establishes a 1-to-N communication, whereas the requestor's side is the "N". Contrary to requestConnection(), this side can have arbitrary ranks (e.g. 2,3,7). All ranks need to call this function. This communication is only used in PointToPointCommunication, i.e. for the M-to-N communication between two participants.

Parameters
[in]acceptorNameName of calling participant.
[in]requesterNameName of remote participant to connect to
[in]tagTag for establishing this connection
[in]acceptorRanksSet of ranks that accept a connection
[in]requesterRankRank that requests the connection, usually the caller's rank

Implemented in precice::com::MPIDirectCommunication, precice::com::MPIPortsCommunication, precice::com::MPISinglePortsCommunication, and precice::com::SocketCommunication.

◆ send() [1/6]

virtual void precice::com::Communication::send ( bool itemToSend,
Rank rankReceiver )
pure virtual

Sends a bool to process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ send() [2/6]

virtual void precice::com::Communication::send ( double itemToSend,
Rank rankReceiver )
pure virtual

Sends a double to process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ send() [3/6]

virtual void precice::com::Communication::send ( int itemToSend,
Rank rankReceiver )
pure virtual

Sends an int to process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ send() [4/6]

virtual void precice::com::Communication::send ( precice::span< const double > itemsToSend,
Rank rankReceiver )
pure virtual

Sends an array of double values.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ send() [5/6]

virtual void precice::com::Communication::send ( precice::span< const int > itemsToSend,
Rank rankReceiver )
pure virtual

Sends an array of integer values.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ send() [6/6]

virtual void precice::com::Communication::send ( std::string const & itemToSend,
Rank rankReceiver )
pure virtual

Sends a std::string to process with given rank.

Implemented in precice::com::MPICommunication, and precice::com::SocketCommunication.

◆ sendRange() [1/2]

void precice::com::Communication::sendRange ( precice::span< const double > itemsToSend,
Rank rankReceiver )

Sends a range of doubles (size + content)

Definition at line 310 of file Communication.cpp.

Here is the call graph for this function:

◆ sendRange() [2/2]

void precice::com::Communication::sendRange ( precice::span< const int > itemsToSend,
Rank rankReceiver )

Sends a range of ints (size + content)

Definition at line 319 of file Communication.cpp.

Here is the call graph for this function:

◆ setRankOffset()

void precice::com::Communication::setRankOffset ( Rank rankOffset)
inline

Set rank offset.

Definition at line 369 of file Communication.hpp.

Member Data Documentation

◆ _isConnected

bool precice::com::Communication::_isConnected = false
protected

Definition at line 378 of file Communication.hpp.

◆ _log

logging::Logger precice::com::Communication::_log {"com::Communication"}
private

Definition at line 384 of file Communication.hpp.

◆ _rankOffset

int precice::com::Communication::_rankOffset = 0
protected

Rank offset for primaries-secondary communication, since ranks are from 0 to size-2.

Definition at line 376 of file Communication.hpp.


The documentation for this class was generated from the following files: