Luculus Luculus -4 years ago 94
C Question

MPI_Abort and dynamically allocated memory

I am learning to program in MPI in C and I didn't manage to find what happens with the dynamically allocated memory (malloc/calloc) in all processes from a MPI communicator/group when one of the processes calls MPI_Abort.

Not freeing the dynamically allocated memory can cause malfunctions/unpredictable behaviors? Is this considered as a leak?

Answer Source

MPI_Abort() is analogous to exit():

This routine makes a "best attempt" to abort all tasks in the group of comm. This function does not require that the invoking environment take any action with the error code. However, a Unix or POSIX environment should handle this as a return errorcode from the main program.

(MPI 3.1 specification)

Where it is effective at aborting processes, any dynamically-allocated memory held by those processes is released back to the OS. Dynamic allocations do not survive process termination. So,

Not freeing the dynamically allocated memory can cause malfunctions/unpredictable behaviors?

To some extent.

Is this considered as a leak?

There is no leak of malloc()ed or calloc()ed memory arising from the operation of MPI_Abort(). Memory leaking is relevant only in the context of a process that continues to run.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download