mpi.send.Robj()崩溃R

时间:2015-07-30 14:58:01

标签: r mpi mpich

我是Rmpi软件包的新手,并尝试使用MPI进行第一次发送/接收数据的演示。但是,每次在我的代码中调用mpi.send.Robj()时,R总是会崩溃。我在这里发布我的代码,希望有人可以给我一个暗示。我在Windows7 64bit中使用mpich2 1.4.1p,Rmpi 0.6-3。

MakeCluster <- function(count){
  comm = 1

  pcl <- vector("list", count)
  for (i in seq(along = pcl)) pcl[[i]] <- newMPInode(i, comm)
  class(pcl) <- c("spawnedMPIcluster", "MPIcluster", "cluster")
  setMPIcluster(pcl)
  pcl
}

library('Rmpi')

mpi.spawn.Rslaves(nslaves=3)

pcl = MakeCluster(mpi.comm.size()-1)

srecv<-function(){
  if(mpi.comm.rank() > 0 )
    mpi.recv.Robj(0, mpi.any.tag(), comm = 1)
}
mpi.bcast.Robj2slave(srecv)

x = 5:10
for (i in seq_along(pcl)) {
  mpi.send.Robj(x[i], pcl[i]$rank, tag = pcl[i]$tag, pcl[i]$comm)
}
# R crashes in the above loop, or with single call to `mpi.send.Robj` like
# i = 1
# mpi.send.Robj(x[i], pcl[i]$rank, tag = pcl[i]$tag, pcl[i]$comm)

mpi.remote.exec(srecv())

使用mpi.sendmpi.recv即可

srecv<-function(rank){
  if(mpi.comm.rank() == rank)
    mpi.recv(x, 1, 0, mpi.any.tag(), comm = 1)
}
mpi.bcast.Robj2slave(srecv)

x = 1L
mpi.bcast.Robj2slave(x)

# send to slaves
x = 109L
mpi.send(x, 1, 3, 1, 1)
mpi.bcast.cmd(srecv(3))

#check results
mpi.remote.exec(x)


mpi.close.Rslaves()

0 个答案:

没有答案