Rhpc-package: permits *apply() style dispatch for HPC

Description Usage Arguments Details Author(s) Examples

Description

Rhpc_lapply, Rhpc_lapplyLB and Rhpc_worker_call using MPI provides better HPC environment on R(works fast on HPC). and this package supports long vector, can deal with slightly big data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Rhpc_initialize()
Rhpc_finalize()
Rhpc_getHandle(procs)
Rhpc_worker_call(cl, FUN, ..., usequote)
Rhpc_worker_noback(cl, FUN, ..., usequote)
Rhpc_lapply(cl, X, FUN, ...,usequote)
Rhpc_lapplyLB(cl, X, FUN, ..., usequote)
Rhpc_sapply(cl, X, FUN, ..., usequote, simplify, USE.NAMES)
Rhpc_sapplyLB(cl, X, FUN, ..., usequote, simplify, USE.NAMES)
Rhpc_apply(cl, X, MARGIN, FUN, ..., usequote)
Rhpc_numberOfWorker(cl)
Rhpc_Export(cl, variableNames, usequote, pos, envir)
Rhpc_EvalQ(cl, expr, usequote, envir)
Rhpc_setupRNG(cl, iseed)

Arguments

cl

external pointer to MPI communicator

procs

Specify the number of processes when performing dynamic process generation (use the MPI_Comm_spawn), only static generate if blank

X

vector or list. Divided into smaller vectors according to the number of workers, and distributed to workers when the function is first executed. One-sided communication is used asynchronously

FUN

string of function name or function object. Function name or string (string expresses function name) Distributed by collective communication at first, then they are not sent again

MARGIN

a vector giving the subscripts which the function will be applied over. E.g., for a matrix 1 indicates rows, 2 indicates columns, c(1, 2) indicates rows and columns. Where X has named dimnames, it can be a character vector selecting dimension names.

simplify

logical or character string; should the result be simplified to a vector, matrix or higher dimensional array if possible? For sapply it must be named and not abbreviated. The default value, TRUE, returns a vector or matrix if appropriate, whereas if simplify = "array" the result may be an array of “rank” (=length(dim(.))) one higher than the result of FUN(X[[i]]).

USE.NAMES

logical; if TRUE and if X is character, use X as names for the result unless it had names already. Since this argument follows ... its name cannot be abbreviated.

...

arguments. Distributed by collective communication at first, then they are not sent again

usequote

user can choose usequpte=FALSE for performance improvement

variableNames

string vector

iseed

random number seed

expr

expression to evaluate

pos

default is current environment position

envir

where to look for the object

Details

Rhpc batch wrapper in package directory if you use mpirun.

This package sets "Rhpc.mpi.c.comm","Rhpc.mpi.f.comm", "Rhpc.mpi.rank" and "Rhpc.mpi.procs" can get attribute of MPI in getOption().

https://prs.ism.ac.jp/~nakama/Rhpc/

Author(s)

Junji NAKANO <nakanoj@ism.ac.jp> and Ei-ji Nakama<nakama@com-one.com>

Maintainer: Ei-ji Nakama <nakama@com-one.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
# use Rhpc command
Rhpc_initialize()

# If you start the process dynamically on Windows, the dos window of
# mpiexec will be created, but you should not close this window.
cl <- Rhpc_getHandle(5) # ommit number of worker if use Rhpc batch

# Rhpc set to options
opstr=list("Rhpc.mpi.rank","Rhpc.mpi.procs","Rhpc.mpi.c.comm","Rhpc.mpi.f.comm")
do.call("options",opstr)
Rhpc_worker_call(cl, "do.call","options", opstr)
# warning! : pointer not export, worker Rhpc.mpi.c.comm is (nil) on master.

Rhpc_worker_call(cl, Sys.getpid)
Rhpc_lapply(cl,1:10000,sqrt)
Rhpc_lapplyLB(cl,1:10000,sqrt)
Rhpc_sapply(cl,1:10000,sqrt)
Rhpc_sapplyLB(cl,1:10000,sqrt)

df<-data.frame(a=1:4,b=5:8)
Rhpc_apply(cl,df,1,max)
Rhpc_apply(cl,df,2,max)

Rhpc_finalize()
#
# command line example
#
# mpirun -n 4 Rhpc CMD BATCH --no-save `script file for exemplified above'
#

## End(Not run)

Rhpc documentation built on Sept. 5, 2021, 5:47 p.m.