Hi everybody!

I have the next code which makes a reduction of the *a *variable in two
slaves, using the Rmpi package.

library(Rmpi)

mpi.spawn.Rslaves(nslaves=2)

reduc<-function(){
  a<-mpi.comm.rank()+2
  mpi.reduce(a,type=2, op="prod")
  return(paste("a=",a))
}

mpi.bcast.Robj2slave(reduc)
mpi.remote.exec(reduc())

cat("Product: ")
mpi.reduce(1,op="prod")


mpi.close.Rslaves()


I want to use the function mpi.allreduce() instead of mpi.reduce(), so
slaves should receive the value of the reduction. I don't know how to do it
and the avaliable documentation is very small and i'm starting with Rmpi. I
also tried with the next two changes but nothing:


library(Rmpi)

mpi.spawn.Rslaves(nslaves=2)

reduc<-function(){
  a<-mpi.comm.rank()+2
  mpi.reduce(a,type=2, op="prod")
  return(paste("a=",a))
}

mpi.bcast.Robj2slave(reduc)
mpi.remote.exec(reduc())

cat("Product: ")
mpi.allreduce(1,op="prod")


mpi.close.Rslaves()



and



library(Rmpi)

mpi.spawn.Rslaves(nslaves=2)

reduc<-function(){
  a<-mpi.comm.rank()+2
  mpi.allreduce(a,type=2, op="prod")
  return(paste("a=",a))
}

mpi.bcast.Robj2slave(reduc)
mpi.remote.exec(reduc())

cat("Product: ")
mpi.allreduce(1,op="prod")


mpi.close.Rslaves()

Could somebody help me?

Thanks a lot in advance for your help !*
*

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to