File: op.c

package info (click to toggle)
openmpi 3.1.3-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 118,572 kB
  • sloc: ansic: 628,972; f90: 17,993; makefile: 13,761; sh: 7,051; java: 6,360; perl: 3,215; cpp: 2,225; python: 1,350; lex: 988; fortran: 52; tcl: 12
file content (487 lines) | stat: -rw-r--r-- 22,414 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
/*
 * Copyright (c) 2013      Mellanox Technologies, Inc.
 *                         All rights reserved.
 * Copyright (c) 2013      Cisco Systems, Inc.  All rights reserved.
 * Copyright (c) 2015      Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "oshmem_config.h"
#include <complex.h>

#include "orte/runtime/orte_globals.h"

#include "opal/datatype/opal_datatype_internal.h"
#include "opal/class/opal_pointer_array.h"

#include "oshmem/constants.h"
#include "oshmem/op/op.h"

/*
 * Table for op handle conversion
 */
opal_pointer_array_t oshmem_op_array = {{0}};

/*
 * Class information
 */
static void oshmem_op_construct(oshmem_op_t *object);
static void oshmem_op_destruct(oshmem_op_t *object);

/*
 * Class instance
 */
OBJ_CLASS_INSTANCE(oshmem_op_t,
                   opal_object_t,
                   oshmem_op_construct,
                   oshmem_op_destruct);

/*
 * Intrinsic Operation objects
 */
/* Bitwise AND */
oshmem_op_t* oshmem_op_and_short = NULL;
oshmem_op_t* oshmem_op_and_int = NULL;
oshmem_op_t* oshmem_op_and_long = NULL;
oshmem_op_t* oshmem_op_and_longlong = NULL;
oshmem_op_t* oshmem_op_and_fint2 = NULL;
oshmem_op_t* oshmem_op_and_fint4 = NULL;
oshmem_op_t* oshmem_op_and_fint8 = NULL;
oshmem_op_t* oshmem_op_and_int16 = NULL;
oshmem_op_t* oshmem_op_and_int32 = NULL;
oshmem_op_t* oshmem_op_and_int64 = NULL;

/* Bitwise OR */
oshmem_op_t* oshmem_op_or_short = NULL;
oshmem_op_t* oshmem_op_or_int = NULL;
oshmem_op_t* oshmem_op_or_long = NULL;
oshmem_op_t* oshmem_op_or_longlong = NULL;
oshmem_op_t* oshmem_op_or_fint2 = NULL;
oshmem_op_t* oshmem_op_or_fint4 = NULL;
oshmem_op_t* oshmem_op_or_fint8 = NULL;
oshmem_op_t* oshmem_op_or_int16 = NULL;
oshmem_op_t* oshmem_op_or_int32 = NULL;
oshmem_op_t* oshmem_op_or_int64 = NULL;

/* Bitwise XOR */
oshmem_op_t* oshmem_op_xor_short = NULL;
oshmem_op_t* oshmem_op_xor_int = NULL;
oshmem_op_t* oshmem_op_xor_long = NULL;
oshmem_op_t* oshmem_op_xor_longlong = NULL;
oshmem_op_t* oshmem_op_xor_fint2 = NULL;
oshmem_op_t* oshmem_op_xor_fint4 = NULL;
oshmem_op_t* oshmem_op_xor_fint8 = NULL;
oshmem_op_t* oshmem_op_xor_int16 = NULL;
oshmem_op_t* oshmem_op_xor_int32 = NULL;
oshmem_op_t* oshmem_op_xor_int64 = NULL;

/* MAX */
oshmem_op_t* oshmem_op_max_short = NULL;
oshmem_op_t* oshmem_op_max_int = NULL;
oshmem_op_t* oshmem_op_max_long = NULL;
oshmem_op_t* oshmem_op_max_longlong = NULL;
oshmem_op_t* oshmem_op_max_float = NULL;
oshmem_op_t* oshmem_op_max_double = NULL;
oshmem_op_t* oshmem_op_max_longdouble = NULL;
oshmem_op_t* oshmem_op_max_fint2 = NULL;
oshmem_op_t* oshmem_op_max_fint4 = NULL;
oshmem_op_t* oshmem_op_max_fint8 = NULL;
oshmem_op_t* oshmem_op_max_freal4 = NULL;
oshmem_op_t* oshmem_op_max_freal8 = NULL;
oshmem_op_t* oshmem_op_max_freal16 = NULL;
oshmem_op_t* oshmem_op_max_int16 = NULL;
oshmem_op_t* oshmem_op_max_int32 = NULL;
oshmem_op_t* oshmem_op_max_int64 = NULL;

