Skip to content
Back to formatted view

Raw Message

Message-ID: <4FC5B986.5060004@fhcrc.org>
Date: 2012-05-30T06:09:10Z
From: Martin Morgan
Subject: Simple example for High performance computing with R?
In-Reply-To: <CAN31xkcYcFYMCWW=y77H1_H7tG+ubU0QqFVRRg+1S6wndjg6=Q@mail.gmail.com>

On 05/29/2012 08:02 PM, Fabrice Tourre wrote:
> Dear list,
>
> I want to run two independent calculation (A, B) and then combined
> their results to do a plot in R. Before I just run calculation A
> first, then calculation B. It will take some times. I just have one
> server with multiple core. I noticed that there are some nice package
> in R for parallel calculation, such as parallel, multicore and snow.
> Also there is a book, O?Reilly ? ?Parallel R, Data Analysis in the
> Distributed World? book by Q. Ethan McCallum and Stephen Weston.
>
> When track into these packages, I am a little of lost because I did
> not know parallel calculation too much.
>
> Could any one can give me some example codes for my purpose? So I can
> easy follow.

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

>
> Thank you very much in advance.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793