SlideShare une entreprise Scribd logo
1  sur  53
Télécharger pour lire hors ligne
Parallel R
Andrew Bzikadze
seryrzu@gmail.com
Saint Petersburg State University, Russia
Faculty of Mathematics and Mechanics
Department of Statistical Modelling
September 12, 2015
Andrew Bzikadze Parallel R 1 / 39
Outline
1 Motivation and introduction
2 snow
3 multicore
4 parallel
5 What else and references
Andrew Bzikadze Parallel R 2 / 39
Motivation
Why R? The R language has a lot of
advantages:
• Open Source.
• Cross-Platform.
• Free.
• Many basic tools.
• R extensions.
• Arguably fast with R-way style and
well-implemented R distribution.
Andrew Bzikadze Parallel R 3 / 39
Motivation
Why R? The R language has a lot of
advantages:
• Open Source.
• Cross-Platform.
• Free.
• Many basic tools.
• R extensions.
• Arguably fast with R-way style and
well-implemented R distribution.
Why bother then?
Andrew Bzikadze Parallel R 3 / 39
Motivation
Why R? The R language has a lot of
advantages:
• Open Source.
• Cross-Platform.
• Free.
• Many basic tools.
• R extensions.
• Arguably fast with R-way style and
well-implemented R distribution.
Why bother then?
There are 2 major limitations:
• Single-threaded: no out-of-box
support of multi-thread calculations.
• Memory-bound: all data should fit in
RAM.
Andrew Bzikadze Parallel R 3 / 39
Motivation
Why R? The R language has a lot of
advantages:
• Open Source.
• Cross-Platform.
• Free.
• Many basic tools.
• R extensions.
• Arguably fast with R-way style and
well-implemented R distribution.
Why bother then?
There are 2 major limitations:
• Single-threaded: no out-of-box
support of multi-thread calculations.
• Memory-bound: all data should fit in
RAM.
Solution: Parallel Execution. How
exactly?
• Single-threaded: multiple CPU’s
(and cores).
• Memory-bound: spread data from
one computer (master) to several
computers (slaves).
Andrew Bzikadze Parallel R 3 / 39
Basic Terminology
The two types of parallelism:
• Implicit — the OS abstracts parallelism from the user.
• Explicit — user controls details of the process.
A computer cluster consists of a set of loosely or tightly connected computers that
work together so that, in many respects, they can be viewed as a single system (Wiki).
Master/slave is a model of communication where one device or process has
unidirectional control over one or more other devices (Wiki).
Andrew Bzikadze Parallel R 4 / 39
Overview
snow
Usage:
Explicit parallelism by using
clusters (works on Linux,
Windows, Mac OS X).
Solves: Single-threaded, memory-bound.
multicore [deprecated]
Usage:
Implicit parallelism by using
FORK (doesn’t work on
Windows).
Solves: Single-threaded.
Andrew Bzikadze Parallel R 5 / 39
Overview
snow
Usage:
Explicit parallelism by using
clusters (works on Linux,
Windows, Mac OS X).
Solves: Single-threaded, memory-bound.
multicore [deprecated]
Usage:
Implicit parallelism by using
FORK (doesn’t work on
Windows).
Solves: Single-threaded.
parallel [mainstream]
Usage:
Almost a wrapper of snow and
multicore.
Solves: Single-threaded, memory-bound.
Andrew Bzikadze Parallel R 5 / 39
Overview
snow
Usage:
Explicit parallelism by using
clusters (works on Linux,
Windows, Mac OS X).
Solves: Single-threaded, memory-bound.
multicore [deprecated]
Usage:
Implicit parallelism by using
FORK (doesn’t work on
Windows).
Solves: Single-threaded.
parallel [mainstream]
Usage:
Almost a wrapper of snow and
multicore.
Solves: Single-threaded, memory-bound.
Hadoop
R + Hadoop, RHIPE, Segue.
Andrew Bzikadze Parallel R 5 / 39
Epigraph
“. . . R was not built in anticipation of the Big Data revolution.
R was born in 1995. Disk space was expensive, RAM even more so, and this
thing called The Internet was just getting its legs. Notions of “large-scale
data analysis” and “high-performance computing” were reasonably rare.
Outside of Wall Street firms and university research labs, there just wasn‘t
that much data to crunch.”
— Q. Ethan McCallum and Stephen Weston “Parallel R”
Andrew Bzikadze Parallel R 6 / 39
Outline
1 Motivation and introduction
2 snow
3 multicore
4 parallel
5 What else and references
Andrew Bzikadze Parallel R 7 / 39
Outline
1 Motivation and introduction
2 snow
3 multicore
4 parallel
5 What else and references
Andrew Bzikadze Parallel R 8 / 39
snow: quick look
General use case: Main word is cluster, provides explicit parallelism.
Examples:
Monte Carlo simulations, bootstrapping, cross validation,
ensemble machine learning algorithms.
Solves: Single-threaded, memory-bound.
Cool features:
• Different transport mechanisms between Master and
Slaves: Sockets, MPI (rmpi), NWS (nws), PVM (rpvm).
• Good support of RNG (rsprng, rlecuyer).
Problems: No communication between the workers (slaves).
Andrew Bzikadze Parallel R 9 / 39
snow: quick look
General use case: Main word is cluster, provides explicit parallelism.
Examples:
Monte Carlo simulations, bootstrapping, cross validation,
ensemble machine learning algorithms.
Solves: Single-threaded, memory-bound.
Cool features:
• Different transport mechanisms between Master and
Slaves: Sockets, MPI (rmpi), NWS (nws), PVM (rpvm).
• Good support of RNG (rsprng, rlecuyer).
Problems: No communication between the workers (slaves).
Warning:
The input arguments must fit into memory when calling
snow function. Its up to the user to arrange high-performance
distributed file systems.
Andrew Bzikadze Parallel R 9 / 39
Structure of API
Start and stop clusters: makeCluster, stopCluster.
Low-level (cluster-level) functions:
cluster* — clusterApply, clusterApplyLB,
clusterEvalQ, clusterCall, clusterSplit, etc.
High-level functions:
par[L,S,A,R,C]apply — parallel versions of
apply and related functions.
(Uniform) RNG:
L‘Ecuyer (package: rlecuyer),
SPRNG [deprecated] (package: rsprng).
Timing: snow.time(expr) — very useful.
Andrew Bzikadze Parallel R 10 / 39
Start and stop clusters
Basic way:
cl <- makeCluster(8, type = "SOCK") # or you may use
# makeSOCKcluster(),
# makePVMcluster(), etc.
stopCluster(cl)
First parameter is spec — specification. It is ssh-configurable unless you type
"localhost":
cl <- makeCluster(c("localhost","localhost"), type = "SOCK")
stopCluster(cl)
Warning: Be aware of computational costs of cluster setup.
Andrew Bzikadze Parallel R 11 / 39
Low-level API
All of them are cluster* and designed for computing on a cluster. Most interesting
are as follows.
clusterApply(cl, x, fun, ...) Jobs are being “recycled”.
clusterApplyLB(cl, x, fun, ...) Load Balancing version of clusterApply().
clusterCall(cl, fun, ...)
Calls a function fun with identical
arguments . . . on each node in the cluster cl
and returns a list of the results.
clusterEvalQ(cl, expr)
Evaluates an expression expr on each node
in the cluster cl;
implemented using clusterCall().
clusterMap(cl, fun, ...,
MoreArgs = NULL, RECYCLE = TRUE)
Similar to mapply.
Andrew Bzikadze Parallel R 12 / 39
Example, K-means
Basic one-core way:
library(MASS)
result <- kmeans(Boston, 4,
nstart=100)
Andrew Bzikadze Parallel R 13 / 39
Example, K-means
Basic one-core way:
library(MASS)
result <- kmeans(Boston, 4,
nstart=100)
Before using snow it is easier to think
*apply-way:
results <- lapply(rep(25, 4),
function(nstart)
kmeans(Boston, 4, nstart=nstart)
)
i <- sapply(results,
function(result)
result$tot.withinss
)
result <- results[[which.min(i)]]
Andrew Bzikadze Parallel R 13 / 39
Example, K-means
Basic one-core way:
library(MASS)
result <- kmeans(Boston, 4,
nstart=100)
Before using snow it is easier to think
*apply-way:
results <- lapply(rep(25, 4),
function(nstart)
kmeans(Boston, 4, nstart=nstart)
)
i <- sapply(results,
function(result)
result$tot.withinss
)
result <- results[[which.min(i)]]
Finally snow version.
ignore <-
clusterEvalQ(cl, {library(MASS); NULL})
results <-
clusterApply(cl, rep(25, 4),
function(nstart)
kmeans(Boston, 4, nstart=nstart)
)
i <- sapply(results,
function(result)
result$tot.withinss
)
result <- results[[which.min(i)]]
Andrew Bzikadze Parallel R 13 / 39
Load Balancing
clusterApply() uses a robin-round fashion for scheduling tasks for clusters. It means
one time for every cluster. It could be not very wise to do that.
set.seed(123)
sleeptime <- abs(rnorm(10, 10, 10))
tm <- snow.time(clusterApply(cl, sleeptime, Sys.sleep))
Andrew Bzikadze Parallel R 14 / 39
Load Balancing
0 10 20 30 40 50 60
Elapsed Time
Node
01234
Cluster Usage
Andrew Bzikadze Parallel R 15 / 39
Load Balancing
So we waited for more than 50 seconds. A more efficient way would be pull the tasks
to clusters when they are needed. This technique is called “load balancing”. Function
clusterApplyLB() uses that technique.
set.seed(123)
sleeptime <- abs(rnorm(10, 10, 10))
tm <- snow.time(clusterApplyLB(cl, sleeptime, Sys.sleep))
Andrew Bzikadze Parallel R 16 / 39
Load Balancing
0 5 10 15 20 25 30 35
Elapsed Time
Node
01234
Cluster Usage
Andrew Bzikadze Parallel R 17 / 39
Load Balancing
So, here we waited for about 30 seconds. This is an improvement. The only wasted
time was at the end.
Andrew Bzikadze Parallel R 18 / 39
High-level API
parLapply(cl, x, fun, ...) Parallel version of lapply().
parSapply(cl, X, FUN, ...,
simplify = TRUE, USE.NAMES = TRUE)
Parallel version of sapply().
parApply(cl, X, MARGIN, FUN, ...) Parallel version of apply().
parRapply(cl, x, fun, ...) Row apply() for matrix.
parCapply(cl, x, fun, ...) Column apply() for matrix.
The most useful is parLapply() function. It is different from clusterApply()
because it splits the task into “equal” tasks.
parLapply
## function (cl, x, fun, ...)
## docall(c, clusterApply(cl, splitList(x, length(cl)), lapply,
## fun, ...))
## <environment: namespace:snow>
where splitList() is an internal snow function.
Andrew Bzikadze Parallel R 19 / 39
Example of comparison clusterApply() and parLapply()
parLapply() could be more efficient if you have more tasks than workers. Another
situation — you send large arguments to parLapply(). Let’s take a look at the
example.
bigsleep <- function(sleeptime, mat) Sys.sleep(sleeptime)
bigmatrix <- matrix(0, 2000, 2000)
sleeptime <- rep(1, 100)
Firstly, let’s try clusterApply().
Andrew Bzikadze Parallel R 20 / 39
Example of comparison clusterApply() and parLapply()
0 5 10 15 20 25 30
Elapsed Time
Node
01234
Cluster Usage
Andrew Bzikadze Parallel R 21 / 39
Example of comparison clusterApply() and parLapply()
Definitely not highly efficient. Those gaps are due to I/O time. Ideally we should have
25 seconds... Let’s give parLapply() a try.
Andrew Bzikadze Parallel R 22 / 39
Example of comparison clusterApply() and parLapply()
0 5 10 15 20 25
Elapsed Time
Node
01234
Cluster Usage
Andrew Bzikadze Parallel R 23 / 39
Load Balancing parLapply?
Andrew Bzikadze Parallel R 24 / 39
Load Balancing parLapply?
Short answer: no, there is no such a function in snow package.
Good news: it is possible to write your own.
Andrew Bzikadze Parallel R 24 / 39
Random Number Generation
There are 2 basic steps.
1 Configure your cluster workers to use a generator.
library(rlecuyer)
clusterSetupRNG(cl, type = 'RNGstream')
## [1] "RNGstream"
2 Be happy to generate your numbers.
unlist(clusterCall(cl, runif, 1))
## [1] 0.12701112 0.75958186 0.72850979 0.09570262
Andrew Bzikadze Parallel R 25 / 39
Outline
1 Motivation and introduction
2 snow
3 multicore
4 parallel
5 What else and references
Andrew Bzikadze Parallel R 26 / 39
Multicore [deprecated] : quick look
If it is deprecated, why even think about it?
Andrew Bzikadze Parallel R 27 / 39
Multicore [deprecated] : quick look
If it is deprecated, why even think about it? The reason is the package parallel.
Wait a little bit...
Andrew Bzikadze Parallel R 27 / 39
Multicore [deprecated] : quick look
If it is deprecated, why even think about it? The reason is the package parallel.
Wait a little bit...
General use case:
Main word is fork (thus no Windows support),
provides implicit parallelism.
Examples: lapply() runs for ages on your Intel Core i999.
Solves: Single-threaded.
Problems:
• No Windows support.
• No internal RNG support.
• Runs only on one computer.
• Cannot be used with R GUI.
• No internal Load Balancing, however, it can be imitated.
Andrew Bzikadze Parallel R 27 / 39
Multicore [deprecated] : quick look
If it is deprecated, why even think about it? The reason is the package parallel.
Wait a little bit...
General use case:
Main word is fork (thus no Windows support),
provides implicit parallelism.
Examples: lapply() runs for ages on your Intel Core i999.
Solves: Single-threaded.
Problems:
• No Windows support.
• No internal RNG support.
• Runs only on one computer.
• Cannot be used with R GUI.
• No internal Load Balancing, however, it can be imitated.
Warning: Jobs started by multicore share the same state (because of fork).
Andrew Bzikadze Parallel R 27 / 39
Multicore [deprecated] : quick look
We will only consider high-level API and let low-level to be out-of-scope.
mclapply() Parallel version of lapply().
mcmapply() Parallel version of mapply().
pvec()
Somewhat an high-level analog of
low-level clusterSplit() function.
parallel() and collect()
parallel() creates a new process with fork(),
evaluate expression in parallel and after that
the result is retrieved by the collect().
Andrew Bzikadze Parallel R 28 / 39
Multicore: mclapply
mclapply() is a parallel lapply().
Syntax is as follows:
mclapply(X, FUN, ..., mc.preschedule = TRUE, mc.set.seed = TRUE,
mc.silent = FALSE, mc.cores = getOption("mc.cores"))
where
1 mc.preschedule = TRUE — how jobs are created for X.
2 mc.set.seed = TRUE — do you need to randomly seed slaves, or fork it?
3 mc.silent = FALSE — hide info from ‘stdout’ for all parallel forked processes.
‘stderr’ is not affected.
4 mc.cores == getOption("mc.cores") — number of workers (not cores,
actually) to start.
Andrew Bzikadze Parallel R 29 / 39
Multicore: mclapply, mc.preschedule
Meaning:
• TRUE: divide data in mc.cores-jobs
beforehand and fork it to
mc.cores-processes.
• FALSE: for each piece of data
construct a new job (up to
mc.cores).
Andrew Bzikadze Parallel R 30 / 39
Multicore: mclapply, mc.preschedule
Meaning:
• TRUE: divide data in mc.cores-jobs
beforehand and fork it to
mc.cores-processes.
• FALSE: for each piece of data
construct a new job (up to
mc.cores).
Rule of thumb: use
• TRUE: you don’t need load balance
(for instance, if there are lot’s of
values in the data).
• FALSE: the variance of job
completion is very high (so, you
need load balance).
Andrew Bzikadze Parallel R 30 / 39
Outline
1 Motivation and introduction
2 snow
3 multicore
4 parallel
5 What else and references
Andrew Bzikadze Parallel R 31 / 39
parallel
General use case:
Main word is mainstream,
almost a wrapper of snow and multicore packages.
Examples: Anything above.
Solves: Single-threaded and (partially) memory-bound.
Cool features:
• Preinstalled into R since 2.14.0.
• Full RNG support with no dependency on rlecuyer
package.
• Almost nothing to learn (if you are still awake).
• Can be easily used on any platform including Windows.
• Highly compatible with snow and multicore.
Andrew Bzikadze Parallel R 32 / 39
parallel
General use case:
Main word is mainstream,
almost a wrapper of snow and multicore packages.
Examples: Anything above.
Solves: Single-threaded and (partially) memory-bound.
Cool features:
• Preinstalled into R since 2.14.0.
• Full RNG support with no dependency on rlecuyer
package.
• Almost nothing to learn (if you are still awake).
• Can be easily used on any platform including Windows.
• Highly compatible with snow and multicore.
Warning:
On Windows you can’t use more than one machine.
It also can be difficult to configure multiple Linux machines.
Andrew Bzikadze Parallel R 32 / 39
parallel : detectCores()
How many cores?
library(parallel)
mc.cores <- detectCores()
mc.cores
## [1] 8
Warning: It is important to take into account that you maybe have hyper-threading.
Andrew Bzikadze Parallel R 33 / 39
parallel RNG
Unlike snow package no additional packages (like rlecuyer) are needed.
Fork (no Windows) way:
RNGkind("L'Ecuyer-CMRG")
unlist(mclapply(rep(1,4), runif))
## [1] 0.3768615 0.3824588 0.3845725 0.9092709
Cluster way:
detach("package:snow", character.only=TRUE)
library(parallel)
RNGkind("L'Ecuyer-CMRG")
cl <- makeCluster(2, type="PSOCK")
unlist(clusterCall(cl, function(x) runif(2)))
## [1] 0.3114024 0.9506436 0.6032429 0.8057068
stopCluster(cl)
Andrew Bzikadze Parallel R 34 / 39
parallel RNG: reproducible results
Basic way to get reproducible results would be mc.reset.stream() — the parallel
random number generator is reinitialized using the current seed on the master.
detach("package:snow", character.only=TRUE)
library(parallel)
RNGkind("L'Ecuyer-CMRG")
cl <- makeCluster(2, type="PSOCK")
clusterSetRNGStream(cl, 123)
unlist(clusterCall(cl, function(x) runif(2)))
## [1] 0.1663742 0.3898457 0.3411064 0.9712727
clusterSetRNGStream(cl, 123)
unlist(clusterCall(cl, function(x) runif(2)))
## [1] 0.1663742 0.3898457 0.3411064 0.9712727
stopCluster(cl)
Andrew Bzikadze Parallel R 35 / 39
Differences from multicore and snow
Let’s sum up the differences between modern parallel package and his predecessors.
parallel > multicore
• Prefix mc in mcfork(), mcexit(),
mckill(), mcparallel(),
mccollect(), mc.cores.
• Different default value of mc.cores
argument.
• New mc.reset.stream() function.
parallel = snow
• New function
clusterSetRNGStream() initializes
parallel RNG.
• snow.time() function not included.
• makeCluster() supports additional
types FORK.
Also useful detectCores() is added.
Andrew Bzikadze Parallel R 36 / 39
Outline
1 Motivation and introduction
2 snow
3 multicore
4 parallel
5 What else and references
Andrew Bzikadze Parallel R 37 / 39
Out of scope
We covered 3 (2.5 really) packages: snow, multicore, parallel. What else?
• Revolution Analytics foreach package for iteration over a set of values.
• MapReduce via Java Hadoop: RHIPE (negotiator between you with your
MapReduce functions and Hadoop).
• Segue for Amazon Elastic MapReduce lovers. Be aware of terminating clusters.
• doRedis.
• http://cloudNumbers.com
• R and GPUs: gputools etc.
Andrew Bzikadze Parallel R 38 / 39
Literature
Main reference: Useful links:
• Advanced R by Hadley Wickham.
• The R Inferno by Patrick Burns.
• R Packages by Hadley Wickham.
• Writing R Extensions.
• Los Angeles R Users Group:
Parallelization in R, Revisited by
Ryan R. Rosario.
• Package parallel manual.
Andrew Bzikadze Parallel R 39 / 39

