This source file includes following definitions.
- Create_errhandler
- do_create_keyval
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include "mpi.h"
25 #include "ompi/constants.h"
26 #include "ompi/mpi/cxx/mpicxx.h"
27 #include "cxx_glue.h"
28
29
30
31
32
33
34
35
36
37
38
39
40
41 MPI::Comm::Comm()
42 {
43 }
44
45
46 MPI::Comm::Comm(const Comm_Null& data) : Comm_Null(data)
47 {
48 }
49
50
51 MPI::Errhandler
52 MPI::Comm::Create_errhandler(MPI::Comm::_MPI2CPP_ERRHANDLERFN_* function)
53 {
54 return ompi_cxx_errhandler_create_comm ((ompi_cxx_dummy_fn_t *) function);
55 }
56
57
58
59
60 int
61 MPI::Comm::do_create_keyval(MPI_Comm_copy_attr_function* c_copy_fn,
62 MPI_Comm_delete_attr_function* c_delete_fn,
63 Copy_attr_function* cxx_copy_fn,
64 Delete_attr_function* cxx_delete_fn,
65 void* extra_state, int &keyval)
66 {
67 int ret, count = 0;
68 keyval_intercept_data_t *cxx_extra_state;
69
70
71
72 if (NULL != c_copy_fn && NULL != c_delete_fn) {
73 ret = ompi_cxx_attr_create_keyval_comm (c_copy_fn, c_delete_fn, &keyval,
74 extra_state, 0, NULL);
75 if (MPI_SUCCESS != ret) {
76 return ompi_cxx_errhandler_invoke_comm(MPI_COMM_WORLD, ret,
77 "MPI::Comm::Create_keyval");
78 }
79 }
80
81
82
83
84
85
86
87
88
89
90 cxx_extra_state = (keyval_intercept_data_t*)
91 malloc(sizeof(keyval_intercept_data_t));
92 if (NULL == cxx_extra_state) {
93 return ompi_cxx_errhandler_invoke_comm (MPI_COMM_WORLD, MPI_ERR_NO_MEM,
94 "MPI::Comm::Create_keyval");
95 }
96 cxx_extra_state->c_copy_fn = c_copy_fn;
97 cxx_extra_state->cxx_copy_fn = cxx_copy_fn;
98 cxx_extra_state->c_delete_fn = c_delete_fn;
99 cxx_extra_state->cxx_delete_fn = cxx_delete_fn;
100 cxx_extra_state->extra_state = extra_state;
101
102
103 if (NULL != c_copy_fn) {
104 ++count;
105 }
106 if (NULL != c_delete_fn) {
107 ++count;
108 }
109 if (NULL != cxx_copy_fn) {
110 ++count;
111 }
112 if (NULL != cxx_delete_fn) {
113 ++count;
114 }
115 if (2 != count) {
116 free(cxx_extra_state);
117 return ompi_cxx_errhandler_invoke_comm (MPI_COMM_WORLD, MPI_ERR_ARG,
118 "MPI::Comm::Create_keyval");
119 }
120
121
122
123
124
125 ret = ompi_cxx_attr_create_keyval_comm ((MPI_Comm_copy_attr_function *) ompi_mpi_cxx_comm_copy_attr_intercept,
126 ompi_mpi_cxx_comm_delete_attr_intercept,
127 &keyval, cxx_extra_state, 0, cxx_extra_state);
128 if (OMPI_SUCCESS != ret) {
129 return ompi_cxx_errhandler_invoke_comm (MPI_COMM_WORLD, ret,
130 "MPI::Comm::Create_keyval");
131 }
132
133 return MPI_SUCCESS;
134 }
135