Fabrice Tourre
2012-May-30 03:02 UTC
[R] Simple example for High performance computing with R?
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. Thank you very much in advance.
Martin Morgan
2012-May-30 06:09 UTC
[R] Simple example for High performance computing with R?
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
Prof Brian Ripley
2012-May-30 08:16 UTC
[R] Simple example for High performance computing with R?
On 30/05/2012 04:02, 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. > > 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.Please read the vignette for package 'parallel': we already answered your request. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595