I have a MPI program under Intel C++ with its Intel MPI library.
According to the user input, the master process will broadcast data to other worker processes.
In worker processes, I use a do-while loop to keep receiving data from master
int master_rank =0
int mycmd;
if(my_rank==master_rank )
{
//wait for user input
//accept input command
MPI_Bcast(&mycmd, 1, MPI_INT, master_rank, MPI_COMM_WORLD);
//do some work
}
else
{
MPI_Bcast(&mycmd, 1, MPI_INT, master_rank, MPI_COMM_WORLD);
switch (mycmd)
{
case 1:
// do some work
break;
case 2:
// do some work
break;
default:
std::cout << "myrank:" << my_rank << "Unknown command:" << mycmd << std::endl;
break;
}
}
However, I found that even during waiting for user input, the all worker processes always make CPU usage up to nearly 100% .
This make my computer too hot..
I googled the web, and found openMPI provide an option mpi_yield_when_idle Probe seems to consume the CPU
mpirun -np N --mca mpi_yield_when_idle 1 ./a.out But in intel MPI, I can not find a similar option
I changed MPI_Bcast to MPI_IBcast , it seems no any improvement at all.
Any idea to solve it?
Thank you all.
I_MPI_WAIT_MODE
,I_MPI_THREAD_YIELD
andI_MPI_SPIN_COUNT
. one of these might help you here. An other option is to start one MPI task and thenMPI_Comm_spawn()
the slaves. – Gilles Gouaillardet