Mario Valle
2011-Jan-14 05:25 UTC
[R] Fwd: Re: [R-sig-hpc] Working doSNOW foreach openMPI example
Whas missing the R in the command line:
"mpirun -n --hostfile /home/hostfile R --no-save -f rtest.R"
Hope this helps
mario
On 13-Jan-11 22:08, Justin Moriarty wrote:> Hi,
> Just wanted to share a working example of doSNOW and foreach for an
openMPI cluster. The function eddcmp() is just an example and returns some
inocuous warnings. The example first has each node return its nodename, then
runs an example comparing dopar, do and a for loop. In the directory containing
rtest.R it is run from the command line with:
> "mpirun -n --hostfile /home/hostfile --no-save -f rtest.R"
>
> Here is the code for rtest.R:
>
> #################
> library(doSNOW)
> library(panel)
>
> cl<-makeMPIcluster(3)
> registerDoSNOW(cl)
>
> clusterEvalQ(cl,library(panel))
>
> res<-clusterCall(cl, function(){Sys.info()["nodename"]})
> print(do.call(rbind,res))
>
> sme<- matrix(rnorm(100),10,10)
> clusterExport(cl,"sme")
>
> myfun<-function()
> {
> for(i in 1:1000)
> {
> x<-eddcmp(sme)
> }
> }
>
> ged<-0
>
> system.time({
> ged<-foreach(i=1:10) %dopar%
> {
> myfun()
> }
> })
>
> system.time({
> ged<-foreach(i=1:10) %do%
> {
> myfun()
> }
> })
>
> system.time({
> for(i in 1:10)
> {
> ged<-myfun()
> }
> })
>
> stopCluster(cl)
> mpi.quit()
>
> #################
> Cheers,
> Justin
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-hpc mailing list
> R-sig-hpc at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
--
Ing. Mario Valle
Data Analysis and Visualization Group | http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
Seemingly Similar Threads
- [R-sig-hpc] Error in makeMPIcluster(spec, ...): how to get a minimal example for parallel computing with doSNOW to run?
- Question about foreach (with doSNOW), is that a bug?
- compat-openmpi issues after upgrade to CentOS 6.5
- lam vs. openmpi
- untaring files in parallel with foreach and doSNOW?
