pbdMPI (version 0.3-9)

communicator: Communicator Functions

Description

The functions provide controls to communicators.

Usage

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)

Arguments

comm

a communicator number.

mpi.finalize

if MPI should be shutdown.

set.seed

if a random seed preset.

port.name

a port name with default maximum length 1024 characters for OpenMPI.

info

a info number.

rank.root

a root rank.

newcomm

a new communicator number.

color

control of subset assignment.

key

control of rank assigment.

serv.name

a service name.

errorcode

an error code to abort MPI.

intercomm

a intercommunicator number.

high

used to order the groups within comm.

local.comm

a local communicator number.

local.leader

the leader number of local communicator.

peer.comm

a peer communicator number.

remote.leader

the remote leader number of peer communicator.

newintercomm

a new intercommunicator number.

tag

a tag number.

Value

Most function return an invisible state of MPI call.

Details

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.

References

Programming with Big Data in R Website: http://r-pbd.org/

Examples

Run this code
# NOT RUN {
### Save code in a file "demo.r" and run with 2 processors by
### SHELL> mpiexec -np 2 Rscript demo.r

spmd.code <- "
### Initial.
suppressMessages(library(pbdMPI, quietly = TRUE))
init()
.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