/* MIN */
oshmem_op_t* oshmem_op_min_short = NULL;
oshmem_op_t* oshmem_op_min_int = NULL;
oshmem_op_t* oshmem_op_min_long = NULL;
oshmem_op_t* oshmem_op_min_longlong = NULL;
oshmem_op_t* oshmem_op_min_float = NULL;
oshmem_op_t* oshmem_op_min_double = NULL;
oshmem_op_t* oshmem_op_min_longdouble = NULL;
oshmem_op_t* oshmem_op_min_fint2 = NULL;
oshmem_op_t* oshmem_op_min_fint4 = NULL;
oshmem_op_t* oshmem_op_min_fint8 = NULL;
oshmem_op_t* oshmem_op_min_freal4 = NULL;
oshmem_op_t* oshmem_op_min_freal8 = NULL;
oshmem_op_t* oshmem_op_min_freal16 = NULL;
oshmem_op_t* oshmem_op_min_int16 = NULL;
oshmem_op_t* oshmem_op_min_int32 = NULL;
oshmem_op_t* oshmem_op_min_int64 = NULL;

/* SUM */
oshmem_op_t* oshmem_op_sum_short = NULL;
oshmem_op_t* oshmem_op_sum_int = NULL;
oshmem_op_t* oshmem_op_sum_long = NULL;
oshmem_op_t* oshmem_op_sum_longlong = NULL;
oshmem_op_t* oshmem_op_sum_float = NULL;
oshmem_op_t* oshmem_op_sum_double = NULL;
oshmem_op_t* oshmem_op_sum_longdouble = NULL;
oshmem_op_t* oshmem_op_sum_complexf = NULL;
oshmem_op_t* oshmem_op_sum_complexd = NULL;
oshmem_op_t* oshmem_op_sum_fint2 = NULL;
oshmem_op_t* oshmem_op_sum_fint4 = NULL;
oshmem_op_t* oshmem_op_sum_fint8 = NULL;
oshmem_op_t* oshmem_op_sum_freal4 = NULL;
oshmem_op_t* oshmem_op_sum_freal8 = NULL;
oshmem_op_t* oshmem_op_sum_freal16 = NULL;
oshmem_op_t* oshmem_op_sum_int16 = NULL;
oshmem_op_t* oshmem_op_sum_int32 = NULL;
oshmem_op_t* oshmem_op_sum_int64 = NULL;

/* PROD */
oshmem_op_t* oshmem_op_prod_short = NULL;
oshmem_op_t* oshmem_op_prod_int = NULL;
oshmem_op_t* oshmem_op_prod_long = NULL;
oshmem_op_t* oshmem_op_prod_longlong = NULL;
oshmem_op_t* oshmem_op_prod_float = NULL;
oshmem_op_t* oshmem_op_prod_double = NULL;
oshmem_op_t* oshmem_op_prod_longdouble = NULL;
oshmem_op_t* oshmem_op_prod_complexf = NULL;
oshmem_op_t* oshmem_op_prod_complexd = NULL;
oshmem_op_t* oshmem_op_prod_fint2 = NULL;
oshmem_op_t* oshmem_op_prod_fint4 = NULL;
oshmem_op_t* oshmem_op_prod_fint8 = NULL;
oshmem_op_t* oshmem_op_prod_freal4 = NULL;
oshmem_op_t* oshmem_op_prod_freal8 = NULL;
oshmem_op_t* oshmem_op_prod_freal16 = NULL;
oshmem_op_t* oshmem_op_prod_int16 = NULL;
oshmem_op_t* oshmem_op_prod_int32 = NULL;
oshmem_op_t* oshmem_op_prod_int64 = NULL;

