CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   MPI_barrier() (http://www.cfd-online.com/Forums/openfoam/69701-mpi_barrier.html)

johndeas November 1, 2009 09:45

MPI_barrier()
 
Hi,

I need my master processor to carry out some operations on some files. I would like all the other processors to pause while this is going on, as their behaviour might be affected by the non completion of the task on the master proc.

I have read about MPI_barrier() which seems to be what I need:

Code:

if not on the masterProc:
    MPI_barrier()
else:
    carry out operation
    MPI_barrier()

Is it possible to do this directly using OpenFOAM commands and if not, is it possible to use the vanilla MPI_barrier() ?

In that case what arguments should be put in:
Code:

int MPI_Barrier ( MPI_Comm comm )
?

Thanks !

fra76 November 3, 2009 14:29

When I need this, I usually do a reduction, as MPI_barrier is not exposed by Pstream, as far as I know.

I.e.:

Code:

if (Pstream.master())
{
  carry out operation
}
{
    label tmp = Pstream.myProcNo();
    reduce(tmp,sumOp<label>());
}

At the reduce statement, all the processors must pass together, so the effect is like MPI_barrier even if with a very low unnecessary traffic.

Hope this helps,
Francesco

johndeas November 23, 2009 12:59

Since I am putting a lot of commands, a proper MPI_barrier might have helped, but, thank you for you advice, will use it !


All times are GMT -4. The time now is 08:22.