Search code examples
cmpiabort

MPI_Abort() vs exit()


Is there any good reason to prefer

MPI_Abort(MPI_COMM_WORLD, MY_ERROR_CODE);

to

exit(MY_ERROR_CODE);

in an MPI-based parallel code written in C? So far I've never used the former.


Solution

  • Read the documentation of the MPI_Abort function: https://www.open-mpi.org/doc/v2.0/man3/MPI_Abort.3.php. The exit function just terminates the calling process. MPI_Abort on the other hand

    makes a "best attempt" to abort all tasks in the group of comm

    not just the calling process.