Contenu connexe

Tendances

Dynamic pricing of Lyft rides using streaming
Dynamic pricing of Lyft rides using streamingDynamic pricing of Lyft rides using streaming
Dynamic pricing of Lyft rides using streamingAmar Pai
 
CILK/CILK++ and Reducers
CILK/CILK++ and ReducersCILK/CILK++ and Reducers
CILK/CILK++ and ReducersYunming Zhang
 
Os Reindersfinal
Os ReindersfinalOs Reindersfinal
Os Reindersfinaloscon2007
 
Indic threads pune12-apache-crunch
Indic threads pune12-apache-crunchIndic threads pune12-apache-crunch
Indic threads pune12-apache-crunchIndicThreads
 
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by  ...WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by  ...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...AMD Developer Central
 
Yampa AFRP Introduction
Yampa AFRP IntroductionYampa AFRP Introduction
Yampa AFRP IntroductionChengHui Weng
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packagesAjay Ohri
 
How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)Sławomir Zborowski
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5Jeff Larkin
 
Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...Sajib Mitra
 
Reducing Structural Bias in Technology Mapping
Reducing Structural Bias in Technology MappingReducing Structural Bias in Technology Mapping
Reducing Structural Bias in Technology Mappingsatrajit
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextEdward Willink
 
OmpSs – improving the scalability of OpenMP
OmpSs – improving the scalability of OpenMPOmpSs – improving the scalability of OpenMP
OmpSs – improving the scalability of OpenMPIntel IT Center
 
