Programming with Big Data in R


Programming with Big Data in R is a series of R packages and an environment for statistical computing with big data by using high-performance statistical computation. The pbdR uses the same programming language as R with S3/S4 classes and methods which is used among statisticians and data miners for developing statistical software. The significant difference between pbdR and R code is that pbdR mainly focuses on distributed memory systems, where data are distributed across several processors and analyzed in a batch mode, while communications between processors are based on MPI that is easily used in large high-performance computing systems. R system mainly focuses on single multi-core machines for data analysis via an interactive mode such as GUI interface.
Two main implementations in R using MPI are Rmpi and pbdMPI of pbdR.
The idea of SPMD parallelism is to let every processor do the same amount of work, but on different parts of a large data set. For example, a modern GPU is a large collection of slower co-processors that can simply apply the same computation on different parts of relatively smaller data, but the SPMD parallelism ends up with an efficient way to obtain final solutions.

Package design

Programming with pbdR requires usage of various packages developed by pbdR core team. Packages developed are the following.
GeneralI/OComputationApplicationProfilingClient/Server
pbdDEMOpbdNCDF4pbdDMATpmclustpbdPROFpbdZMQ
pbdMPIpbdADIOSpbdBASEpbdMLpbdPAPIremoter
pbdSLAPhpcvispbdCS
kazaampbdRPC

Among these packages, pbdMPI provides wrapper functions to MPI library, and it also produces a shared library and a configuration file for MPI environments. All other packages rely on this configuration for installation and library loading that avoids difficulty of library linking and compiling. All other packages can directly use MPI functions easily.
Among those packages, the pbdDEMO package is a collection of 20+ package demos which offer example uses of the various pbdR packages, and contains a vignette that offers detailed explanations for the demos and provides some mathematical or statistical insight.

Examples

Example 1

Hello World! Save the following code in a file called "demo.r"

  1. ## Initial MPI
library
init
comm.cat
  1. ## Finish
finalize

and use the command

mpiexec -np 2 Rscript demo.r

to execute the code where Rscript is one of command line executable program.

Example 2

The following example modified from pbdMPI illustrates the basic syntax of the language of pbdR.
Since pbdR is designed in SPMD, all the R scripts are stored in files and executed from the command line via mpiexec, mpirun, etc. Save the following code in a file called "demo.r"

  1. ## Initial MPI
library
init
.comm.size <- comm.size
.comm.rank <- comm.rank
  1. ## Set a vector x on all processors with different values
N <- 5
x <- + N *.comm.rank
  1. ## All reduce x using summation operation
y <- allreduce
comm.print
y <- allreduce
comm.print
  1. ## Finish
finalize

and use the command

mpiexec -np 4 Rscript demo.r

to execute the code where Rscript is one of command line executable program.

Example 3

The following example modified from pbdDEMO illustrates the basic ddmatrix computation of pbdR which performs singular value decomposition on a given matrix.
Save the following code in a file called "demo.r"

  1. Initialize process grid
library
if
comm.stop
init.grid
  1. Setup for the remainder
comm.set.seed
M <- N <- 16
BL <- 2 # blocking --- passing single value BL assumes BLxBL blocking
dA <- ddmatrix
  1. LA SVD
svd1 <- La.svd
comm.print
  1. Finish
finalize

and use the command

mpiexec -np 2 Rscript demo.r

to execute the code where Rscript is one of command line executable program.