[R-sig-hpc] Rmpi: What tag gets assigned to mpi.bcast.cmd?
Till Francke
win at comets.de
Thu Jan 10 15:12:57 CET 2013
Dear list,
when passing messages with Rmpi using mpi.send.Robj(), it is possible to
supply argument "tag" to tag the message. mpi.bcast.cmd() does not have
this option.
However, messages issued by mpi.bcast.cmd() still get a value for tag (see
example below), which in my case makes the slaves misinterpret the meaning
of the message.
Is there any way of providing a tag to mpi.bcast.cmd() or prevent its
tranfer altogether?
Thanks for your advice,
Till
<code>
library(Rmpi)
slave_func=function() #does nothing but print the received messages into
files
{
sink(paste("slave",mpi.comm.rank(),sep="")) #create logfiles for
slaves to see their output
tag <- 1
while(tag!=7) #
{
slave_message <- mpi.recv.Robj(mpi.any.source(),mpi.any.tag())
slave_message_info <- mpi.get.sourcetag()
slave_id <- slave_message_info[1]
tag <- slave_message_info[2]
print(paste("tag:",tag,"message:",slave_message))
}
sink()
}
mpi.spawn.Rslaves(nslaves=2)
mpi.bcast.Robj2slave(slave_func) #send function to slaves
mpi.bcast.cmd(slave_func())
mpi.send.Robj(obj=1, dest=1, tag=1) #yields "tag: 1 message: 1"
-correct
mpi.send.Robj(obj=2, dest=2, tag=2) #yields "tag: 2 message: 2"
-correct
mpi.bcast.cmd(slave_func()) #yields "tag: 1 message:
slave_func()" on slave 1
# "tag: 2 message:
slave_func()" on slave 2
#where does the value for "tag"
come from?
mpi.send.Robj(obj=11, dest=1, tag=11) #correct
mpi.send.Robj(obj=22, dest=2, tag=22) #correct
mpi.bcast.cmd(slave_func()) #yields "tag: 1 message:
slave_func()" on slave 1
# "tag: 2 message:
slave_func()" on slave 2
#Is the first-ever used tag
always used by mpi.bcast.cmd()?
#I don't think so, but I cannot
reproduce an example.
mpi.send.Robj(obj=1, dest=1, tag=7) #finish
mpi.send.Robj(obj=1, dest=2, tag=7) #finish
mpi.close.Rslaves()
</code>
> sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Rmpi_0.6-2
More information about the R-sig-hpc
mailing list