inst/examples/test_cs/named.server.r

### See ``http://www.mpi-forum.org/docs/mpi-20-html/node106.htm'' for details.

### Initialize MPI.
suppressMessages(library(pbdMPI, quietly = TRUE))
.pbd_env$SPMD.CT$check.type <- FALSE
if(comm.size() != 1){
  stop("Server too big.")
}
client.comm <- .pbd_env$SPMD.CT$newcomm

### Connection start.
port.name <- port.open()
serv.publish(port.name)
comm.accept(port.name, newcomm = client.comm)

### Communicate 1.
buffer <- as.integer(rep(0, 5))
ret <- spmd.recv.integer(buffer, rank.source = NULL, tag = NULL,
                         comm = client.comm)
print(get.sourcetag())
print(ret)

### Communicate 2.
ret <- spmd.allgather.integer(buffer, rep(buffer, 2), comm = client.comm)
print(ret)

### Connection stop.
comm.disconnect(comm = client.comm)
serv.unpublish(port.name)
port.close(port.name)

### Finish.
finalize()

Try the pbdMPI package in your browser

Any scripts or data that you put into this service are public.

pbdMPI documentation built on Sept. 10, 2023, 5:06 p.m.