pbdMPI (version 0.3-9)

pbdMPI-package: Programming with Big Data -- Interface to MPI

Description

pbdMPI provides an efficient interface to MPI by utilizing S4 classes and methods with a focus on Single Program/Multiple Data (SPMD) parallel programming style, which is intended for batch parallel execution.

Arguments

Details

Package: pbdMPI
Type: Package
License: Mozilla Public License 2.0
LazyLoad: yes

This package requires an MPI library (OpenMPI, MPICH2, or LAM/MPI). The install command (with OpenMPI library) is

> tar zxvf pbdMPI_0.1-0.tar.gz > R CMD INSTALL pbdMPI

Other arguments include

Argument Default
--with-mpi-type OPENMPI
--with-mpi-include ${MPI_ROOT}/include
--with-mpi-libpath ${MPI_ROOT}/lib
--with-mpi ${MPI_ROOT}

where ${MPI_ROOT} is the path to the MPI root. See the package source file pbdMPI/configure for details.

After loading library(pbdMPI), the standard process starts from init() which set two global variables .comm.size and .comm.rank. The standard process should end with finalize().

Most functions are assumed to run in SPMD, i.e. in batch mode. Ideally, most codes run with mpiexec and Rscript, together, such as > mpiexec -np 2 Rscript some_code.r where some_code.r contains whole SPMD program.

The package source files provide several examples based on pbdMPI, such as

Directory Examples
pbdMPI/inst/examples/test_spmd/ major SPMD functions
pbdMPI/inst/examples/test_rmpi/ analog to Rmpi
pbdMPI/inst/examples/test_parallel/ analog to parallel
pbdMPI/inst/examples/test_performance/ performance tests
pbdMPI/inst/examples/test_s4/ S4 extension
pbdMPI/inst/examples/test_cs/ client/server examples
pbdMPI/inst/examples/test_long_vector/ long vector examples

where test_long_vector needs to recompile with setting

#define MPI_LONG_DEBUG 1

in pbdMPI/src/pkg_constant.h.

The current version is mainly written and tested under OpenMPI environments in Linux system (xubuntu-11.04). Also, it is tested under MPICH2 environments in Windows 7 system. It is expected to be fine for other MPI libraries and other OS platforms.

References

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

See Also

allgather(), allreduce(), bcast(), gather(), reduce(), scatter().

Examples

Run this code
# NOT RUN {
### Under command mode, run the demo with 2 processors by
### (Use Rscript.exe for windows system)
# mpiexec -np 2 Rscript -e "demo(allgather,'pbdMPI',ask=F,echo=F)"
# mpiexec -np 2 Rscript -e "demo(allreduce,'pbdMPI',ask=F,echo=F)"
# mpiexec -np 2 Rscript -e "demo(bcast,'pbdMPI',ask=F,echo=F)"
# mpiexec -np 2 Rscript -e "demo(gather,'pbdMPI',ask=F,echo=F)"
# mpiexec -np 2 Rscript -e "demo(reduce,'pbdMPI',ask=F,echo=F)"
# mpiexec -np 2 Rscript -e "demo(scatter,'pbdMPI',ask=F,echo=F)"
### Or
# execmpi("demo(allgather,'pbdMPI',ask=F,echo=F)", nranks = 2L)
# execmpi("demo(allreduce,'pbdMPI',ask=F,echo=F)", nranks = 2L)
# execmpi("demo(bcast,'pbdMPI',ask=F,echo=F)", nranks = 2L)
# execmpi("demo(gather,'pbdMPI',ask=F,echo=F)", nranks = 2L)
# execmpi("demo(reduce,'pbdMPI',ask=F,echo=F)", nranks = 2L)
# execmpi("demo(scatter,'pbdMPI',ask=F,echo=F)", nranks = 2L)
# }

Run the code above in your browser using DataCamp Workspace