[mpich-discuss] [PATCH v2] test: add attrdeleteget, MPI_Attr_get called from delete_fn

Pavan Balaji balaji at mcs.anl.gov
Sat May 18 11:20:39 CDT 2013


Hi Jed,

You should use MPI_COMM_CREATE_KEYVAL and MPI_COMM_GET_ATTR.
KEYVAL_CREATE and ATTR_GET are deprecated.

I'm not sure I understand the program.  If the comm is invalidated
before the delete_fn is called, this is erroneous.  But if it is
invalidated after the delete_fn is called, this is valid.  So what
exactly are you trying to do?

 -- Pavan

On 05/17/2013 11:52 PM US Central Time, Jed Brown wrote:
> With MS-MPI 64-bit from HPC Pack 2008 and 2012, MPI_Attr_get returns
> error code 773 when called from delete_fn on a communicator obtained
> from MPI_Comm_split.
> 
> Signed-off-by: Jed Brown <jedbrown at mcs.anl.gov>
> Signed-off-by: Satish Balay <balay at mcs.anl.gov>
> ---
> Updated to propagate the error code from MPI_Attr_get.
> 
>  test/mpi/.gitignore           |  1 +
>  test/mpi/attr/Makefile.am     |  1 +
>  test/mpi/attr/attrdeleteget.c | 36 ++++++++++++++++++++++++++++++++++++
>  test/mpi/attr/testlist        |  1 +
>  4 files changed, 39 insertions(+)
>  create mode 100644 test/mpi/attr/attrdeleteget.c
> 
> diff --git a/test/mpi/.gitignore b/test/mpi/.gitignore
> index 3aadba2..0bdcd15 100644
> --- a/test/mpi/.gitignore
> +++ b/test/mpi/.gitignore
> @@ -51,6 +51,7 @@
>  /attr/attrerr
>  /attr/attrerrcomm
>  /attr/attrerrtype
> +/attr/attrdeleteget
>  /attr/attric
>  /attr/attrorder
>  /attr/attrordercomm
> diff --git a/test/mpi/attr/Makefile.am b/test/mpi/attr/Makefile.am
> index a672192..e1d788b 100644
> --- a/test/mpi/attr/Makefile.am
> +++ b/test/mpi/attr/Makefile.am
> @@ -18,6 +18,7 @@ noinst_PROGRAMS =      \
>      attrerr            \
>      attrerrcomm        \
>      attrerrtype        \
> +    attrdeleteget      \
>      attr2type          \
>      attrorder          \
>      attrordercomm      \
> diff --git a/test/mpi/attr/attrdeleteget.c b/test/mpi/attr/attrdeleteget.c
> new file mode 100644
> index 0000000..05afaa4
> --- /dev/null
> +++ b/test/mpi/attr/attrdeleteget.c
> @@ -0,0 +1,36 @@
> +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
> +/*
> + *
> + *  (C) 2013 by Argonne National Laboratory.
> + *      See COPYRIGHT in top-level directory.
> + */
> +
> +#include <stdio.h>
> +#include "mpi.h"
> +#include "mpitest.h"
> +
> +int key = MPI_KEYVAL_INVALID;
> +char a[100];
> +
> +int delete_fn (MPI_Comm, int, void *, void *);
> +
> +int main(int argc,char **argv)
> +{
> +  MPI_Comm scomm;
> +
> +  MTest_Init(&argc,&argv);
> +  MPI_Comm_split(MPI_COMM_WORLD,1,0,&scomm);
> +  MPI_Keyval_create(MPI_NULL_COPY_FN,delete_fn,&key,(void*)0);
> +  MPI_Attr_put(scomm,key,a);
> +  MPI_Comm_free(&scomm);
> +  MPI_Finalize();
> +  return 0;
> +}
> +
> +int delete_fn(MPI_Comm comm,int keyval,void *attr_val,void *extra_state)
> +{
> +  int   flg;
> +  void  *ptr;
> +
> +  return MPI_Attr_get(comm,key,&ptr,&flg);
> +}
> diff --git a/test/mpi/attr/testlist b/test/mpi/attr/testlist
> index 61bd613..4db94df 100644
> --- a/test/mpi/attr/testlist
> +++ b/test/mpi/attr/testlist
> @@ -7,6 +7,7 @@ attrend2 1
>  attrend2 5
>  attrerrcomm 1
>  attrerrtype 1
> +attrdeleteget 1
>  attr2type 1
>  attrorder 1
>  attrordercomm 1
> 

-- 
Pavan Balaji
http://www.mcs.anl.gov/~balaji



More information about the discuss mailing list