[mpich2-dev] some comments on attribute catching, create/free() keyvals and all that.

Lisandro Dalcin dalcinl at gmail.com
Fri Mar 13 13:34:09 CDT 2009


Dave, this is not related at all with the ticket... but with a
behavior of MPICH2 (and likely others MPI's out there, just confirmed
this on Open MPI) about how create()/free() keyvals work...

Please, try to read my mail and run the code example... I would lilke
to know your opinions about this behaviour, this could be really
dangerous :-)


On Fri, Mar 13, 2009 at 4:14 PM, Dave Goodell <goodell at mcs.anl.gov> wrote:
> Lisandro,
>
> Have you seen our recent commits on this issue?  I believe that the issues
> you pointed out were resolved in the following changesets: r4025-r4030,
> r4044, r4048.
>
> Related trac tickets: #222, #449
>
> -Dave
>
> On Mar 13, 2009, at 1:01 PM, Lisandro Dalcin wrote:
>
>> As I've shown in a previous emal, MPICH2 likely implement
>> create()/free() for keyvals using a counter that is incr/decr ...
>>
>> Now, give a try to the code pasted below. This shows that (at least in
>> MPICH2), MPI_Keyval_free() have to be used with great care as it is
>> IMHO dangerous, and basically these calls should be all done near
>> MPI_Finalize() time... or bad things could happen...
>>
>> The only reference I can found in the MPI standard is at
>> (http://www.mpi-forum.org/docs/mpi21-report-bw/node147.htm#Node147)
>> where MPI_Comm_free_keyval() is explained... However, I believe that
>> description is talking about different things...
>>
>> Should MPICH2 stop decrefing the keyval counter? You know, about 2<<31
>> values should be enough, right ;-) ?
>> But then.. What the pourpose of having MPI_Keyval_free()? Just to
>> invalidate de passed value by setting it to KEYVAL_INVALID?
>>
>>
>> #include <mpi.h>
>> #include <stdio.h>
>>
>> int free_KeyVal(MPI_Comm c, int k, void *v,void *ctx)
>> {
>>  printf("free_KeyVal()\n");
>>  return MPI_SUCCESS;
>> }
>>
>> int main( int argc, char ** argv ) {
>>  int Key1, Key2, Val1=1, Val2=2, ValOut;
>>  MPI_Init(&argc, &argv);
>>
>>  MPI_Keyval_create(MPI_NULL_COPY_FN, free_KeyVal, &Key1,(void *) 0);
>>  MPI_Attr_put(MPI_COMM_SELF, Key1, &Val1);
>>  MPI_Keyval_free(&Key1);
>>
>>  MPI_Keyval_create(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &Key2,(void *)
>> 0);
>>  MPI_Attr_put(MPI_COMM_SELF, Key2, &Val2);
>>  MPI_Keyval_free(&Key2);
>>
>>  MPI_Finalize();
>>
>>  return 0;
>> }
>>
>>
>> --
>> Lisandro Dalcín
>> ---------------
>> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>> Tel/Fax: +54-(0)342-451.1594
>
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594


More information about the mpich2-dev mailing list