This source file includes following definitions.
- module_max_constructor
- module_max_destructor
- max_float
- max_double
- max_real
- max_double_precision
- ompi_op_example_setup_max
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include "ompi_config.h"
27
28 #include "opal/class/opal_object.h"
29 #include "opal/util/output.h"
30
31 #include "ompi/constants.h"
32 #include "ompi/op/op.h"
33 #include "ompi/mca/op/op.h"
34 #include "ompi/mca/op/base/base.h"
35 #include "ompi/mca/op/example/op_example.h"
36
37
38
39
40
41
42
43 typedef struct {
44 ompi_op_base_module_1_0_0_t super;
45
46
47
48
49
50
51
52
53
54
55
56 ompi_op_base_handler_fn_t fallback_float;
57 ompi_op_base_module_t *fallback_float_module;
58 ompi_op_base_handler_fn_t fallback_real;
59 ompi_op_base_module_t *fallback_real_module;
60
61 ompi_op_base_handler_fn_t fallback_double;
62 ompi_op_base_module_t *fallback_double_module;
63 ompi_op_base_handler_fn_t fallback_double_precision;
64 ompi_op_base_module_t *fallback_double_precision_module;
65 } module_max_t;
66
67
68
69
70 static void module_max_constructor(module_max_t *m)
71 {
72
73
74
75 m->fallback_float = NULL;
76 m->fallback_float_module = NULL;
77 m->fallback_real = NULL;
78 m->fallback_real_module = NULL;
79
80 m->fallback_double = NULL;
81 m->fallback_double_module = NULL;
82 m->fallback_double_precision = NULL;
83 m->fallback_double_precision_module = NULL;
84 }
85
86
87
88
89 static void module_max_destructor(module_max_t *m)
90 {
91
92
93
94
95 m->fallback_float = (ompi_op_base_handler_fn_t) 0xdeadbeef;
96 m->fallback_float_module = (ompi_op_base_module_t*) 0xdeadbeef;
97 m->fallback_real = (ompi_op_base_handler_fn_t) 0xdeadbeef;
98 m->fallback_real_module = (ompi_op_base_module_t*) 0xdeadbeef;
99
100 m->fallback_double = (ompi_op_base_handler_fn_t) 0xdeadbeef;
101 m->fallback_double_module = (ompi_op_base_module_t*) 0xdeadbeef;
102 m->fallback_double_precision = (ompi_op_base_handler_fn_t) 0xdeadbeef;
103 m->fallback_double_precision_module = (ompi_op_base_module_t*) 0xdeadbeef;
104 }
105
106
107
108
109
110
111
112
113 static OBJ_CLASS_INSTANCE(module_max_t,
114 ompi_op_base_module_t,
115 module_max_constructor,
116 module_max_destructor);
117
118
119
120
121 static void max_float(void *in, void *out, int *count,
122 ompi_datatype_t **type, ompi_op_base_module_t *module)
123 {
124 module_max_t *m = (module_max_t*) module;
125
126
127
128 opal_output(0, "In example max float function");
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 m->fallback_float(in, out, count, type, m->fallback_float_module);
150 }
151
152
153
154
155 static void max_double(void *in, void *out, int *count,
156 ompi_datatype_t **type, ompi_op_base_module_t *module)
157 {
158 module_max_t *m = (module_max_t*) module;
159 opal_output(0, "In example max double function");
160
161
162
163 m->fallback_double(in, out, count, type, m->fallback_double_module);
164 }
165
166
167
168
169 static void max_real(void *in, void *out, int *count,
170 ompi_datatype_t **type, ompi_op_base_module_t *module)
171 {
172 module_max_t *m = (module_max_t*) module;
173 opal_output(0, "In example max real function");
174
175
176
177 m->fallback_real(in, out, count, type, m->fallback_real_module);
178 }
179
180
181
182
183 static void max_double_precision(void *in, void *out, int *count,
184 ompi_datatype_t **type,
185 ompi_op_base_module_t *module)
186 {
187 module_max_t *m = (module_max_t*) module;
188 opal_output(0, "In example max double precision function");
189
190
191
192 m->fallback_double_precision(in, out, count, type,
193 m->fallback_double_precision_module);
194 }
195
196
197
198
199
200
201
202
203 ompi_op_base_module_t *ompi_op_example_setup_max(ompi_op_t *op)
204 {
205 module_max_t *module = OBJ_NEW(module_max_t);
206
207
208
209
210
211
212
213
214
215
216 module->super.opm_fns[OMPI_OP_BASE_TYPE_FLOAT] = max_float;
217 module->fallback_float = op->o_func.intrinsic.fns[OMPI_OP_BASE_TYPE_FLOAT];
218 module->fallback_float_module =
219 op->o_func.intrinsic.modules[OMPI_OP_BASE_TYPE_FLOAT];
220
221
222
223 OBJ_RETAIN(module->fallback_float_module);
224
225
226 module->super.opm_fns[OMPI_OP_BASE_TYPE_REAL] = max_real;
227 module->fallback_real =
228 op->o_func.intrinsic.fns[OMPI_OP_BASE_TYPE_REAL];
229 module->fallback_real_module =
230 op->o_func.intrinsic.modules[OMPI_OP_BASE_TYPE_REAL];
231 OBJ_RETAIN(module->fallback_real_module);
232
233
234
235 if (mca_op_example_component.double_supported) {
236
237 module->super.opm_fns[OMPI_OP_BASE_TYPE_DOUBLE] = max_double;
238 module->fallback_double =
239 op->o_func.intrinsic.fns[OMPI_OP_BASE_TYPE_DOUBLE];
240 module->fallback_double_module =
241 op->o_func.intrinsic.modules[OMPI_OP_BASE_TYPE_DOUBLE];
242 OBJ_RETAIN(module->fallback_double_module);
243
244
245 module->super.opm_fns[OMPI_OP_BASE_TYPE_DOUBLE_PRECISION] =
246 max_double_precision;
247 module->fallback_double_precision =
248 op->o_func.intrinsic.fns[OMPI_OP_BASE_TYPE_DOUBLE_PRECISION];
249 module->fallback_double_precision_module =
250 op->o_func.intrinsic.modules[OMPI_OP_BASE_TYPE_DOUBLE_PRECISION];
251 OBJ_RETAIN(module->fallback_double_precision_module);
252 }
253
254
255
256
257 return (ompi_op_base_module_t*) module;
258 }