This source file includes following definitions.
- Free
- do_create_keyval
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #include "mpi.h"
16 #include "ompi/mpi/cxx/mpicxx.h"
17 #include "ompi/constants.h"
18 #include "cxx_glue.h"
19
20 void
21 MPI::Datatype::Free()
22 {
23 (void)MPI_Type_free(&mpi_datatype);
24 }
25
26 int
27 MPI::Datatype::do_create_keyval(MPI_Type_copy_attr_function* c_copy_fn,
28 MPI_Type_delete_attr_function* c_delete_fn,
29 Copy_attr_function* cxx_copy_fn,
30 Delete_attr_function* cxx_delete_fn,
31 void* extra_state, int &keyval)
32 {
33 int ret, count = 0;
34 keyval_intercept_data_t *cxx_extra_state;
35
36
37
38 if (NULL != c_copy_fn && NULL != c_delete_fn) {
39 ret = ompi_cxx_attr_create_keyval_type (c_copy_fn, c_delete_fn, &keyval,
40 extra_state, 0, NULL);
41 if (MPI_SUCCESS != ret) {
42 return ompi_cxx_errhandler_invoke_comm (MPI_COMM_WORLD, ret,
43 "MPI::Datatype::Create_keyval");
44 }
45 }
46
47
48
49
50
51
52
53
54 cxx_extra_state = (keyval_intercept_data_t *) malloc(sizeof(*cxx_extra_state));
55 if (NULL == cxx_extra_state) {
56 return ompi_cxx_errhandler_invoke_comm (MPI_COMM_WORLD, MPI_ERR_NO_MEM,
57 "MPI::Datatype::Create_keyval");
58 }
59
60 cxx_extra_state->c_copy_fn = c_copy_fn;
61 cxx_extra_state->cxx_copy_fn = cxx_copy_fn;
62 cxx_extra_state->c_delete_fn = c_delete_fn;
63 cxx_extra_state->cxx_delete_fn = cxx_delete_fn;
64 cxx_extra_state->extra_state = extra_state;
65
66
67 if (NULL != c_copy_fn) {
68 ++count;
69 }
70 if (NULL != c_delete_fn) {
71 ++count;
72 }
73 if (NULL != cxx_copy_fn) {
74 ++count;
75 }
76 if (NULL != cxx_delete_fn) {
77 ++count;
78 }
79 if (2 != count) {
80 free(cxx_extra_state);
81 return ompi_cxx_errhandler_invoke_comm (MPI_COMM_WORLD, MPI_ERR_ARG,
82 "MPI::Datatype::Create_keyval");
83 }
84
85
86
87
88
89
90
91
92
93
94 ret = ompi_cxx_attr_create_keyval_type ((MPI_Type_copy_attr_function *) ompi_mpi_cxx_type_copy_attr_intercept,
95 ompi_mpi_cxx_type_delete_attr_intercept, &keyval,
96 cxx_extra_state, 0, NULL);
97 if (OMPI_SUCCESS != ret) {
98 return ompi_cxx_errhandler_invoke_comm (MPI_COMM_WORLD, ret,
99 "MPI::Datatype::Create_keyval");
100 }
101
102 return MPI_SUCCESS;
103 }