[R-sig-hpc] Rmpi: What tag gets assigned to mpi.bcast.cmd?
Hao Yu
hyu at stats.uwo.ca
Thu Jan 10 15:34:21 CET 2013
You cannot use mpi.bcast.cmd in the middle of computation unless slaves
are back into the original state: idle. It is mainly used at the beginning
so that slaves can carry out their executions until end.
When you are using mpi.spawn.Rslaves(nslaves=2), all slaves are running an
infinite loop
repeat
try(eval(mpi.bcast.cmd(rank=0,comm=.comm, nonblock=.nonblock,
sleep=.sleep),envir=sys.parent()),TRUE)
mpi.bcast.cmd must be used by both master and slaves at the same time.
Otherwise there is a deadlock or miscommunication (in your case).
Hao
Till Francke wrote:
> 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
>
> _______________________________________________
> R-sig-hpc mailing list
> R-sig-hpc at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
>
--
Department of Statistics & Actuarial Sciences
Office Phone#:(519)-661-3622
Fax Phone#:(519)-661-3813
The University of Western Ontario
London, Ontario N6A 5B7
http://www.stats.uwo.ca/yu
More information about the R-sig-hpc
mailing list