190111 tf2 preview_jwkang_pub
190111 tf2 preview_jwkang_pub190111 tf2 preview_jwkang_pub
190111 tf2 preview_jwkang_pubJaewook. Kang
 

Tendances (20)

Dynamic pricing of Lyft rides using streaming
Dynamic pricing of Lyft rides using streamingDynamic pricing of Lyft rides using streaming
Dynamic pricing of Lyft rides using streaming
 
CILK/CILK++ and Reducers
CILK/CILK++ and ReducersCILK/CILK++ and Reducers
CILK/CILK++ and Reducers
 
The low level awesomeness of Go
The low level awesomeness of GoThe low level awesomeness of Go
The low level awesomeness of Go
 
Apache Crunch
Apache CrunchApache Crunch
Apache Crunch
 
Os Reindersfinal
Os ReindersfinalOs Reindersfinal
Os Reindersfinal
 
Indic threads pune12-apache-crunch
Indic threads pune12-apache-crunchIndic threads pune12-apache-crunch
Indic threads pune12-apache-crunch
 
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by  ...WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by  ...
WT-4065, Superconductor: GPU Web Programming for Big Data Visualization, by ...
 
Yampa AFRP Introduction
Yampa AFRP IntroductionYampa AFRP Introduction
Yampa AFRP Introduction
 
