Parallel Programming using R in Windows

Ashamed at my lack of parallel programming, I decided to learn some R Parallel Programming (after all parallel blogging is not really respect worthy in tech-geek-ninja circles).

So I did the usual Google- CRAN- search like a dog thing only to find some obstacles.


Some Parallel Programming Packages like doMC are not available in Windows

Some Parallel Programming Packages like doSMP depend on Revolution’s Enterprise R (like –

and (No the latest hack didnt work)

or are in testing like multicore (for Windows) so not available on CRAN

fortunately available on RForge

Revolution did make DoSnow AND foreach available on CRAN


but the documentation in SNOW is overwhelming (hint- I use Windows , what does that tell you about my tech acumen) and

what is a PVM or MPI? and SOCKS are for wearing or getting lost in washers till I encountered them in SNOW

Finally I did the following-and made the parallel programming work in Windows using R

cl<-makeCluster(2) # I have two cores
# create a function to run in each itteration of the loop

check <-function(n) {

+ for(i in 1:1000)

+ {

+ sme <- matrix(rnorm(100), 10,10)

+ solve(sme)

+ }

+ }
times <- 100     # times to run the loop
system.time(x <- foreach(j=1:times ) %dopar% check(j))
user  system elapsed
0.16    0.02   19.17
system.time(for(j in 1:times ) x <- check(j))
user  system elapsed</pre>
39.66    0.00   40.46


And it works!