Q:

master consuming 100% CPU in Rmpi program

I'm using the Rmpi (v. 0.6-2) package to parallelize my R (v. 2.15) code. I have the following peace of code:
library(Rmpi)
source("slaveFunction04.r")
mpi.spawn.Rslaves(nslaves=2)
mpi.bcast.Robj2slave(slaveFunction04)
mpi.remote.exec(slaveFunction04())
mpi.close.Rslaves()
mpi.quit()

While the slaves are executing slaveFunction04 I would expect the master process to be idle, consuming very little resources, as it happens when you use MPI with C or Fortran. But instead, the master is consuming a 100% of CPU, just like the slaves (each process is running in its own core).
Any idea why this happens and how can I solve it?
For MPI I'm using OpenMPI v. 1.6-3.1.2 on OpenSuse 12.3.
Thanks in advance.

A:

This isn't unusual, and in fact is pretty much what I'd expect to see in C or Fortran as well with a master-slave decomposition.
MPI is designed for high-performance parallel computing, where typically if a task is blocked waiting for a message there's no more important thing to do than to get that message as fast as possible, so the implementation "busy waits", repeatedly polling to see if the message has arrived, tying up the CPU.  That chews up CPU time, but by hypothesis there's nothing else to do and it shaves microseconds off of the latency when the message does arrive.  That mode of operation is generally the default in most MPI implementations; it's called "aggressive" mode in OpenMPI and is described here. 
That's a very sensible default behaviour for many problems, but isn't always what you want, so there are ways of turning it off.  If this is the cause of what you're seeing, you should be able to somewhat reduce the CPU load on the master by setting the environment variable OMPI_MCA_mpi_yield_when_idle to 1 (or non-zero) to get out of aggressive mode.