#define FUNC_OP_CREATE(name, type_name, type, calc)  \
    void oshmem_op_##name##_##type_name##_func(void *in, void *out, int count); \
    void oshmem_op_##name##_##type_name##_func(void *in, void *out, int count) \
    {                                                                       \
        int i;                                                              \
        type *a = (type *) in;                                              \
        type *b = (type *) out;                                             \
        for (i = 0; i < count; ++i) {                                       \
            *(b) = calc(*(b), *(a));                                        \
            ++b;                                                            \
            ++a;                                                            \
        }                                                                   \
    }

#define OBJ_OP_CREATE(name, type_name, type, op_id, dt_id)  \
    oshmem_op_##name##_##type_name = OBJ_NEW(oshmem_op_t);                                      \
    if (oshmem_op_##name##_##type_name)                                                         \
    {                                                                                           \
        oshmem_op_##name##_##type_name->op = op_id;                                             \
        oshmem_op_##name##_##type_name->dt = dt_id;                                             \
        oshmem_op_##name##_##type_name->dt_size = sizeof(type);                                 \
        oshmem_op_##name##_##type_name->o_func.c_fn = oshmem_op_##name##_##type_name##_func;    \
    }                                                                                           \

/* Bitwise AND */
#define __and_op(a, b) ((a) & (b))
FUNC_OP_CREATE(and, short, short, __and_op)
FUNC_OP_CREATE(and, int, int, __and_op)
FUNC_OP_CREATE(and, long, long, __and_op)
FUNC_OP_CREATE(and, longlong, long long, __and_op)
FUNC_OP_CREATE(and, fint2, ompi_fortran_integer4_t, __and_op)
FUNC_OP_CREATE(and, fint4, ompi_fortran_integer4_t, __and_op)
FUNC_OP_CREATE(and, fint8, ompi_fortran_integer8_t, __and_op)
FUNC_OP_CREATE(and, int16, int16_t, __and_op)
FUNC_OP_CREATE(and, int32, int32_t, __and_op)
FUNC_OP_CREATE(and, int64, int64_t, __and_op)

/* Bitwise OR */
#define __or_op(a, b) ((a) | (b))
FUNC_OP_CREATE(or, short, short, __or_op)
FUNC_OP_CREATE(or, int, int, __or_op)
FUNC_OP_CREATE(or, long, long, __or_op)
FUNC_OP_CREATE(or, longlong, long long, __or_op)
FUNC_OP_CREATE(or, fint2, ompi_fortran_integer2_t, __or_op)
FUNC_OP_CREATE(or, fint4, ompi_fortran_integer4_t, __or_op)
FUNC_OP_CREATE(or, fint8, ompi_fortran_integer8_t, __or_op)
FUNC_OP_CREATE(or, int16, int16_t, __or_op)
FUNC_OP_CREATE(or, int32, int32_t, __or_op)
FUNC_OP_CREATE(or, int64, int64_t, __or_op)

/* Bitwise XOR */
#define __xor_op(a, b) ((a) ^ (b))
FUNC_OP_CREATE(xor, short, short, __xor_op)
FUNC_OP_CREATE(xor, int, int, __xor_op)
FUNC_OP_CREATE(xor, long, long, __xor_op)
FUNC_OP_CREATE(xor, longlong, long long, __xor_op)
FUNC_OP_CREATE(xor, fint2, ompi_fortran_integer4_t, __xor_op)
FUNC_OP_CREATE(xor, fint4, ompi_fortran_integer4_t, __xor_op)
FUNC_OP_CREATE(xor, fint8, ompi_fortran_integer8_t, __xor_op)
FUNC_OP_CREATE(xor, int16, int16_t, __xor_op)
FUNC_OP_CREATE(xor, int32, int32_t, __xor_op)
FUNC_OP_CREATE(xor, int64, int64_t, __xor_op)

/* MAX */
#define __max_op(a, b) ((a) > (b) ? (a) : (b))
FUNC_OP_CREATE(max, short, short, __max_op)
FUNC_OP_CREATE(max, int, int, __max_op)
FUNC_OP_CREATE(max, long, long, __max_op)
FUNC_OP_CREATE(max, longlong, long long, __max_op)
FUNC_OP_CREATE(max, float, float, __max_op)
FUNC_OP_CREATE(max, double, double, __max_op)
FUNC_OP_CREATE(max, longdouble, long double, __max_op)
FUNC_OP_CREATE(max, fint2, ompi_fortran_integer4_t, __max_op)
FUNC_OP_CREATE(max, fint4, ompi_fortran_integer4_t, __max_op)
FUNC_OP_CREATE(max, fint8, ompi_fortran_integer8_t, __max_op)
FUNC_OP_CREATE(max, freal4, ompi_fortran_real4_t, __max_op)
FUNC_OP_CREATE(max, freal8, ompi_fortran_real8_t, __max_op)
#if OMPI_HAVE_FORTRAN_REAL16
FUNC_OP_CREATE(max, freal16, ompi_fortran_real16_t, __max_op)
#endif
FUNC_OP_CREATE(max, int16, int16_t, __max_op)
FUNC_OP_CREATE(max, int32, int32_t, __max_op)
FUNC_OP_CREATE(max, int64, int64_t, __max_op)

/* MIN */
#define __min_op(a, b) ((a) < (b) ? (a) : (b))
FUNC_OP_CREATE(min, short, short, __min_op)
FUNC_OP_CREATE(min, int, int, __min_op)
FUNC_OP_CREATE(min, long, long, __min_op)
FUNC_OP_CREATE(min, longlong, long long, __min_op)
FUNC_OP_CREATE(min, float, float, __min_op)
FUNC_OP_CREATE(min, double, double, __min_op)
FUNC_OP_CREATE(min, longdouble, long double, __min_op)
FUNC_OP_CREATE(min, fint2, ompi_fortran_integer4_t, __min_op)
FUNC_OP_CREATE(min, fint4, ompi_fortran_integer4_t, __min_op)
FUNC_OP_CREATE(min, fint8, ompi_fortran_integer8_t, __min_op)
FUNC_OP_CREATE(min, freal4, ompi_fortran_real4_t, __min_op)
FUNC_OP_CREATE(min, freal8, ompi_fortran_real8_t, __min_op)
#if OMPI_HAVE_FORTRAN_REAL16
FUNC_OP_CREATE(min, freal16, ompi_fortran_real16_t, __min_op)
#endif
FUNC_OP_CREATE(min, int16, int16_t, __min_op)
FUNC_OP_CREATE(min, int32, int32_t, __min_op)
FUNC_OP_CREATE(min, int64, int64_t, __min_op)

/* SUM */
#define __sum_op(a, b) ((a) + (b))
FUNC_OP_CREATE(sum, short, short, __sum_op)
FUNC_OP_CREATE(sum, int, int, __sum_op)
FUNC_OP_CREATE(sum, long, long, __sum_op)
FUNC_OP_CREATE(sum, longlong, long long, __sum_op)
FUNC_OP_CREATE(sum, float, float, __sum_op)
FUNC_OP_CREATE(sum, double, double, __sum_op)
FUNC_OP_CREATE(sum, longdouble, long double, __sum_op)
FUNC_OP_CREATE(sum, complexf, float complex, __sum_op)
FUNC_OP_CREATE(sum, complexd, double complex, __sum_op)
FUNC_OP_CREATE(sum, fint2, ompi_fortran_integer4_t, __sum_op)
FUNC_OP_CREATE(sum, fint4, ompi_fortran_integer4_t, __sum_op)
FUNC_OP_CREATE(sum, fint8, ompi_fortran_integer8_t, __sum_op)
FUNC_OP_CREATE(sum, freal4, ompi_fortran_real4_t, __sum_op)
FUNC_OP_CREATE(sum, freal8, ompi_fortran_real8_t, __sum_op)
#if OMPI_HAVE_FORTRAN_REAL16
FUNC_OP_CREATE(sum, freal16, ompi_fortran_real16_t, __sum_op)
#endif
FUNC_OP_CREATE(sum, int16, int16_t, __sum_op)
FUNC_OP_CREATE(sum, int32, int32_t, __sum_op)
FUNC_OP_CREATE(sum, int64, int64_t, __sum_op)

/* PROD */
#define __prod_op(a, b) ((a) * (b))
FUNC_OP_CREATE(prod, short, short, __prod_op)
FUNC_OP_CREATE(prod, int, int, __prod_op)
FUNC_OP_CREATE(prod, long, long, __prod_op)
FUNC_OP_CREATE(prod, longlong, long long, __prod_op)
FUNC_OP_CREATE(prod, float, float, __prod_op)
FUNC_OP_CREATE(prod, double, double, __prod_op)
FUNC_OP_CREATE(prod, longdouble, long double, __prod_op)
FUNC_OP_CREATE(prod, complexf, float complex, __prod_op)
FUNC_OP_CREATE(prod, complexd, double complex, __prod_op)
FUNC_OP_CREATE(prod, fint2, ompi_fortran_integer2_t, __prod_op)
FUNC_OP_CREATE(prod, fint4, ompi_fortran_integer4_t, __prod_op)
FUNC_OP_CREATE(prod, fint8, ompi_fortran_integer8_t, __prod_op)
FUNC_OP_CREATE(prod, freal4, ompi_fortran_real4_t, __prod_op)
FUNC_OP_CREATE(prod, freal8, ompi_fortran_real8_t, __prod_op)
#if OMPI_HAVE_FORTRAN_REAL16
FUNC_OP_CREATE(prod, freal16, ompi_fortran_real16_t, __prod_op)
#endif
FUNC_OP_CREATE(prod, int16, int16_t, __prod_op)
FUNC_OP_CREATE(prod, int32, int32_t, __prod_op)
FUNC_OP_CREATE(prod, int64, int64_t, __prod_op)

int oshmem_op_init(void)
{

    /* Setup operation array */
    OBJ_CONSTRUCT(&oshmem_op_array, opal_pointer_array_t);
    if (OPAL_SUCCESS
            != opal_pointer_array_init(&oshmem_op_array,
                                       0,
                                       ORTE_GLOBAL_ARRAY_MAX_SIZE,
                                       1)) {
        return OSHMEM_ERROR;
    }

    /* Bitwise AND */
    OBJ_OP_CREATE(and, short, short, OSHMEM_OP_AND, OSHMEM_OP_TYPE_SHORT);
    OBJ_OP_CREATE(and, int, int, OSHMEM_OP_AND, OSHMEM_OP_TYPE_INT);
    OBJ_OP_CREATE(and, long, long, OSHMEM_OP_AND, OSHMEM_OP_TYPE_LONG);
    OBJ_OP_CREATE(and, longlong, long long, OSHMEM_OP_AND, OSHMEM_OP_TYPE_LLONG);
    OBJ_OP_CREATE(and, fint2, ompi_fortran_integer2_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_FINT2);
    OBJ_OP_CREATE(and, fint4, ompi_fortran_integer4_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_FINT4);
    OBJ_OP_CREATE(and, fint8, ompi_fortran_integer8_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_FINT8);
    OBJ_OP_CREATE(and, int16, int16_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_INT16_T);
    OBJ_OP_CREATE(and, int32, int32_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_INT32_T);
    OBJ_OP_CREATE(and, int64, int64_t, OSHMEM_OP_AND, OSHMEM_OP_TYPE_INT64_T);

    /* Bitwise OR */
    OBJ_OP_CREATE(or, short, short, OSHMEM_OP_OR, OSHMEM_OP_TYPE_SHORT);
    OBJ_OP_CREATE(or, int, int, OSHMEM_OP_OR, OSHMEM_OP_TYPE_INT);
    OBJ_OP_CREATE(or, long, long, OSHMEM_OP_OR, OSHMEM_OP_TYPE_LONG);
    OBJ_OP_CREATE(or, longlong, long long, OSHMEM_OP_OR, OSHMEM_OP_TYPE_LLONG);
    OBJ_OP_CREATE(or, fint2, ompi_fortran_integer2_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_FINT2);
    OBJ_OP_CREATE(or, fint4, ompi_fortran_integer4_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_FINT4);
    OBJ_OP_CREATE(or, fint8, ompi_fortran_integer8_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_FINT8);
    OBJ_OP_CREATE(or, int16, int16_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_INT16_T);
    OBJ_OP_CREATE(or, int32, int32_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_INT32_T);
    OBJ_OP_CREATE(or, int64, int64_t, OSHMEM_OP_OR, OSHMEM_OP_TYPE_INT64_T);

    /* Bitwise XOR */
    OBJ_OP_CREATE(xor, short, short, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_SHORT);
    OBJ_OP_CREATE(xor, int, int, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_INT);
    OBJ_OP_CREATE(xor, long, long, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_LONG);
    OBJ_OP_CREATE(xor, longlong, long long, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_LLONG);
    OBJ_OP_CREATE(xor, fint2, ompi_fortran_integer2_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_FINT2);
    OBJ_OP_CREATE(xor, fint4, ompi_fortran_integer4_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_FINT4);
    OBJ_OP_CREATE(xor, fint8, ompi_fortran_integer8_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_FINT8);
    OBJ_OP_CREATE(xor, int16, int16_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_INT16_T);
    OBJ_OP_CREATE(xor, int32, int32_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_INT32_T);
    OBJ_OP_CREATE(xor, int64, int64_t, OSHMEM_OP_XOR, OSHMEM_OP_TYPE_INT64_T);

    /* MAX */
    OBJ_OP_CREATE(max, short, short, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_SHORT);
    OBJ_OP_CREATE(max, int, int, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_INT);
    OBJ_OP_CREATE(max, long, long, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_LONG);
    OBJ_OP_CREATE(max, longlong, long long, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_LLONG);
    OBJ_OP_CREATE(max, float, float, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FLOAT);
    OBJ_OP_CREATE(max, double, double, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_DOUBLE);
    OBJ_OP_CREATE(max, longdouble, long double, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_LDOUBLE);
    OBJ_OP_CREATE(max, fint2, ompi_fortran_integer2_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FINT2);
    OBJ_OP_CREATE(max, fint4, ompi_fortran_integer4_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FINT4);
    OBJ_OP_CREATE(max, fint8, ompi_fortran_integer8_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FINT8);
    OBJ_OP_CREATE(max, freal4, ompi_fortran_real4_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FREAL4);
    OBJ_OP_CREATE(max, freal8, ompi_fortran_real8_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FREAL8);
#if OMPI_HAVE_FORTRAN_REAL16
    OBJ_OP_CREATE(max, freal16, ompi_fortran_real16_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_FREAL16);
#endif
    OBJ_OP_CREATE(max, int16, int16_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_INT16_T);
    OBJ_OP_CREATE(max, int32, int32_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_INT32_T);
    OBJ_OP_CREATE(max, int64, int64_t, OSHMEM_OP_MAX, OSHMEM_OP_TYPE_INT64_T);

    /* MIN */
    OBJ_OP_CREATE(min, short, short, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_SHORT);
    OBJ_OP_CREATE(min, int, int, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_INT);
    OBJ_OP_CREATE(min, long, long, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_LONG);
    OBJ_OP_CREATE(min, longlong, long long, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_LLONG);
    OBJ_OP_CREATE(min, float, float, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FLOAT);
    OBJ_OP_CREATE(min, double, double, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_DOUBLE);
    OBJ_OP_CREATE(min, longdouble, long double, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_LDOUBLE);
    OBJ_OP_CREATE(min, fint2, ompi_fortran_integer2_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FINT2);
    OBJ_OP_CREATE(min, fint4, ompi_fortran_integer4_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FINT4);
    OBJ_OP_CREATE(min, fint8, ompi_fortran_integer8_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FINT8);
    OBJ_OP_CREATE(min, freal4, ompi_fortran_real4_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FREAL4);
    OBJ_OP_CREATE(min, freal8, ompi_fortran_real8_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FREAL8);
#if OMPI_HAVE_FORTRAN_REAL16
    OBJ_OP_CREATE(min, freal16, ompi_fortran_real16_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_FREAL16);
#endif
    OBJ_OP_CREATE(min, int16, int16_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_INT16_T);
    OBJ_OP_CREATE(min, int32, int32_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_INT32_T);
    OBJ_OP_CREATE(min, int64, int64_t, OSHMEM_OP_MIN, OSHMEM_OP_TYPE_INT64_T);

    /* SUM */
    OBJ_OP_CREATE(sum, short, short, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_SHORT);
    OBJ_OP_CREATE(sum, int, int, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_INT);
    OBJ_OP_CREATE(sum, long, long, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_LONG);
    OBJ_OP_CREATE(sum, longlong, long long, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_LLONG);
    OBJ_OP_CREATE(sum, float, float, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FLOAT);
    OBJ_OP_CREATE(sum, double, double, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_DOUBLE);
    OBJ_OP_CREATE(sum, longdouble, long double, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_LDOUBLE);
    OBJ_OP_CREATE(sum, complexf, float complex, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FCOMPLEX);
    OBJ_OP_CREATE(sum, complexd, double complex, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_DCOMPLEX);
    OBJ_OP_CREATE(sum, fint2, ompi_fortran_integer2_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FINT2);
    OBJ_OP_CREATE(sum, fint4, ompi_fortran_integer4_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FINT4);
    OBJ_OP_CREATE(sum, fint8, ompi_fortran_integer8_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FINT8);
    OBJ_OP_CREATE(sum, freal4, ompi_fortran_real4_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FREAL4);
    OBJ_OP_CREATE(sum, freal8, ompi_fortran_real8_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FREAL8);
#if OMPI_HAVE_FORTRAN_REAL16
    OBJ_OP_CREATE(sum, freal16, ompi_fortran_real16_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_FREAL16);
#endif
    OBJ_OP_CREATE(sum, int16, int16_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_INT16_T);
    OBJ_OP_CREATE(sum, int32, int32_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_INT32_T);
    OBJ_OP_CREATE(sum, int64, int64_t, OSHMEM_OP_SUM, OSHMEM_OP_TYPE_INT64_T);

    /* PROD */
    OBJ_OP_CREATE(prod, short, short, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_SHORT);
    OBJ_OP_CREATE(prod, int, int, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_INT);
    OBJ_OP_CREATE(prod, long, long, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_LONG);
    OBJ_OP_CREATE(prod, longlong, long long, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_LLONG);
    OBJ_OP_CREATE(prod, float, float, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FLOAT);
    OBJ_OP_CREATE(prod, double, double, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_DOUBLE);
    OBJ_OP_CREATE(prod, longdouble, long double, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_LDOUBLE);
    OBJ_OP_CREATE(prod, complexf, float complex, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FCOMPLEX);
    OBJ_OP_CREATE(prod, complexd, double complex, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_DCOMPLEX);
    OBJ_OP_CREATE(prod, fint2, ompi_fortran_integer2_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FINT2);
    OBJ_OP_CREATE(prod, fint4, ompi_fortran_integer4_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FINT4);
    OBJ_OP_CREATE(prod, fint8, ompi_fortran_integer8_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FINT8);
    OBJ_OP_CREATE(prod, freal4, ompi_fortran_real4_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FREAL4);
    OBJ_OP_CREATE(prod, freal8, ompi_fortran_real8_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FREAL8);
#if OMPI_HAVE_FORTRAN_REAL16
    OBJ_OP_CREATE(prod, freal16, ompi_fortran_real16_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_FREAL16);
#endif
    OBJ_OP_CREATE(prod, int16, int16_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_INT16_T);
    OBJ_OP_CREATE(prod, int32, int32_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_INT32_T);
    OBJ_OP_CREATE(prod, int64, int64_t, OSHMEM_OP_PROD, OSHMEM_OP_TYPE_INT64_T);

    return OSHMEM_SUCCESS;
}

int oshmem_op_finalize(void)
{
    int max, i;
    oshmem_op_t *op;

    /* Check whether we have some left */
    max = opal_pointer_array_get_size(&oshmem_op_array);
    for (i = 0; i < max; i++) {
        op = (oshmem_op_t *) opal_pointer_array_get_item(&oshmem_op_array, i);
        if (NULL != op) {
            OBJ_RELEASE(op);
        }
    }

    OBJ_DESTRUCT(&oshmem_op_array);

    return OSHMEM_SUCCESS;
}

/**************************************************************************
 *
 * Static functions
 *
 **************************************************************************/

/*
 * Op constructor
 */
static void oshmem_op_construct(oshmem_op_t *object)
{
    object->id = opal_pointer_array_add(&oshmem_op_array, object);
}

/*
 * Op destructor
 */
static void oshmem_op_destruct(oshmem_op_t *object)
{
    if (NULL != opal_pointer_array_get_item(&oshmem_op_array, object->id)) {
        opal_pointer_array_set_item(&oshmem_op_array, object->id, NULL );
    }
}