Search code examples
pythonerror-handlingmpiabortmpi4py

mpi4py: abort() and raise RuntimeError()


Is there a way to use mpi4py.abort() and python raise RuntimeError() (or any other sort of error) together? Maybe

errstr = 'ARRRGH!!!'
raise RuntimeError(errstr)
mpicomm.abort()

or

mpicomm.abort()
errstr = 'ARRRGH!!!'
raise RuntimeError(errstr)

or some other variant?


Solution

  • Given that MPI_Abort basically terminates all processes within the application, there is no way to combine this with regular exception handling in python. Note that MPI implementations are permitted to abort all processes, not just the one in mpicomm.

    The only think that would make some sense, it to raise a RuntimeError in some local python code, and invoke mpicomm.abort() in the exception handler.