1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #include <mpi.h>
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include "mpitest.h"
10
11 /* tests multiple invocations of MPI_Type_free_keyval on the same keyval */
12
13 int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra);
delete_fn(MPI_Comm comm,int keyval,void * attr,void * extra)14 int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra)
15 {
16 MPI_Type_free_keyval(&keyval);
17 return MPI_SUCCESS;
18 }
19
main(int argc,char ** argv)20 int main(int argc, char **argv)
21 {
22 MPI_Datatype type;
23 MPI_Datatype type_dup;
24 int keyval = MPI_KEYVAL_INVALID;
25 int keyval_copy = MPI_KEYVAL_INVALID;
26 int errs = 0;
27
28 MTest_Init(&argc, &argv);
29 MPI_Type_dup(MPI_INT, &type);
30 MPI_Type_dup(MPI_INT, &type_dup);
31
32 MPI_Type_create_keyval(MPI_TYPE_NULL_COPY_FN, delete_fn, &keyval, NULL);
33 keyval_copy = keyval;
34 MPI_Type_set_attr(type, keyval, NULL);
35 MPI_Type_set_attr(type_dup, keyval, NULL);
36
37 MPI_Type_free(&type); /* first MPI_Type_free_keyval */
38 MPI_Type_free_keyval(&keyval); /* second MPI_Type_free_keyval */
39 MPI_Type_free_keyval(&keyval_copy); /* third MPI_Type_free_keyval */
40 MPI_Type_free(&type_dup); /* fourth MPI_Type_free_keyval */
41 MTest_Finalize(errs);
42 return MTestReturnValue(errs);
43 }
44