R - Concurrent Programming - r

Is it possible to do concurrent programming in R
For example, running 2 functions with while(TRUE) loops concurrently.

The snow, Rmpi, and pvm packages have supported this for almost a decade, initially across computers and also on a multi-cpu or multi-core machine.
The multicore package added a the ability to do this on multi-core machines.
Since R 2.14.0, the parallel package has bundled parts of snow and multicore in the basic R distribution. This may be your best starting point now.
A few parts of R itself also use multi-threaded programming, but that approach is limited due to some architectural constraints that are unlikely to be lifted.
We wrote a survey paper on parallel programming with R a few years ago which is still relevant.

Yes as of version 2.14.0 the parallel package is included so you can run things on different threads for one instance of R. See: http://cran.r-project.org/web/views/HighPerformanceComputing.html

Related

R with 36 cores is much slower than R with 8 cores

On the right hand side is the result from EC2 instance with 36 cores and 64GB RAM while on the left is my laptop with 8 cores and 8GB RAM.
I'm new to running R on AWS EC2 instance, so probably I need to configure my R in order to make use of the EC2 instance raw compute power.
Could someone please advise on how or is there anything that I miss here?
Thanks!
I found the better answer here.
Quite disappointing with the unnecessary downvotes.
https://github.com/csantill/RPerformanceWBLAS/blob/master/RPerformanceBLAS.md
We frequently hear that R is slow, if your code makes heavy usage of
vector/matrix operations you will see significant performance
improvements.
The precompiled R distribution that is downloaded from CRAN makes use
of the reference BLAS/LAPACK implementation for linear algebra
operations, These implementations are built to be stable and cross
platform compatible but are not optimized for performance. Most R
programmers use these default libraries and are unaware that highly
optimized libraries are available and switching to these can have a
significant perfomance improvement.

Do parallel computing packages such as doSNOW/doParallel help when I'm using Microsoft R open?

I'm using Microsoft R Open, which embeds parallel computing in its backend. Just curious if using parallel computing packages doSNOW/doParallel with foreach would still improve computational performance on top of that? Or it would actually cause some conflicts and slow down the computation?

Microsoft Open R (Revolution R) using Two CPUs each with Multple Cores

Good morning.
I know it's relatively easy to spread the computation of a monte carlo simulation across multiple cores on one CPU using Microsoft Open R (running Windows 10), but can you run the processing across 2 CPUs each with say 12 cores on one machine?
Thank you
So if you are using the Microsoft RevoUtilsMath package, you will get multi-threading "for free" on a multi-processor, multicore machine. See more here. There are also CRAN packages available to support multicore. Couple of examples: here, and here.
If you use Microsoft R Server, the RevoScaleR functions are parallel.

Does the integration of Intel® Parallel Studio XE 2013 for Linux* and R lead to significant performance improvements?

I am running some resource intensive computations in R. I use for-loops, bootstrap simulations and so on. I have already integrated the Intel® Math Kernel Library for Linux* with R and it seems that this has lead to a significant improvement in computation times. I am now thinking about integrating Intel® Parallel Studio XE 2013 for Linux* and R. This means passing the different compilers that ship with it to R:
(1) Will the integration of Intel® Parallel Studio XE 2013 for Linux* and R lead to significant performance improvements?
(2) Could you give some examples in which situations I would have a benefit?
Thank you!
Very rough order of magnitude:
parallel / multi-core BLAS such as the MKL will scale sublinearly in the number of cores but only for the parts of your operations that are actually BLAS calls ie not for your basic "for-loops, bootstrap simulation and so on"
byte-compiling your R code may give you up to a factor of two, maybe three
after that you may need heavier weapons such as for example Rcpp which can give 50, 70, 90-fold speedups on code involving "for-loops, bootstrap simulation and so on" which why it is eg so popular with the MCMC crowd
similarly, the Intel TBB and other parallel tricks will require rewrites of your code.
There is no free lunch.

Difference between "SOCK", "PVM", "MPI", and "NWS" for the R SNOW package

The makeCluster function for the SNOW package has the different cluster types of "SOCK", "PVM", "MPI", and "NWS" but I'm not very clear on the differences among them, and more specifically which would be best for my program.
Currently I have a queue of tasks of different length going into a load balancing cluster with clusterApplyLB and am using a 64bit 32-core Windows machine.
I am looking for a brief description of the differences among the four cluster types, which would be best for my use and why.
Welcome to parallel programming. You may want to peruse the vignette of the excellent parallel package that comes with R as it gives a general introduction. It also gives you an idea of what you can or cannot do on Windows -- in short, PVM and MPI are standard parallel programming approaches supported by namesake libraries. These exists on Windows, but are less frequently used and often not as mature as their Unix counterparts.
If you want to stick with snow, your options are essentially limited to SOCK types clusters. Again, the package documentation will have pointers.

Resources