Parallel quicksort cz. 1
Parallel quicksort cz. 1Parallel quicksort cz. 1
Parallel quicksort cz. 1
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
 
OCL 2.5 plans
OCL 2.5 plansOCL 2.5 plans
OCL 2.5 plans
 
How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
 
Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...
 
Reducing Structural Bias in Technology Mapping
Reducing Structural Bias in Technology MappingReducing Structural Bias in Technology Mapping
Reducing Structural Bias in Technology Mapping
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for Xtext
 
OmpSs – improving the scalability of OpenMP
OmpSs – improving the scalability of OpenMPOmpSs – improving the scalability of OpenMP
OmpSs – improving the scalability of OpenMP
 
190111 tf2 preview_jwkang_pub
190111 tf2 preview_jwkang_pub190111 tf2 preview_jwkang_pub
190111 tf2 preview_jwkang_pub
 
GCC, GNU compiler collection
GCC, GNU compiler collectionGCC, GNU compiler collection
GCC, GNU compiler collection
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 

En vedette

2a edição das metas do plano nacional de cultura terceira parte
2a edição das metas do plano nacional de cultura   terceira parte2a edição das metas do plano nacional de cultura   terceira parte
2a edição das metas do plano nacional de cultura terceira parteClaudia Morais
 
Presentacion anyul
Presentacion anyulPresentacion anyul
Presentacion anyulanyulpuentes
 
Hays hoops hysteria invite
Hays hoops hysteria inviteHays hoops hysteria invite
Hays hoops hysteria inviteSean Hurley
 
Sir ken robinson
Sir ken robinsonSir ken robinson
Sir ken robinsonEstherrog
 
AIESEC Mongolia | National Audit Team | Presentation
AIESEC Mongolia | National Audit Team | PresentationAIESEC Mongolia | National Audit Team | Presentation
AIESEC Mongolia | National Audit Team | PresentationGabriela Vasquez Herrero
 
Sistemas de seguridad y control
Sistemas de seguridad y controlSistemas de seguridad y control
Sistemas de seguridad y controlVíctor Arroyo
 
Social Media in NPI Planning (Fortune 500 Cosumer Technology Company)
Social Media in NPI Planning (Fortune 500 Cosumer Technology Company)Social Media in NPI Planning (Fortune 500 Cosumer Technology Company)
Social Media in NPI Planning (Fortune 500 Cosumer Technology Company)BRIDGEi2i Analytics Solutions
 

En vedette (14)

2a edição das metas do plano nacional de cultura terceira parte
2a edição das metas do plano nacional de cultura   terceira parte2a edição das metas do plano nacional de cultura   terceira parte
2a edição das metas do plano nacional de cultura terceira parte
 
Presentacion anyul
Presentacion anyulPresentacion anyul
Presentacion anyul
 
Hays hoops hysteria invite
Hays hoops hysteria inviteHays hoops hysteria invite
Hays hoops hysteria invite
 
Cambio climático
Cambio climáticoCambio climático
Cambio climático
 
Quien soy
Quien soyQuien soy
Quien soy
 
Presentación1
Presentación1Presentación1
Presentación1
 
Ny app coacher jobsøgende
Ny app coacher jobsøgendeNy app coacher jobsøgende
Ny app coacher jobsøgende
 
Sir ken robinson
Sir ken robinsonSir ken robinson
Sir ken robinson
 
Comentario video kar
Comentario video karComentario video kar
Comentario video kar
 
AIESEC Mongolia | National Audit Team | Presentation
AIESEC Mongolia | National Audit Team | PresentationAIESEC Mongolia | National Audit Team | Presentation
AIESEC Mongolia | National Audit Team | Presentation
 
Things I Pooted On
Things I Pooted OnThings I Pooted On
Things I Pooted On
 
Sistemas de seguridad y control
Sistemas de seguridad y controlSistemas de seguridad y control
Sistemas de seguridad y control
 
