12.9.2. Server Routines

PreviousUpNext
Up: Establishing Communication Next: Client Routines Previous: Names, Addresses, Ports, and All Thatt

A server makes itself available with two routines. First it must call MPI_OPEN_PORT to establish a port at which it may be contacted. Secondly it must call MPI_COMM_ACCEPT to accept connections from clients.

MPI_OPEN_PORT(info, port_name)
IN infoimplementation-specific information on how to establish an address (handle)
OUT port_namenewly established port (string)
C binding
int MPI_Open_port(MPI_Info info, char *port_name)
Fortran 2008 binding
MPI_Open_port(info, port_name, ierror)

TYPE(MPI_Info), INTENT(IN) :: info
CHARACTER(LEN=MPI_MAX_PORT_NAME), INTENT(OUT) :: port_name
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_OPEN_PORT(INFO, PORT_NAME, IERROR)

INTEGER INFO, IERROR
CHARACTER*(*) PORT_NAME

This function establishes a network address, encoded in the port_name string, at which the server will be able to accept connections from clients. port_name is supplied by the system, possibly using information in the info argument.

MPI copies a system-supplied port name into port_name. port_name identifies the newly opened port and can be used by a client to contact the server. The maximum size of the string that may be supplied by the system is MPI_MAX_PORT_NAME.
Advice to users.

The system copies the port name into port_name. The application must pass a buffer of sufficient size to hold this value. ( End of advice to users.)
port_name is essentially a network address. It is unique within the communication universe to which it belongs (determined by the implementation), and may be used by any client within that communication universe. For instance, if it is an internet (host:port) address, it will be unique on the internet. If it is a low level switch address on an IBM SP, it will be unique to that SP.
Advice to implementors.

These examples are not meant to constrain implementations. A port_name could, for instance, contain a user name or the name of a batch job, as long as it is unique within some well-defined communication domain. The larger the communication domain, the more useful MPI's client/server functionality will be. ( End of advice to implementors.)
The precise form of the address is implementation-defined. For instance, an internet address may be a host name or IP address, or anything that the implementation can decode into an IP address. A port name may be reused after it is freed with MPI_CLOSE_PORT and released by the system.


Advice to implementors.

Since the user may type in port_name by hand, it is useful to choose a form that is easily readable and does not have embedded spaces. ( End of advice to implementors.)
info may be used to tell the implementation how to establish the address. It may, and usually will, be MPI_INFO_NULL in order to get the implementation defaults.

MPI_CLOSE_PORT(port_name)
IN port_namea port (string)
C binding
int MPI_Close_port(const char *port_name)
Fortran 2008 binding
MPI_Close_port(port_name, ierror)

CHARACTER(LEN=*), INTENT(IN) :: port_name
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_CLOSE_PORT(PORT_NAME, IERROR)

CHARACTER*(*) PORT_NAME
INTEGER IERROR

This function releases the network address represented by port_name.

MPI_COMM_ACCEPT(port_name, info, root, comm, newcomm)
IN port_nameport name (string, significant only at root)
IN infoimplementation-dependent information (handle, significant only at root)
IN rootrank of root in comm (integer)
IN commintra-communicator over which call is collective (handle)
OUT newcomminter-communicator with client as remote group (handle)
C binding
int MPI_Comm_accept(const char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm)
Fortran 2008 binding
MPI_Comm_accept(port_name, info, root, comm, newcomm, ierror)

CHARACTER(LEN=*), INTENT(IN) :: port_name
TYPE(MPI_Info), INTENT(IN) :: info
INTEGER, INTENT(IN) :: root
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Comm), INTENT(OUT) :: newcomm
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_COMM_ACCEPT(PORT_NAME, INFO, ROOT, COMM, NEWCOMM, IERROR)

CHARACTER*(*) PORT_NAME
INTEGER INFO, ROOT, COMM, NEWCOMM, IERROR

MPI_COMM_ACCEPT establishes communication with a client. It is collective over the calling communicator. It returns an inter-communicator that allows communication with the client.

The port_name must have been established through a call to MPI_OPEN_PORT.

info can be used to provide directives that may influence the behavior of the ACCEPT call.


PreviousUpNext
Up: Establishing Communication Next: Client Routines Previous: Names, Addresses, Ports, and All Thatt


Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023