15 : _commState(utils::Parallel::current())
43 PRECICE_ASSERT(rankOffset == 1,
"MPIDirectCommunication only supports IntraComm Communications!");
49 PRECICE_ASSERT(acceptorRank == 0,
"The Acceptor/Primary rank has to be rank 0!");
67 int requesterCommunicatorSize)
149 MPI_Bcast(
const_cast<int *
>(itemsToSend.
data()), itemsToSend.
size(), MPI_INT, 0,
_commState->comm);
155 MPI_Bcast(itemsToReceive.
data(), itemsToReceive.
size(), MPI_INT, rankBroadcaster,
_commState->comm);
161 broadcast(precice::refToSpan<const int>(itemToSend));
167 broadcast(precice::refToSpan<int>(itemToReceive), rankBroadcaster);
173 MPI_Bcast(
const_cast<double *
>(itemsToSend.
data()), itemsToSend.
size(), MPI_DOUBLE, 0,
_commState->comm);
179 MPI_Bcast(itemsToReceive.
data(), itemsToReceive.
size(), MPI_DOUBLE, rankBroadcaster,
_commState->comm);
185 broadcast(precice::refToSpan<const double>(itemToSend));
191 broadcast(precice::refToSpan<double>(itemToReceive), rankBroadcaster);
197 int item = itemToSend;
206 itemToReceive = item;
#define PRECICE_TRACE(...)
int MPI_Reduce(const T *sendbuf, T *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
int MPI_Allreduce(const T *sendbuf, T *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
#define PRECICE_ASSERT(...)
void setRankOffset(Rank rankOffset)
Set rank offset.
virtual bool isConnected()
Returns true, if a connection to a remote participant has been setup.
virtual Rank rank(int rank) override
virtual void acceptConnection(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, int acceptorRank, int rankOffset=0) override
virtual void requestConnection(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, int requesterRank, int requesterCommunicatorSize) override
virtual size_t getRemoteCommunicatorSize() override
Returns the number of processes in the remote communicator.
virtual void broadcast(precice::span< const int > itemsToSend) override
virtual int adjustRank(Rank rank) const override
Turn the rank adjustment into a noop for direct communication.
utils::Parallel::CommStatePtr _commState
CommState to use.
virtual void closeConnection() override
See precice::com::Communication::closeConnection().
virtual ~MPIDirectCommunication()
virtual void allreduceSum(precice::span< double const > itemsToSend, precice::span< double > itemsToReceive, Rank primaryRank) override
virtual MPI_Comm & communicator(Rank rank=0) override
Returns the communicator.
virtual void reduceSum(precice::span< double const > itemsToSend, precice::span< double > itemsToReceive, Rank primaryRank) override
Performs a reduce summation on the rank given by primaryRank.
A C++ 11 implementation of the non-owning C++20 std::span type.
constexpr pointer data() const noexcept
constexpr size_type size() const noexcept
static CommStatePtr current()
Returns an owning pointer to the current CommState.
contains the data communication abstraction layer.