Social Media in NPI Planning (Fortune 500 Cosumer Technology Company)
Social Media in NPI Planning (Fortune 500 Cosumer Technology Company)Social Media in NPI Planning (Fortune 500 Cosumer Technology Company)
Social Media in NPI Planning (Fortune 500 Cosumer Technology Company)
 
Iceberg Theory
Iceberg TheoryIceberg Theory
Iceberg Theory
 

Similaire à St Petersburg R user group meetup 2, Parallel R

Scafi: Scala with Computational Fields
Scafi: Scala with Computational FieldsScafi: Scala with Computational Fields
Scafi: Scala with Computational FieldsRoberto Casadei
 
CS 542 -- Query Execution
CS 542 -- Query ExecutionCS 542 -- Query Execution
CS 542 -- Query ExecutionJ Singh
 
Parallel Computing with R
Parallel Computing with RParallel Computing with R
Parallel Computing with RAbhirup Mallik
 
Practical Aggregate Programming in Scala
Practical Aggregate Programming in ScalaPractical Aggregate Programming in Scala
Practical Aggregate Programming in ScalaRoberto Casadei
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudRevolution Analytics
 
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at TwitterHadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at TwitterDataWorks Summit
 
Katello on TorqueBox
Katello on TorqueBoxKatello on TorqueBox
Katello on TorqueBoxlzap
 
Hadoop Summit 2015: Performance Optimization at Scale, Lessons Learned at Twi...
Hadoop Summit 2015: Performance Optimization at Scale, Lessons Learned at Twi...Hadoop Summit 2015: Performance Optimization at Scale, Lessons Learned at Twi...
Hadoop Summit 2015: Performance Optimization at Scale, Lessons Learned at Twi...Alex Levenson
 
Data Analytics and Simulation in Parallel with MATLAB*
Data Analytics and Simulation in Parallel with MATLAB*Data Analytics and Simulation in Parallel with MATLAB*
Data Analytics and Simulation in Parallel with MATLAB*Intel® Software
 
Getting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::CGetting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::Cdaoswald
 
Large-scale Recommendation Systems on Just a PC
Large-scale Recommendation Systems on Just a PCLarge-scale Recommendation Systems on Just a PC
Large-scale Recommendation Systems on Just a PCAapo Kyrölä
 
HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...
HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...
HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...AMD Developer Central
 
Seattle useR Group - R + Scala
Seattle useR Group - R + ScalaSeattle useR Group - R + Scala
Seattle useR Group - R + ScalaShouheng Yi
 
[Globant summer take over] Empowering Big Data with Cassandra
[Globant summer take over] Empowering Big Data with Cassandra[Globant summer take over] Empowering Big Data with Cassandra
[Globant summer take over] Empowering Big Data with CassandraGlobant
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Peng Cheng
 

Similaire à St Petersburg R user group meetup 2, Parallel R (20)

Java 8
Java 8Java 8
Java 8
 
Scafi: Scala with Computational Fields
Scafi: Scala with Computational FieldsScafi: Scala with Computational Fields
Scafi: Scala with Computational Fields
 
CS 542 -- Query Execution
CS 542 -- Query ExecutionCS 542 -- Query Execution
CS 542 -- Query Execution
 
Parallel Computing with R
Parallel Computing with RParallel Computing with R
Parallel Computing with R
 
Practical Aggregate Programming in Scala
Practical Aggregate Programming in ScalaPractical Aggregate Programming in Scala
Practical Aggregate Programming in Scala
 
Inferno Scalable Deep Learning on Spark
Inferno Scalable Deep Learning on SparkInferno Scalable Deep Learning on Spark
Inferno Scalable Deep Learning on Spark
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the Cloud
 
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at TwitterHadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
 
Katello on TorqueBox
Katello on TorqueBoxKatello on TorqueBox
Katello on TorqueBox
 
Hadoop Summit 2015: Performance Optimization at Scale, Lessons Learned at Twi...
Hadoop Summit 2015: Performance Optimization at Scale, Lessons Learned at Twi...Hadoop Summit 2015: Performance Optimization at Scale, Lessons Learned at Twi...
Hadoop Summit 2015: Performance Optimization at Scale, Lessons Learned at Twi...
 
Data Analytics and Simulation in Parallel with MATLAB*
Data Analytics and Simulation in Parallel with MATLAB*Data Analytics and Simulation in Parallel with MATLAB*
Data Analytics and Simulation in Parallel with MATLAB*
 
Introduction to Parallelization ans performance optimization
Introduction to Parallelization ans performance optimizationIntroduction to Parallelization ans performance optimization
Introduction to Parallelization ans performance optimization
 
Getting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::CGetting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::C
 
Large-scale Recommendation Systems on Just a PC
Large-scale Recommendation Systems on Just a PCLarge-scale Recommendation Systems on Just a PC
Large-scale Recommendation Systems on Just a PC
 
HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...
HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...
HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...
 
Seattle useR Group - R + Scala
Seattle useR Group - R + ScalaSeattle useR Group - R + Scala
Seattle useR Group - R + Scala
 
[Globant summer take over] Empowering Big Data with Cassandra
[Globant summer take over] Empowering Big Data with Cassandra[Globant summer take over] Empowering Big Data with Cassandra
[Globant summer take over] Empowering Big Data with Cassandra
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
 
main
mainmain
main
 
Algebra
AlgebraAlgebra
Algebra
 

Dernier

Davis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologyDavis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologycaarthichand2003
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxMurugaveni B
 
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
The dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxThe dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxEran Akiva Sinbar
 
Radiation physics in Dental Radiology...
Radiation physics in Dental Radiology...Radiation physics in Dental Radiology...
Radiation physics in Dental Radiology...navyadasi1992
 
preservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxpreservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxnoordubaliya2003
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPirithiRaju
 
Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringPrajakta Shinde
 
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In DubaiDubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubaikojalkojal131
 
User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
Four Spheres of the Earth Presentation.ppt
Four Spheres of the Earth Presentation.pptFour Spheres of the Earth Presentation.ppt
Four Spheres of the Earth Presentation.pptJoemSTuliba
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxpriyankatabhane
 
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.PraveenaKalaiselvan1
 
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTXALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTXDole Philippines School
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...Universidade Federal de Sergipe - UFS
 
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingBase editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingNetHelix
 
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptxECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptxmaryFF1
 

Dernier (20)

Hot Sexy call girls in Moti Nagar,🔝 9953056974 🔝 escort Service
Hot Sexy call girls in  Moti Nagar,🔝 9953056974 🔝 escort ServiceHot Sexy call girls in  Moti Nagar,🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Moti Nagar,🔝 9953056974 🔝 escort Service
 
Davis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologyDavis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technology
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
 
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
 
The dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxThe dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptx
 
Radiation physics in Dental Radiology...
Radiation physics in Dental Radiology...Radiation physics in Dental Radiology...
Radiation physics in Dental Radiology...
 
preservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxpreservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptx
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdf
 
Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical Engineering
 
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In DubaiDubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
 
