Learn R Programming

pbdMPI (version 0.2-3)

communicator: Communicator Functions

Description

The functions provide controls to communicators.

Usage

barrier(comm = .SPMD.CT$comm)
  comm.is.null(comm = .SPMD.CT$comm)
  comm.rank(comm = .SPMD.CT$comm)
  comm.size(comm = .SPMD.CT$comm)
  comm.dup(comm, newcomm)
  comm.free(comm = .SPMD.CT$comm)
  init(set.seed = TRUE)
  finalize(mpi.finalize = .SPMD.CT$mpi.finalize)

comm.abort(errorcode = 1, comm = .SPMD.CT$comm) comm.split(comm = .SPMD.CT$comm, color = 0L, key = 0L, newcomm = .SPMD.CT$newcomm) comm.disconnect(comm = .SPMD.CT$comm) comm.connect(port.name, info = .SPMD.CT$info, rank.root = .SPMD.CT$rank.root, comm = .SPMD.CT$comm, newcomm = .SPMD.CT$newcomm) comm.accept(port.name, info = .SPMD.CT$info, rank.root = .SPMD.CT$rank.root, comm = .SPMD.CT$comm, newcomm = .SPMD.CT$newcomm)

port.open(info = .SPMD.CT$info) port.close(port.name) serv.publish(port.name, serv.name = .SPMD.CT$serv.name, info = .SPMD.CT$info) serv.unpublish(port.name, serv.name = .SPMD.CT$serv.name, info = .SPMD.CT$info) serv.lookup(serv.name = .SPMD.CT$serv.name, info = .SPMD.CT$info)

intercomm.merge(intercomm = .SPMD.CT$intercomm, high = 0L, comm = .SPMD.CT$comm) intercomm.create(local.comm = .SPMD.CT$comm, local.leader = .SPMD.CT$rank.source, peer.comm = .SPMD.CT$intercomm, remote.leader = .SPMD.CT$rank.dest, tag = .SPMD.CT$tag, newintercomm = .SPMD.CT$newcomm)

comm.c2f(comm = .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.

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
### Save code in a file "demo.r" and run with 2 processors by
### SHELL> mpiexec -np 2 Rscript demo.r

### Initial.
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()

Run the code above in your browser using DataLab