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]]
Hi everybody!
I have the next code which makes a reduction of the *a *variable in two
slaves, using the Rmpi package.
library(Rmpi)
#get the slaves
mpi.spawn.Rslaves(nslaves=2)
#slaves will execute this function
reduc<-function(){
a<-mpi.comm.rank()+2
mpi.reduce(a,type=2, op="prod")
return(paste("a=",a))
}
#send function
mpi.bcast.Robj2slave(reduc)
#execute function by slaves
mpi.remote.exec(reduc())
#get reduction
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]]