屏障

MPI_Barrier 操作在屬於給定通訊器的程序之間執行同步。也就是說,來自給定通訊器的所有程序將在 MPI_Barrier 內等待,直到所有程序都在內部,並且在那時,它們將離開操作。

int res;

res = MPI_Barrier (MPI_COMM_WORLD); /* all processes will wait */
if (res != MPI_SUCCESS)
{
    fprintf (stderr, "MPI_Barrier failed\n");
    exit (0);
}