The functions provide controls to communicators.
barrier(comm = .pbd_env$SPMD.CT$comm)
comm.is.null(comm = .pbd_env$SPMD.CT$comm)
comm.rank(comm = .pbd_env$SPMD.CT$comm)
comm.localrank(comm = .pbd_env$SPMD.CT$comm)
comm.size(comm = .pbd_env$SPMD.CT$comm)
comm.dup(comm, newcomm)
comm.free(comm = .pbd_env$SPMD.CT$comm)
init(set.seed = TRUE)
finalize(mpi.finalize = .pbd_env$SPMD.CT$mpi.finalize)
is.finalized()comm.abort(errorcode = 1, comm = .pbd_env$SPMD.CT$comm)
comm.split(comm = .pbd_env$SPMD.CT$comm, color = 0L, key = 0L,
newcomm = .pbd_env$SPMD.CT$newcomm)
comm.disconnect(comm = .pbd_env$SPMD.CT$comm)
comm.connect(port.name, info = .pbd_env$SPMD.CT$info,
rank.root = .pbd_env$SPMD.CT$rank.root,
comm = .pbd_env$SPMD.CT$comm,
newcomm = .pbd_env$SPMD.CT$newcomm)
comm.accept(port.name, info = .pbd_env$SPMD.CT$info,
rank.root = .pbd_env$SPMD.CT$rank.root,
comm = .pbd_env$SPMD.CT$comm,
newcomm = .pbd_env$SPMD.CT$newcomm)
port.open(info = .pbd_env$SPMD.CT$info)
port.close(port.name)
serv.publish(port.name, serv.name = .pbd_env$SPMD.CT$serv.name,
info = .pbd_env$SPMD.CT$info)
serv.unpublish(port.name, serv.name = .pbd_env$SPMD.CT$serv.name,
info = .pbd_env$SPMD.CT$info)
serv.lookup(serv.name = .pbd_env$SPMD.CT$serv.name,
info = .pbd_env$SPMD.CT$info)
intercomm.merge(intercomm = .pbd_env$SPMD.CT$intercomm,
high = 0L, comm = .pbd_env$SPMD.CT$comm)
intercomm.create(local.comm = .pbd_env$SPMD.CT$comm,
local.leader = .pbd_env$SPMD.CT$rank.source,
peer.comm = .pbd_env$SPMD.CT$intercomm,
remote.leader = .pbd_env$SPMD.CT$rank.dest,
tag = .pbd_env$SPMD.CT$tag,
newintercomm = .pbd_env$SPMD.CT$newcomm)
comm.c2f(comm = .pbd_env$SPMD.CT$comm)
Most function return an invisible state of MPI call.
a communicator number.
if MPI should be shutdown.
if a random seed preset.
a port name with default maximum length 1024 characters for OpenMPI.
a info number.
a root rank.
a new communicator number.
control of subset assignment.
control of rank assigment.
a service name.
an error code to abort MPI.
a intercommunicator number.
used to order the groups within comm.
a local communicator number.
the leader number of local communicator.
a peer communicator number.
the remote leader number of peer communicator.
a new intercommunicator number.
a tag number.
Wei-Chen Chen wccsnow@gmail.com, George Ostrouchov, Drew Schmidt, Pragneshkumar Patel, and Hao Yu.
Another functions are direct calls to MPI library.
barrier() blocks all processors until everyone call this.
comm.is.null() returns -1 if the array of communicators is not
allocated, i.e. init() is not called yet. It returns 1
if the communicator is not initialized, i.e. NULL. It
returns 0 if the communicator is initialized.
comm.rank() returns the processor's rank for the given comm.
comm.size() returns the total processes for the given comm.
comm.dup() duplicate a newcomm from comm.
comm.free() free a comm.
init() initializes a MPI world, and set two global variables
.comm.size and .comm.rank in .GlobalEnv. A random seed
will be preset by default (Sys.getpid() + Sys.time()) to the package
rlecuyer.
finalize() frees memory and finishes a MPI world if
mpi.finalize = TRUE.
is.finalized() checks if MPI is already finalized.
comm.abort() aborts MPI.
comm.split() create a newcomm by color and key.
comm.disconnect() frees a comm.
comm.connect() connects a newcomm.
comm.accept() accepts a newcomm.
port.open() opens a port and returns the port name.
port.close() closes a port by name.
serv.publish() publishs a service via port.name.
serv.unpublish() unpublishs a service via port.name.
serv.lookup() lookup the serv.name and returns the port name.
intercomm.merge() merges the intercomm to intracommunicator.
intercomm.create() creates a new intercomm from two
peer intracommunicators.
comm.c2f() returns an integer for Fortran MPI support.
Programming with Big Data in R Website: https://pbdr.org/
if (FALSE) {
### Save code in a file "demo.r" and run with 2 processors by
### SHELL> mpiexec -np 2 Rscript demo.r
spmd.code <- "
### Initialize
suppressMessages(library(pbdMPI, quietly = TRUE))
.comm.size <- comm.size()
.comm.rank <- comm.rank()
### Examples .
comm.print(.comm.size)
comm.print(.comm.rank, all.rank = TRUE)
comm.print(comm.rank(), rank.print = 1)
comm.print(comm.c2f())
### Finish.
finalize()
"
# execmpi(spmd.code, nranks = 2L)
}
Run the code above in your browser using DataLab