The MPI standard clearly states (in 8.7.1 Allowing User Functions at
Process Termination) that the mechanism you describe is only allowed on
MPI_COMM_SELF. The most relevant part starts at line 14.

George.



On Tue, Aug 26, 2014 at 11:20 AM, Lisandro Dalcin <dalc...@gmail.com> wrote:

> Another issue while testing 1.8.2 (./configure --enable-debug
> --enable-mem-debug).
>
> Please look at the following code. I'm duplicating COMM_WORLD and
> composing the dupe on it. The attribute free function is written to
> Comm_free the duped comm and deallocate memory. However, the run fails
> with the error you can see at the end.
>
> IMHO, this is a bug. This way of managing duplicated communicator
> contexts is quite common in parallel libraries. Moreover, In the MPI 3
> standard, page 364, lines 11 and 12, it says:
> """
> For example, MPI is “active” in callback functions that are invoked
> during MPI_FINALIZE.
> """
>
> Interestingly, if I replace WORLD -> SELF in the code below, I do not
> get the error.
>
> $ cat finalize.c
> #include <stdlib.h>
> #include <mpi.h>
>
> static int free_comm(MPI_Comm comm, int k, void *v, void *xs)
> {
>   MPI_Comm_free((MPI_Comm *)v);
>   free(v);
>   return MPI_SUCCESS;
> }
>
>
> int main(int argc, char *argv[])
> {
>   int keyval;
>   MPI_Comm base,*comm;
>   MPI_Init(&argc, &argv);
>
>   MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN, free_comm, &keyval, NULL);
>
>   base = MPI_COMM_WORLD;
>   comm = (MPI_Comm *)malloc(sizeof(MPI_Comm));
>   MPI_Comm_dup(base, comm);
>   MPI_Comm_set_attr(base, keyval, comm);
>
>   MPI_Finalize();
>   return 0;
> }
>
> $ mpicc finalize.c
> $ ./a.out
> *** The MPI_Comm_free() function was called after MPI_FINALIZE was invoked.
> *** This is disallowed by the MPI standard.
> *** Your MPI job will now abort.
> [kw2060:14603] Local abort after MPI_FINALIZE completed successfully;
> not able to aggregate error messages, and not able to guarantee that
> all other processes were killed!
>
>
> --
> Lisandro Dalcin
> ============
> Research Scientist
> Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
> Numerical Porous Media Center (NumPor)
> King Abdullah University of Science and Technology (KAUST)
> http://numpor.kaust.edu.sa/
>
> 4700 King Abdullah University of Science and Technology
> al-Khawarizmi Bldg (Bldg 1), Office # 4332
> Thuwal 23955-6900, Kingdom of Saudi Arabia
> http://www.kaust.edu.sa
>
> Office Phone: +966 12 808-0459
> _______________________________________________
> devel mailing list
> de...@open-mpi.org
> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/devel
> Link to this post:
> http://www.open-mpi.org/community/lists/devel/2014/08/15712.php

Reply via email to