Skip to content
Prev 296024 / 398513 Next

Simple example for High performance computing with R?

On 05/29/2012 08:02 PM, Fabrice Tourre wrote:
Here we sleep for 20 seconds, but do it in only 5 seconds!

 > library(parallel)
 > system.time(mclapply(1:4, function(i) Sys.sleep(5), mc.cores=4))
    user  system elapsed
   0.006   0.025   5.021

Often, it is possible to use mclapply just like lapply; use the 
'parallel' library, and for single processor machines the mclapply and 
similar functions rather than parLapply and similar. This

   vignette("parallel", package="parallel")

might provide further help. Likely you will get benefit from making your 
calculation A use parallel calculations, and B use parallel calculation.

Martin