23 : _addressDirectory(
std::move(addressDirectory))
42 MPI_Comm_remote_size(
_global, &size);
65 res = MPI_Open_port(MPI_INFO_NULL, sm.
data());
83 int requesterRank = -1;
84 MPI_Recv(&requesterRank, 1, MPI_INT, 0, 42,
communicator, MPI_STATUS_IGNORE);
85 int requesterCommunicatorSize = -1;
86 MPI_Recv(&requesterCommunicatorSize, 1, MPI_INT, 0, 42,
communicator, MPI_STATUS_IGNORE);
87 MPI_Send(&acceptorRank, 1, MPI_INT, 0, 42,
communicator);
90 if (peerCurrent == 0) {
91 peerCount = requesterCommunicatorSize;
95 "Requester communicator size is {} which is invalid.", requesterCommunicatorSize);
97 "Current requester size from rank {} is {} but should be {}", requesterRank, requesterCommunicatorSize, peerCount);
99 "Rank {} has already been connected. Duplicate requests are not allowed.", requesterRank);
104 }
while (++peerCurrent < peerCount);
115 int requesterCommunicatorSize)
117 PRECICE_TRACE(acceptorName, requesterName, acceptorRank, requesterCommunicatorSize);
129 res = MPI_Open_port(MPI_INFO_NULL, sm.
data());
155 int requesterCommunicatorSize)
171 MPI_Send(&requesterRank, 1, MPI_INT, 0, 42,
communicator);
173 MPI_Send(&requesterCommunicatorSize, 1, MPI_INT, 0, 42,
communicator);
175 int acceptorRank = -1;
176 MPI_Recv(&acceptorRank, 1, MPI_INT, 0, 42,
communicator, MPI_STATUS_IGNORE);
217 res = MPI_Comm_disconnect(&kv.second);
221 if (
_global != MPI_COMM_NULL) {
222 res = MPI_Comm_disconnect(&
_global);
241 if (
_global != MPI_COMM_NULL) {
252 if (
_global != MPI_COMM_NULL) {
269 create_directories(dir);
271 PRECICE_WARN(
"Creating directory for connection info failed with: {}", e.
what());
#define PRECICE_WARN_IF(condition,...)
#define PRECICE_WARN(...)
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#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.
Reads the connection info for the given participant/rank information.
std::string read() const
Reads the info from the connection info file. Will block, if the the file is not present.
Writes the connection info for the given participant/rank information.
void write(std::string_view info) const
Write the string info, e.g. IP:port to the connection info file.
virtual void prepareEstablishment(std::string const &acceptorName, std::string const &requesterName) override
Prepare environment used to establish the communication.
std::string _addressDirectory
virtual void requestConnection(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, int requesterRank, int requesterCommunicatorSize) override
Connects to another communicator, which has to call acceptConnection().
MPI_Comm _global
The global inter-communicator that connects all ranks.
virtual Rank rank(int rank) override
virtual void requestConnectionAsClient(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, std::set< int > const &acceptorRanks, int requesterRank) override
Connects to another communicator, which has to call acceptConnectionAsServer().
virtual MPI_Comm & communicator(Rank rank) override
Returns the communicator.
virtual ~MPISinglePortsCommunication()
std::string _portName
Name of the port used for connection.
virtual size_t getRemoteCommunicatorSize() override
Returns the number of processes in the remote communicator.
int _initialCommSize
The communicator size known from acceptConnection and requestConnection.
virtual void closeConnection() override
Disconnects from communication space, i.e. participant.
virtual void acceptConnectionAsServer(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, int acceptorRank, int requesterCommunicatorSize) override
requesterCommunicatorSize is not used, since connection is always made on the entire communicator
std::map< int, MPI_Comm > _direct
A map of direct communication channels based on MPI_COMM_SELF on both sides.
virtual void acceptConnection(std::string const &acceptorName, std::string const &requesterName, std::string const &tag, int acceptorRank, int rankOffset=0) override
Accepts connection from another communicator, which has to call requestConnection().
virtual void cleanupEstablishment(std::string const &acceptorName, std::string const &requesterName) override
Clean-up environment used to establish the communication.
MPISinglePortsCommunication(std::string addressDirectory=".")
static Rank getRank()
Current rank.
static CommStatePtr current()
Returns an owning pointer to the current CommState.
Utility class to build a string from C functions with output pointers and static maximum length.
T generic_string(T... args)
std::string localDirectory(std::string_view acceptorName, std::string_view requesterName, std::string_view addressDirectory)
contains the data communication abstraction layer.
std::string message() const