User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)
 
Four Spheres of the Earth Presentation.ppt
Four Spheres of the Earth Presentation.pptFour Spheres of the Earth Presentation.ppt
Four Spheres of the Earth Presentation.ppt
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
 
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
 
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTXALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
ALL ABOUT MIXTURES IN GRADE 7 CLASS PPTX
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
 
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingBase editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
 
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptxECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
ECG Graph Monitoring with AD8232 ECG Sensor & Arduino.pptx
 

St Petersburg R user group meetup 2, Parallel R

  • 1. Parallel R Andrew Bzikadze seryrzu@gmail.com Saint Petersburg State University, Russia Faculty of Mathematics and Mechanics Department of Statistical Modelling September 12, 2015 Andrew Bzikadze Parallel R 1 / 39
  • 2. Outline 1 Motivation and introduction 2 snow 3 multicore 4 parallel 5 What else and references Andrew Bzikadze Parallel R 2 / 39
  • 3. Motivation Why R? The R language has a lot of advantages: • Open Source. • Cross-Platform. • Free. • Many basic tools. • R extensions. • Arguably fast with R-way style and well-implemented R distribution. Andrew Bzikadze Parallel R 3 / 39
  • 4. Motivation Why R? The R language has a lot of advantages: • Open Source. • Cross-Platform. • Free. • Many basic tools. • R extensions. • Arguably fast with R-way style and well-implemented R distribution. Why bother then? Andrew Bzikadze Parallel R 3 / 39
  • 5. Motivation Why R? The R language has a lot of advantages: • Open Source. • Cross-Platform. • Free. • Many basic tools. • R extensions. • Arguably fast with R-way style and well-implemented R distribution. Why bother then? There are 2 major limitations: • Single-threaded: no out-of-box support of multi-thread calculations. • Memory-bound: all data should fit in RAM. Andrew Bzikadze Parallel R 3 / 39
  • 6. Motivation Why R? The R language has a lot of advantages: • Open Source. • Cross-Platform. • Free. • Many basic tools. • R extensions. • Arguably fast with R-way style and well-implemented R distribution. Why bother then? There are 2 major limitations: • Single-threaded: no out-of-box support of multi-thread calculations. • Memory-bound: all data should fit in RAM. Solution: Parallel Execution. How exactly? • Single-threaded: multiple CPU’s (and cores). • Memory-bound: spread data from one computer (master) to several computers (slaves). Andrew Bzikadze Parallel R 3 / 39
  • 7. Basic Terminology The two types of parallelism: • Implicit — the OS abstracts parallelism from the user. • Explicit — user controls details of the process. A computer cluster consists of a set of loosely or tightly connected computers that work together so that, in many respects, they can be viewed as a single system (Wiki). Master/slave is a model of communication where one device or process has unidirectional control over one or more other devices (Wiki). Andrew Bzikadze Parallel R 4 / 39
  • 8. Overview snow Usage: Explicit parallelism by using clusters (works on Linux, Windows, Mac OS X). Solves: Single-threaded, memory-bound. multicore [deprecated] Usage: Implicit parallelism by using FORK (doesn’t work on Windows). Solves: Single-threaded. Andrew Bzikadze Parallel R 5 / 39
  • 9. Overview snow Usage: Explicit parallelism by using clusters (works on Linux, Windows, Mac OS X). Solves: Single-threaded, memory-bound. multicore [deprecated] Usage: Implicit parallelism by using FORK (doesn’t work on Windows). Solves: Single-threaded. parallel [mainstream] Usage: Almost a wrapper of snow and multicore. Solves: Single-threaded, memory-bound. Andrew Bzikadze Parallel R 5 / 39
  • 10. Overview snow Usage: Explicit parallelism by using clusters (works on Linux, Windows, Mac OS X). Solves: Single-threaded, memory-bound. multicore [deprecated] Usage: Implicit parallelism by using FORK (doesn’t work on Windows). Solves: Single-threaded. parallel [mainstream] Usage: Almost a wrapper of snow and multicore. Solves: Single-threaded, memory-bound. Hadoop R + Hadoop, RHIPE, Segue. Andrew Bzikadze Parallel R 5 / 39
  • 11. Epigraph “. . . R was not built in anticipation of the Big Data revolution. R was born in 1995. Disk space was expensive, RAM even more so, and this thing called The Internet was just getting its legs. Notions of “large-scale data analysis” and “high-performance computing” were reasonably rare. Outside of Wall Street firms and university research labs, there just wasn‘t that much data to crunch.” — Q. Ethan McCallum and Stephen Weston “Parallel R” Andrew Bzikadze Parallel R 6 / 39
  • 12. Outline 1 Motivation and introduction 2 snow 3 multicore 4 parallel 5 What else and references Andrew Bzikadze Parallel R 7 / 39
  • 13. Outline 1 Motivation and introduction 2 snow 3 multicore 4 parallel 5 What else and references Andrew Bzikadze Parallel R 8 / 39
  • 14. snow: quick look General use case: Main word is cluster, provides explicit parallelism. Examples: Monte Carlo simulations, bootstrapping, cross validation, ensemble machine learning algorithms. Solves: Single-threaded, memory-bound. Cool features: • Different transport mechanisms between Master and Slaves: Sockets, MPI (rmpi), NWS (nws), PVM (rpvm). • Good support of RNG (rsprng, rlecuyer). Problems: No communication between the workers (slaves). Andrew Bzikadze Parallel R 9 / 39
  • 15. snow: quick look General use case: Main word is cluster, provides explicit parallelism. Examples: Monte Carlo simulations, bootstrapping, cross validation, ensemble machine learning algorithms. Solves: Single-threaded, memory-bound. Cool features: • Different transport mechanisms between Master and Slaves: Sockets, MPI (rmpi), NWS (nws), PVM (rpvm). • Good support of RNG (rsprng, rlecuyer). Problems: No communication between the workers (slaves). Warning: The input arguments must fit into memory when calling snow function. Its up to the user to arrange high-performance distributed file systems. Andrew Bzikadze Parallel R 9 / 39
  • 16. Structure of API Start and stop clusters: makeCluster, stopCluster. Low-level (cluster-level) functions: cluster* — clusterApply, clusterApplyLB, clusterEvalQ, clusterCall, clusterSplit, etc. High-level functions: par[L,S,A,R,C]apply — parallel versions of apply and related functions. (Uniform) RNG: L‘Ecuyer (package: rlecuyer), SPRNG [deprecated] (package: rsprng). Timing: snow.time(expr) — very useful. Andrew Bzikadze Parallel R 10 / 39
  • 17. Start and stop clusters Basic way: cl <- makeCluster(8, type = "SOCK") # or you may use # makeSOCKcluster(), # makePVMcluster(), etc. stopCluster(cl) First parameter is spec — specification. It is ssh-configurable unless you type "localhost": cl <- makeCluster(c("localhost","localhost"), type = "SOCK") stopCluster(cl) Warning: Be aware of computational costs of cluster setup. Andrew Bzikadze Parallel R 11 / 39
  • 18. Low-level API All of them are cluster* and designed for computing on a cluster. Most interesting are as follows. clusterApply(cl, x, fun, ...) Jobs are being “recycled”. clusterApplyLB(cl, x, fun, ...) Load Balancing version of clusterApply(). clusterCall(cl, fun, ...) Calls a function fun with identical arguments . . . on each node in the cluster cl and returns a list of the results. clusterEvalQ(cl, expr) Evaluates an expression expr on each node in the cluster cl; implemented using clusterCall(). clusterMap(cl, fun, ..., MoreArgs = NULL, RECYCLE = TRUE) Similar to mapply. Andrew Bzikadze Parallel R 12 / 39
  • 19. Example, K-means Basic one-core way: library(MASS) result <- kmeans(Boston, 4, nstart=100) Andrew Bzikadze Parallel R 13 / 39
  • 20. Example, K-means Basic one-core way: library(MASS) result <- kmeans(Boston, 4, nstart=100) Before using snow it is easier to think *apply-way: results <- lapply(rep(25, 4), function(nstart) kmeans(Boston, 4, nstart=nstart) ) i <- sapply(results, function(result) result$tot.withinss ) result <- results[[which.min(i)]] Andrew Bzikadze Parallel R 13 / 39
  • 21. Example, K-means Basic one-core way: library(MASS) result <- kmeans(Boston, 4, nstart=100) Before using snow it is easier to think *apply-way: results <- lapply(rep(25, 4), function(nstart) kmeans(Boston, 4, nstart=nstart) ) i <- sapply(results, function(result) result$tot.withinss ) result <- results[[which.min(i)]] Finally snow version. ignore <- clusterEvalQ(cl, {library(MASS); NULL}) results <- clusterApply(cl, rep(25, 4), function(nstart) kmeans(Boston, 4, nstart=nstart) ) i <- sapply(results, function(result) result$tot.withinss ) result <- results[[which.min(i)]] Andrew Bzikadze Parallel R 13 / 39
  • 22. Load Balancing clusterApply() uses a robin-round fashion for scheduling tasks for clusters. It means one time for every cluster. It could be not very wise to do that. set.seed(123) sleeptime <- abs(rnorm(10, 10, 10)) tm <- snow.time(clusterApply(cl, sleeptime, Sys.sleep)) Andrew Bzikadze Parallel R 14 / 39
  • 23. Load Balancing 0 10 20 30 40 50 60 Elapsed Time Node 01234 Cluster Usage Andrew Bzikadze Parallel R 15 / 39
  • 24. Load Balancing So we waited for more than 50 seconds. A more efficient way would be pull the tasks to clusters when they are needed. This technique is called “load balancing”. Function clusterApplyLB() uses that technique. set.seed(123) sleeptime <- abs(rnorm(10, 10, 10)) tm <- snow.time(clusterApplyLB(cl, sleeptime, Sys.sleep)) Andrew Bzikadze Parallel R 16 / 39
  • 25. Load Balancing 0 5 10 15 20 25 30 35 Elapsed Time Node 01234 Cluster Usage Andrew Bzikadze Parallel R 17 / 39
  • 26. Load Balancing So, here we waited for about 30 seconds. This is an improvement. The only wasted time was at the end. Andrew Bzikadze Parallel R 18 / 39
  • 27. High-level API parLapply(cl, x, fun, ...) Parallel version of lapply(). parSapply(cl, X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE) Parallel version of sapply(). parApply(cl, X, MARGIN, FUN, ...) Parallel version of apply(). parRapply(cl, x, fun, ...) Row apply() for matrix. parCapply(cl, x, fun, ...) Column apply() for matrix. The most useful is parLapply() function. It is different from clusterApply() because it splits the task into “equal” tasks. parLapply ## function (cl, x, fun, ...) ## docall(c, clusterApply(cl, splitList(x, length(cl)), lapply, ## fun, ...)) ## <environment: namespace:snow> where splitList() is an internal snow function. Andrew Bzikadze Parallel R 19 / 39
  • 28. Example of comparison clusterApply() and parLapply() parLapply() could be more efficient if you have more tasks than workers. Another situation — you send large arguments to parLapply(). Let’s take a look at the example. bigsleep <- function(sleeptime, mat) Sys.sleep(sleeptime) bigmatrix <- matrix(0, 2000, 2000) sleeptime <- rep(1, 100) Firstly, let’s try clusterApply(). Andrew Bzikadze Parallel R 20 / 39
  • 29. Example of comparison clusterApply() and parLapply() 0 5 10 15 20 25 30 Elapsed Time Node 01234 Cluster Usage Andrew Bzikadze Parallel R 21 / 39
  • 30. Example of comparison clusterApply() and parLapply() Definitely not highly efficient. Those gaps are due to I/O time. Ideally we should have 25 seconds... Let’s give parLapply() a try. Andrew Bzikadze Parallel R 22 / 39
  • 31. Example of comparison clusterApply() and parLapply() 0 5 10 15 20 25 Elapsed Time Node 01234 Cluster Usage Andrew Bzikadze Parallel R 23 / 39
  • 32. Load Balancing parLapply? Andrew Bzikadze Parallel R 24 / 39
  • 33. Load Balancing parLapply? Short answer: no, there is no such a function in snow package. Good news: it is possible to write your own. Andrew Bzikadze Parallel R 24 / 39
  • 34. Random Number Generation There are 2 basic steps. 1 Configure your cluster workers to use a generator. library(rlecuyer) clusterSetupRNG(cl, type = 'RNGstream') ## [1] "RNGstream" 2 Be happy to generate your numbers. unlist(clusterCall(cl, runif, 1)) ## [1] 0.12701112 0.75958186 0.72850979 0.09570262 Andrew Bzikadze Parallel R 25 / 39
  • 35. Outline 1 Motivation and introduction 2 snow 3 multicore 4 parallel 5 What else and references Andrew Bzikadze Parallel R 26 / 39
  • 36. Multicore [deprecated] : quick look If it is deprecated, why even think about it? Andrew Bzikadze Parallel R 27 / 39
  • 37. Multicore [deprecated] : quick look If it is deprecated, why even think about it? The reason is the package parallel. Wait a little bit... Andrew Bzikadze Parallel R 27 / 39
  • 38. Multicore [deprecated] : quick look If it is deprecated, why even think about it? The reason is the package parallel. Wait a little bit... General use case: Main word is fork (thus no Windows support), provides implicit parallelism. Examples: lapply() runs for ages on your Intel Core i999. Solves: Single-threaded. Problems: • No Windows support. • No internal RNG support. • Runs only on one computer. • Cannot be used with R GUI. • No internal Load Balancing, however, it can be imitated. Andrew Bzikadze Parallel R 27 / 39
  • 39. Multicore [deprecated] : quick look If it is deprecated, why even think about it? The reason is the package parallel. Wait a little bit... General use case: Main word is fork (thus no Windows support), provides implicit parallelism. Examples: lapply() runs for ages on your Intel Core i999. Solves: Single-threaded. Problems: • No Windows support. • No internal RNG support. • Runs only on one computer. • Cannot be used with R GUI. • No internal Load Balancing, however, it can be imitated. Warning: Jobs started by multicore share the same state (because of fork). Andrew Bzikadze Parallel R 27 / 39
  • 40. Multicore [deprecated] : quick look We will only consider high-level API and let low-level to be out-of-scope. mclapply() Parallel version of lapply(). mcmapply() Parallel version of mapply(). pvec() Somewhat an high-level analog of low-level clusterSplit() function. parallel() and collect() parallel() creates a new process with fork(), evaluate expression in parallel and after that the result is retrieved by the collect(). Andrew Bzikadze Parallel R 28 / 39
  • 41. Multicore: mclapply mclapply() is a parallel lapply(). Syntax is as follows: mclapply(X, FUN, ..., mc.preschedule = TRUE, mc.set.seed = TRUE, mc.silent = FALSE, mc.cores = getOption("mc.cores")) where 1 mc.preschedule = TRUE — how jobs are created for X. 2 mc.set.seed = TRUE — do you need to randomly seed slaves, or fork it? 3 mc.silent = FALSE — hide info from ‘stdout’ for all parallel forked processes. ‘stderr’ is not affected. 4 mc.cores == getOption("mc.cores") — number of workers (not cores, actually) to start. Andrew Bzikadze Parallel R 29 / 39
  • 42. Multicore: mclapply, mc.preschedule Meaning: • TRUE: divide data in mc.cores-jobs beforehand and fork it to mc.cores-processes. • FALSE: for each piece of data construct a new job (up to mc.cores). Andrew Bzikadze Parallel R 30 / 39
  • 43. Multicore: mclapply, mc.preschedule Meaning: • TRUE: divide data in mc.cores-jobs beforehand and fork it to mc.cores-processes. • FALSE: for each piece of data construct a new job (up to mc.cores). Rule of thumb: use • TRUE: you don’t need load balance (for instance, if there are lot’s of values in the data). • FALSE: the variance of job completion is very high (so, you need load balance). Andrew Bzikadze Parallel R 30 / 39
  • 44. Outline 1 Motivation and introduction 2 snow 3 multicore 4 parallel 5 What else and references Andrew Bzikadze Parallel R 31 / 39
  • 45. parallel General use case: Main word is mainstream, almost a wrapper of snow and multicore packages. Examples: Anything above. Solves: Single-threaded and (partially) memory-bound. Cool features: • Preinstalled into R since 2.14.0. • Full RNG support with no dependency on rlecuyer package. • Almost nothing to learn (if you are still awake). • Can be easily used on any platform including Windows. • Highly compatible with snow and multicore. Andrew Bzikadze Parallel R 32 / 39
  • 46. parallel General use case: Main word is mainstream, almost a wrapper of snow and multicore packages. Examples: Anything above. Solves: Single-threaded and (partially) memory-bound. Cool features: • Preinstalled into R since 2.14.0. • Full RNG support with no dependency on rlecuyer package. • Almost nothing to learn (if you are still awake). • Can be easily used on any platform including Windows. • Highly compatible with snow and multicore. Warning: On Windows you can’t use more than one machine. It also can be difficult to configure multiple Linux machines. Andrew Bzikadze Parallel R 32 / 39
  • 47. parallel : detectCores() How many cores? library(parallel) mc.cores <- detectCores() mc.cores ## [1] 8 Warning: It is important to take into account that you maybe have hyper-threading. Andrew Bzikadze Parallel R 33 / 39
  • 48. parallel RNG Unlike snow package no additional packages (like rlecuyer) are needed. Fork (no Windows) way: RNGkind("L'Ecuyer-CMRG") unlist(mclapply(rep(1,4), runif)) ## [1] 0.3768615 0.3824588 0.3845725 0.9092709 Cluster way: detach("package:snow", character.only=TRUE) library(parallel) RNGkind("L'Ecuyer-CMRG") cl <- makeCluster(2, type="PSOCK") unlist(clusterCall(cl, function(x) runif(2))) ## [1] 0.3114024 0.9506436 0.6032429 0.8057068 stopCluster(cl) Andrew Bzikadze Parallel R 34 / 39
  • 49. parallel RNG: reproducible results Basic way to get reproducible results would be mc.reset.stream() — the parallel random number generator is reinitialized using the current seed on the master. detach("package:snow", character.only=TRUE) library(parallel) RNGkind("L'Ecuyer-CMRG") cl <- makeCluster(2, type="PSOCK") clusterSetRNGStream(cl, 123) unlist(clusterCall(cl, function(x) runif(2))) ## [1] 0.1663742 0.3898457 0.3411064 0.9712727 clusterSetRNGStream(cl, 123) unlist(clusterCall(cl, function(x) runif(2))) ## [1] 0.1663742 0.3898457 0.3411064 0.9712727 stopCluster(cl) Andrew Bzikadze Parallel R 35 / 39
  • 50. Differences from multicore and snow Let’s sum up the differences between modern parallel package and his predecessors. parallel > multicore • Prefix mc in mcfork(), mcexit(), mckill(), mcparallel(), mccollect(), mc.cores. • Different default value of mc.cores argument. • New mc.reset.stream() function. parallel = snow • New function clusterSetRNGStream() initializes parallel RNG. • snow.time() function not included. • makeCluster() supports additional types FORK. Also useful detectCores() is added. Andrew Bzikadze Parallel R 36 / 39
  • 51. Outline 1 Motivation and introduction 2 snow 3 multicore 4 parallel 5 What else and references Andrew Bzikadze Parallel R 37 / 39
  • 52. Out of scope We covered 3 (2.5 really) packages: snow, multicore, parallel. What else? • Revolution Analytics foreach package for iteration over a set of values. • MapReduce via Java Hadoop: RHIPE (negotiator between you with your MapReduce functions and Hadoop). • Segue for Amazon Elastic MapReduce lovers. Be aware of terminating clusters. • doRedis. • http://cloudNumbers.com • R and GPUs: gputools etc. Andrew Bzikadze Parallel R 38 / 39
  • 53. Literature Main reference: Useful links: • Advanced R by Hadley Wickham. • The R Inferno by Patrick Burns. • R Packages by Hadley Wickham. • Writing R Extensions. • Los Angeles R Users Group: Parallelization in R, Revisited by Ryan R. Rosario. • Package parallel manual. Andrew Bzikadze Parallel R 39 / 39