X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9b73466ada27682d1729f394549479da83ef4a99..5ffbdb20797e6741e7b0b4b68a3f733bd32d45c5:/teshsuite/smpi/mpich3-test/attr/fkeyvaltype.c diff --git a/teshsuite/smpi/mpich3-test/attr/fkeyvaltype.c b/teshsuite/smpi/mpich3-test/attr/fkeyvaltype.c index 392e51dec3..55f172512d 100644 --- a/teshsuite/smpi/mpich3-test/attr/fkeyvaltype.c +++ b/teshsuite/smpi/mpich3-test/attr/fkeyvaltype.c @@ -16,34 +16,30 @@ executed"; */ /* Copy increments the attribute value */ -int copy_fn( MPI_Datatype oldtype, int keyval, void *extra_state, - void *attribute_val_in, void *attribute_val_out, - int *flag); -int copy_fn( MPI_Datatype oldtype, int keyval, void *extra_state, - void *attribute_val_in, void *attribute_val_out, - int *flag) +int copy_fn(MPI_Datatype oldtype, int keyval, void *extra_state, + void *attribute_val_in, void *attribute_val_out, int *flag); +int copy_fn(MPI_Datatype oldtype, int keyval, void *extra_state, + void *attribute_val_in, void *attribute_val_out, int *flag) { /* Copy the address of the attribute */ - *(void **)attribute_val_out = attribute_val_in; + *(void **) attribute_val_out = attribute_val_in; /* Change the value */ - *(int *)attribute_val_in = *(int *)attribute_val_in + 1; + *(int *) attribute_val_in = *(int *) attribute_val_in + 1; /* set flag to 1 to tell comm dup to insert this attribute - into the new communicator */ + * into the new communicator */ *flag = 1; return MPI_SUCCESS; } /* Delete decrements the attribute value */ -int delete_fn( MPI_Datatype type, int keyval, void *attribute_val, - void *extra_state); -int delete_fn( MPI_Datatype type, int keyval, void *attribute_val, - void *extra_state) +int delete_fn(MPI_Datatype type, int keyval, void *attribute_val, void *extra_state); +int delete_fn(MPI_Datatype type, int keyval, void *attribute_val, void *extra_state) { - *(int *)attribute_val = *(int *)attribute_val - 1; + *(int *) attribute_val = *(int *) attribute_val - 1; return MPI_SUCCESS; } -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0; int attrval; @@ -53,75 +49,70 @@ int main( int argc, char *argv[] ) char typename[MPI_MAX_OBJECT_NAME]; int tnlen; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - while (MTestGetDatatypes( &mstype, &mrtype, 1 )) { - type = mstype.datatype; - MPI_Type_create_keyval( copy_fn, delete_fn, &keyval, (void *)0 ); - saveKeyval = keyval; /* in case we need to free explicitly */ - attrval = 1; - MPI_Type_set_attr( type, keyval, (void*)&attrval ); - /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it - is in use in an attribute */ - MPI_Type_free_keyval( &keyval ); - - /* We create some dummy keyvals here in case the same keyval - is reused */ - for (i=0; i<32; i++) { - MPI_Type_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, - &key[i], (void *)0 ); - } + while (MTestGetDatatypes(&mstype, &mrtype, 1)) { + type = mstype.datatype; + MPI_Type_create_keyval(copy_fn, delete_fn, &keyval, (void *) 0); + saveKeyval = keyval; /* in case we need to free explicitly */ + attrval = 1; + MPI_Type_set_attr(type, keyval, (void *) &attrval); + /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it + * is in use in an attribute */ + MPI_Type_free_keyval(&keyval); - if (attrval != 1) { - errs++; - MPI_Type_get_name( type, typename, &tnlen ); - printf( "attrval is %d, should be 1, before dup in type %s\n", - attrval, typename ); - } - MPI_Type_dup( type, &duptype ); - /* Check that the attribute was copied */ - if (attrval != 2) { - errs++; - MPI_Type_get_name( type, typename, &tnlen ); - printf( "Attribute not incremented when type dup'ed (%s)\n", - typename ); - } - MPI_Type_free( &duptype ); - if (attrval != 1) { - errs++; - MPI_Type_get_name( type, typename, &tnlen ); - printf( "Attribute not decremented when duptype %s freed\n", - typename ); - } - /* Check that the attribute was freed in the duptype */ + /* We create some dummy keyvals here in case the same keyval + * is reused */ + for (i = 0; i < 1; i++) { + MPI_Type_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0); + } - if (!mstype.isBasic) { - MPI_Type_get_name( type, typename, &tnlen ); + if (attrval != 1) { + errs++; + MPI_Type_get_name(type, typename, &tnlen); + printf("attrval is %d, should be 1, before dup in type %s\n", attrval, typename); + } + MPI_Type_dup(type, &duptype); + /* Check that the attribute was copied */ + if (attrval != 2) { + errs++; + MPI_Type_get_name(type, typename, &tnlen); + printf("Attribute not incremented when type dup'ed (%s)\n", typename); + } + MPI_Type_free(&duptype); + if (attrval != 1) { + errs++; + MPI_Type_get_name(type, typename, &tnlen); + printf("Attribute not decremented when duptype %s freed\n", typename); + } + /* Check that the attribute was freed in the duptype */ + + if (!mstype.isBasic) { + MPI_Type_get_name(type, typename, &tnlen); MTestFreeDatatype(&mstype); - /* Check that the original attribute was freed */ - if (attrval != 0) { - errs++; - printf( "Attribute not decremented when type %s freed\n", - typename ); - } - } - else { - /* Explicitly delete the attributes from world and self */ - MPI_Type_delete_attr( type, saveKeyval ); + /* Check that the original attribute was freed */ + if (attrval != 0) { + errs++; + printf("Attribute not decremented when type %s freed\n", typename); + } + } + else { + /* Explicitly delete the attributes from world and self */ + MPI_Type_delete_attr(type, saveKeyval); if (mstype.buf) { free(mstype.buf); mstype.buf = 0; } - } - /* Free those other keyvals */ - for (i=0; i<32; i++) { - MPI_Type_free_keyval( &key[i] ); - } + } + /* Free those other keyvals */ + for (i = 0; i < 1; i++) { + MPI_Type_free_keyval(&key[i]); + } MTestFreeDatatype(&mrtype); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; - + }