InitFinalize
在執行任何 MPI 命令之前,需要初始化環境,最後完成:
int main(int argc, char** argv)
{
int res;
res = MPI_Init(&argc,&argv);
if (res != MPI_SUCCESS)
{
fprintf (stderr, "MPI_Init failed\n");
exit (0);
}
...
res = MPI_Finalize();
if (res != MPI_SUCCESS)
{
fprintf (stderr, "MPI_Finalize failed\n");
exit (0);
}
}