1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2007 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
11 static int foo_keyval = MPI_KEYVAL_INVALID;
13 int foo_initialize(void);
14 void foo_finalize(void);
16 int foo_copy_attr_function(MPI_Datatype type, int type_keyval,
17 void *extra_state, void *attribute_val_in,
18 void *attribute_val_out, int *flag);
19 int foo_delete_attr_function(MPI_Datatype type, int type_keyval,
20 void *attribute_val, void *extra_state);
21 static const char *my_func = 0;
22 static int verbose = 0;
23 static int delete_called = 0;
24 static int copy_called = 0;
26 int main(int argc, char *argv[])
28 MPI_Datatype type, duptype;
31 MPI_Init(&argc, &argv);
33 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
37 MPI_Type_contiguous(2, MPI_INT, &type);
39 MPI_Type_set_attr(type, foo_keyval, NULL);
41 MPI_Type_dup(type, &duptype);
43 my_func = "Free of type";
46 my_func = "free of duptype";
47 MPI_Type_free(&duptype);
53 if (copy_called != 1) {
54 printf("Copy called %d times; expected once\n", copy_called);
57 if (delete_called != 2) {
58 printf("Delete called %d times; expected twice\n", delete_called);
62 printf(" No Errors\n");
65 printf(" Found %d errors\n", errs);
74 int foo_copy_attr_function(MPI_Datatype type,
77 void *attribute_val_in, void *attribute_val_out, int *flag)
80 printf("copy fn. called\n");
82 *(char **) attribute_val_out = NULL;
88 int foo_delete_attr_function(MPI_Datatype type,
89 int type_keyval, void *attribute_val, void *extra_state)
92 printf("delete fn. called in %s\n", my_func);
98 int foo_initialize(void)
100 /* create keyval for use later */
101 MPI_Type_create_keyval(foo_copy_attr_function,
102 foo_delete_attr_function, &foo_keyval, NULL);
104 printf("created keyval\n");
109 void foo_finalize(void)
112 MPI_Type_free_keyval(&foo_keyval);
115 printf("freed keyval\n");