root/ompi/mca/op/base/op_base_functions.c

/* [<][>][^][v][top][bottom][index][help] */
   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2010 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2006-2014 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2013      Los Alamos National Security, LLC. All rights
  15  *                         reserved.
  16  * Copyright (c) 2018      FUJITSU LIMITED.  All rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 
  24 #include "ompi_config.h"
  25 
  26 #ifdef HAVE_SYS_TYPES_H
  27 #include <sys/types.h>
  28 #endif
  29 
  30 #include "ompi/mca/op/op.h"
  31 
  32 
  33 /*
  34  * Since all the functions in this file are essentially identical, we
  35  * use a macro to substitute in names and types.  The core operation
  36  * in all functions that use this macro is the same.
  37  *
  38  * This macro is for (out op in).
  39  */
  40 #define OP_FUNC(name, type_name, type, op) \
  41   static void ompi_op_base_2buff_##name##_##type_name(void *in, void *out, int *count, \
  42                                                       struct ompi_datatype_t **dtype, \
  43                                                       struct ompi_op_base_module_1_0_0_t *module) \
  44   {                                                                      \
  45       int i;                                                             \
  46       type *a = (type *) in;                                             \
  47       type *b = (type *) out;                                            \
  48       for (i = 0; i < *count; ++i) {                                     \
  49           *(b++) op *(a++);                                              \
  50       }                                                                  \
  51   }
  52 
  53 /*
  54  * Since all the functions in this file are essentially identical, we
  55  * use a macro to substitute in names and types.  The core operation
  56  * in all functions that use this macro is the same.
  57  *
  58  * This macro is for (out = op(out, in))
  59  */
  60 #define FUNC_FUNC(name, type_name, type) \
  61   static void ompi_op_base_2buff_##name##_##type_name(void *in, void *out, int *count, \
  62                                                 struct ompi_datatype_t **dtype, \
  63                                                 struct ompi_op_base_module_1_0_0_t *module) \
  64   {                                                                      \
  65       int i;                                                             \
  66       type *a = (type *) in;                                             \
  67       type *b = (type *) out;                                            \
  68       for (i = 0; i < *count; ++i) {                                     \
  69           *(b) = current_func(*(b), *(a));                               \
  70           ++b;                                                           \
  71           ++a;                                                           \
  72       }                                                                  \
  73   }
  74 
  75 /*
  76  * Since all the functions in this file are essentially identical, we
  77  * use a macro to substitute in names and types.  The core operation
  78  * in all functions that use this macro is the same.
  79  *
  80  * This macro is for minloc and maxloc
  81  */
  82 #define LOC_STRUCT(type_name, type1, type2) \
  83   typedef struct { \
  84       type1 v; \
  85       type2 k; \
  86   } ompi_op_predefined_##type_name##_t;
  87 
  88 #define LOC_FUNC(name, type_name, op) \
  89     static void ompi_op_base_2buff_##name##_##type_name(void *in, void *out, int *count, \
  90                                                         struct ompi_datatype_t **dtype, \
  91                                                         struct ompi_op_base_module_1_0_0_t *module) \
  92     {                                                                   \
  93         int i;                                                          \
  94         ompi_op_predefined_##type_name##_t *a = (ompi_op_predefined_##type_name##_t*) in; \
  95         ompi_op_predefined_##type_name##_t *b = (ompi_op_predefined_##type_name##_t*) out; \
  96         for (i = 0; i < *count; ++i, ++a, ++b) {                        \
  97             if (a->v op b->v) {                                         \
  98                 b->v = a->v;                                            \
  99                 b->k = a->k;                                            \
 100             } else if (a->v == b->v) {                                  \
 101                 b->k = (b->k < a->k ? b->k : a->k);                     \
 102             }                                                           \
 103         }                                                               \
 104     }
 105 
 106 /*
 107  * Define a function to calculate sum of complex numbers using a real
 108  * number floating-point type (float, double, etc.).  This macro is used
 109  * when the compiler supports a real number floating-point type but does
 110  * not supports the corresponding complex number type.
 111  */
 112 #define COMPLEX_SUM_FUNC(type_name, type) \
 113   static void ompi_op_base_2buff_sum_##type_name(void *in, void *out, int *count, \
 114                                                  struct ompi_datatype_t **dtype, \
 115                                                  struct ompi_op_base_module_1_0_0_t *module) \
 116   {                                                                      \
 117       int i;                                                             \
 118       type (*a)[2] = (type (*)[2]) in;                                   \
 119       type (*b)[2] = (type (*)[2]) out;                                  \
 120       for (i = 0; i < *count; ++i, ++a, ++b) {                           \
 121           (*b)[0] += (*a)[0];                                            \
 122           (*b)[1] += (*a)[1];                                            \
 123       }                                                                  \
 124   }
 125 
 126 /*
 127  * Define a function to calculate product of complex numbers using a real
 128  * number floating-point type (float, double, etc.).  This macro is used
 129  * when the compiler supports a real number floating-point type but does
 130  * not supports the corresponding complex number type.
 131  */
 132 #define COMPLEX_PROD_FUNC(type_name, type) \
 133   static void ompi_op_base_2buff_prod_##type_name(void *in, void *out, int *count, \
 134                                                   struct ompi_datatype_t **dtype, \
 135                                                   struct ompi_op_base_module_1_0_0_t *module) \
 136   {                                                                      \
 137       int i;                                                             \
 138       type (*a)[2] = (type (*)[2]) in;                                   \
 139       type (*b)[2] = (type (*)[2]) out;                                  \
 140       type c[2];                                                         \
 141       for (i = 0; i < *count; ++i, ++a, ++b) {                           \
 142           c[0] = (*a)[0] * (*b)[0] - (*a)[1] * (*b)[1];                  \
 143           c[1] = (*a)[0] * (*b)[1] + (*a)[1] * (*b)[0];                  \
 144           (*b)[0] = c[0];                                                \
 145           (*b)[1] = c[1];                                                \
 146       }                                                                  \
 147   }
 148 
 149 /*************************************************************************
 150  * Max
 151  *************************************************************************/
 152 
 153 #undef current_func
 154 #define current_func(a, b) ((a) > (b) ? (a) : (b))
 155 /* C integer */
 156 FUNC_FUNC(max,   int8_t,   int8_t)
 157 FUNC_FUNC(max,  uint8_t,  uint8_t)
 158 FUNC_FUNC(max,  int16_t,  int16_t)
 159 FUNC_FUNC(max, uint16_t, uint16_t)
 160 FUNC_FUNC(max,  int32_t,  int32_t)
 161 FUNC_FUNC(max, uint32_t, uint32_t)
 162 FUNC_FUNC(max,  int64_t,  int64_t)
 163 FUNC_FUNC(max, uint64_t, uint64_t)
 164 /* Fortran integer */
 165 #if OMPI_HAVE_FORTRAN_INTEGER
 166 FUNC_FUNC(max, fortran_integer, ompi_fortran_integer_t)
 167 #endif
 168 #if OMPI_HAVE_FORTRAN_INTEGER1
 169 FUNC_FUNC(max, fortran_integer1, ompi_fortran_integer1_t)
 170 #endif
 171 #if OMPI_HAVE_FORTRAN_INTEGER2
 172 FUNC_FUNC(max, fortran_integer2, ompi_fortran_integer2_t)
 173 #endif
 174 #if OMPI_HAVE_FORTRAN_INTEGER4
 175 FUNC_FUNC(max, fortran_integer4, ompi_fortran_integer4_t)
 176 #endif
 177 #if OMPI_HAVE_FORTRAN_INTEGER8
 178 FUNC_FUNC(max, fortran_integer8, ompi_fortran_integer8_t)
 179 #endif
 180 #if OMPI_HAVE_FORTRAN_INTEGER16
 181 FUNC_FUNC(max, fortran_integer16, ompi_fortran_integer16_t)
 182 #endif
 183 /* Floating point */
 184 #if defined(HAVE_SHORT_FLOAT)
 185 FUNC_FUNC(max, short_float, short float)
 186 #elif defined(HAVE_OPAL_SHORT_FLOAT_T)
 187 FUNC_FUNC(max, short_float, opal_short_float_t)
 188 #endif
 189 FUNC_FUNC(max, float, float)
 190 FUNC_FUNC(max, double, double)
 191 FUNC_FUNC(max, long_double, long double)
 192 #if OMPI_HAVE_FORTRAN_REAL
 193 FUNC_FUNC(max, fortran_real, ompi_fortran_real_t)
 194 #endif
 195 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 196 FUNC_FUNC(max, fortran_double_precision, ompi_fortran_double_precision_t)
 197 #endif
 198 #if OMPI_HAVE_FORTRAN_REAL2
 199 FUNC_FUNC(max, fortran_real2, ompi_fortran_real2_t)
 200 #endif
 201 #if OMPI_HAVE_FORTRAN_REAL4
 202 FUNC_FUNC(max, fortran_real4, ompi_fortran_real4_t)
 203 #endif
 204 #if OMPI_HAVE_FORTRAN_REAL8
 205 FUNC_FUNC(max, fortran_real8, ompi_fortran_real8_t)
 206 #endif
 207 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
 208 FUNC_FUNC(max, fortran_real16, ompi_fortran_real16_t)
 209 #endif
 210 
 211 
 212 /*************************************************************************
 213  * Min
 214  *************************************************************************/
 215 
 216 #undef current_func
 217 #define current_func(a, b) ((a) < (b) ? (a) : (b))
 218 /* C integer */
 219 FUNC_FUNC(min,   int8_t,   int8_t)
 220 FUNC_FUNC(min,  uint8_t,  uint8_t)
 221 FUNC_FUNC(min,  int16_t,  int16_t)
 222 FUNC_FUNC(min, uint16_t, uint16_t)
 223 FUNC_FUNC(min,  int32_t,  int32_t)
 224 FUNC_FUNC(min, uint32_t, uint32_t)
 225 FUNC_FUNC(min,  int64_t,  int64_t)
 226 FUNC_FUNC(min, uint64_t, uint64_t)
 227 /* Fortran integer */
 228 #if OMPI_HAVE_FORTRAN_INTEGER
 229 FUNC_FUNC(min, fortran_integer, ompi_fortran_integer_t)
 230 #endif
 231 #if OMPI_HAVE_FORTRAN_INTEGER1
 232 FUNC_FUNC(min, fortran_integer1, ompi_fortran_integer1_t)
 233 #endif
 234 #if OMPI_HAVE_FORTRAN_INTEGER2
 235 FUNC_FUNC(min, fortran_integer2, ompi_fortran_integer2_t)
 236 #endif
 237 #if OMPI_HAVE_FORTRAN_INTEGER4
 238 FUNC_FUNC(min, fortran_integer4, ompi_fortran_integer4_t)
 239 #endif
 240 #if OMPI_HAVE_FORTRAN_INTEGER8
 241 FUNC_FUNC(min, fortran_integer8, ompi_fortran_integer8_t)
 242 #endif
 243 #if OMPI_HAVE_FORTRAN_INTEGER16
 244 FUNC_FUNC(min, fortran_integer16, ompi_fortran_integer16_t)
 245 #endif
 246 /* Floating point */
 247 #if defined(HAVE_SHORT_FLOAT)
 248 FUNC_FUNC(min, short_float, short float)
 249 #elif defined(HAVE_OPAL_SHORT_FLOAT_T)
 250 FUNC_FUNC(min, short_float, opal_short_float_t)
 251 #endif
 252 FUNC_FUNC(min, float, float)
 253 FUNC_FUNC(min, double, double)
 254 FUNC_FUNC(min, long_double, long double)
 255 #if OMPI_HAVE_FORTRAN_REAL
 256 FUNC_FUNC(min, fortran_real, ompi_fortran_real_t)
 257 #endif
 258 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 259 FUNC_FUNC(min, fortran_double_precision, ompi_fortran_double_precision_t)
 260 #endif
 261 #if OMPI_HAVE_FORTRAN_REAL2
 262 FUNC_FUNC(min, fortran_real2, ompi_fortran_real2_t)
 263 #endif
 264 #if OMPI_HAVE_FORTRAN_REAL4
 265 FUNC_FUNC(min, fortran_real4, ompi_fortran_real4_t)
 266 #endif
 267 #if OMPI_HAVE_FORTRAN_REAL8
 268 FUNC_FUNC(min, fortran_real8, ompi_fortran_real8_t)
 269 #endif
 270 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
 271 FUNC_FUNC(min, fortran_real16, ompi_fortran_real16_t)
 272 #endif
 273 
 274 /*************************************************************************
 275  * Sum
 276  *************************************************************************/
 277 
 278 /* C integer */
 279 OP_FUNC(sum,   int8_t,   int8_t, +=)
 280 OP_FUNC(sum,  uint8_t,  uint8_t, +=)
 281 OP_FUNC(sum,  int16_t,  int16_t, +=)
 282 OP_FUNC(sum, uint16_t, uint16_t, +=)
 283 OP_FUNC(sum,  int32_t,  int32_t, +=)
 284 OP_FUNC(sum, uint32_t, uint32_t, +=)
 285 OP_FUNC(sum,  int64_t,  int64_t, +=)
 286 OP_FUNC(sum, uint64_t, uint64_t, +=)
 287 /* Fortran integer */
 288 #if OMPI_HAVE_FORTRAN_INTEGER
 289 OP_FUNC(sum, fortran_integer, ompi_fortran_integer_t, +=)
 290 #endif
 291 #if OMPI_HAVE_FORTRAN_INTEGER1
 292 OP_FUNC(sum, fortran_integer1, ompi_fortran_integer1_t, +=)
 293 #endif
 294 #if OMPI_HAVE_FORTRAN_INTEGER2
 295 OP_FUNC(sum, fortran_integer2, ompi_fortran_integer2_t, +=)
 296 #endif
 297 #if OMPI_HAVE_FORTRAN_INTEGER4
 298 OP_FUNC(sum, fortran_integer4, ompi_fortran_integer4_t, +=)
 299 #endif
 300 #if OMPI_HAVE_FORTRAN_INTEGER8
 301 OP_FUNC(sum, fortran_integer8, ompi_fortran_integer8_t, +=)
 302 #endif
 303 #if OMPI_HAVE_FORTRAN_INTEGER16
 304 OP_FUNC(sum, fortran_integer16, ompi_fortran_integer16_t, +=)
 305 #endif
 306 /* Floating point */
 307 #if defined(HAVE_SHORT_FLOAT)
 308 OP_FUNC(sum, short_float, short float, +=)
 309 #elif defined(HAVE_OPAL_SHORT_FLOAT_T)
 310 OP_FUNC(sum, short_float, opal_short_float_t, +=)
 311 #endif
 312 OP_FUNC(sum, float, float, +=)
 313 OP_FUNC(sum, double, double, +=)
 314 OP_FUNC(sum, long_double, long double, +=)
 315 #if OMPI_HAVE_FORTRAN_REAL
 316 OP_FUNC(sum, fortran_real, ompi_fortran_real_t, +=)
 317 #endif
 318 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 319 OP_FUNC(sum, fortran_double_precision, ompi_fortran_double_precision_t, +=)
 320 #endif
 321 #if OMPI_HAVE_FORTRAN_REAL2
 322 OP_FUNC(sum, fortran_real2, ompi_fortran_real2_t, +=)
 323 #endif
 324 #if OMPI_HAVE_FORTRAN_REAL4
 325 OP_FUNC(sum, fortran_real4, ompi_fortran_real4_t, +=)
 326 #endif
 327 #if OMPI_HAVE_FORTRAN_REAL8
 328 OP_FUNC(sum, fortran_real8, ompi_fortran_real8_t, +=)
 329 #endif
 330 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
 331 OP_FUNC(sum, fortran_real16, ompi_fortran_real16_t, +=)
 332 #endif
 333 /* Complex */
 334 #if defined(HAVE_SHORT_FLOAT__COMPLEX)
 335 OP_FUNC(sum, c_short_float_complex, short float _Complex, +=)
 336 #elif defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
 337 COMPLEX_SUM_FUNC(c_short_float_complex, opal_short_float_t)
 338 #endif
 339 OP_FUNC(sum, c_float_complex, float _Complex, +=)
 340 OP_FUNC(sum, c_double_complex, double _Complex, +=)
 341 OP_FUNC(sum, c_long_double_complex, long double _Complex, +=)
 342 
 343 /*************************************************************************
 344  * Product
 345  *************************************************************************/
 346 
 347 /* C integer */
 348 OP_FUNC(prod,   int8_t,   int8_t, *=)
 349 OP_FUNC(prod,  uint8_t,  uint8_t, *=)
 350 OP_FUNC(prod,  int16_t,  int16_t, *=)
 351 OP_FUNC(prod, uint16_t, uint16_t, *=)
 352 OP_FUNC(prod,  int32_t,  int32_t, *=)
 353 OP_FUNC(prod, uint32_t, uint32_t, *=)
 354 OP_FUNC(prod,  int64_t,  int64_t, *=)
 355 OP_FUNC(prod, uint64_t, uint64_t, *=)
 356 /* Fortran integer */
 357 #if OMPI_HAVE_FORTRAN_INTEGER
 358 OP_FUNC(prod, fortran_integer, ompi_fortran_integer_t, *=)
 359 #endif
 360 #if OMPI_HAVE_FORTRAN_INTEGER1
 361 OP_FUNC(prod, fortran_integer1, ompi_fortran_integer1_t, *=)
 362 #endif
 363 #if OMPI_HAVE_FORTRAN_INTEGER2
 364 OP_FUNC(prod, fortran_integer2, ompi_fortran_integer2_t, *=)
 365 #endif
 366 #if OMPI_HAVE_FORTRAN_INTEGER4
 367 OP_FUNC(prod, fortran_integer4, ompi_fortran_integer4_t, *=)
 368 #endif
 369 #if OMPI_HAVE_FORTRAN_INTEGER8
 370 OP_FUNC(prod, fortran_integer8, ompi_fortran_integer8_t, *=)
 371 #endif
 372 #if OMPI_HAVE_FORTRAN_INTEGER16
 373 OP_FUNC(prod, fortran_integer16, ompi_fortran_integer16_t, *=)
 374 #endif
 375 /* Floating point */
 376 #if defined(HAVE_SHORT_FLOAT)
 377 OP_FUNC(prod, short_float, short float, *=)
 378 #elif defined(HAVE_OPAL_SHORT_FLOAT_T)
 379 OP_FUNC(prod, short_float, opal_short_float_t, *=)
 380 #endif
 381 OP_FUNC(prod, float, float, *=)
 382 OP_FUNC(prod, double, double, *=)
 383 OP_FUNC(prod, long_double, long double, *=)
 384 #if OMPI_HAVE_FORTRAN_REAL
 385 OP_FUNC(prod, fortran_real, ompi_fortran_real_t, *=)
 386 #endif
 387 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 388 OP_FUNC(prod, fortran_double_precision, ompi_fortran_double_precision_t, *=)
 389 #endif
 390 #if OMPI_HAVE_FORTRAN_REAL2
 391 OP_FUNC(prod, fortran_real2, ompi_fortran_real2_t, *=)
 392 #endif
 393 #if OMPI_HAVE_FORTRAN_REAL4
 394 OP_FUNC(prod, fortran_real4, ompi_fortran_real4_t, *=)
 395 #endif
 396 #if OMPI_HAVE_FORTRAN_REAL8
 397 OP_FUNC(prod, fortran_real8, ompi_fortran_real8_t, *=)
 398 #endif
 399 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
 400 OP_FUNC(prod, fortran_real16, ompi_fortran_real16_t, *=)
 401 #endif
 402 /* Complex */
 403 #if defined(HAVE_SHORT_FLOAT__COMPLEX)
 404 OP_FUNC(prod, c_short_float_complex, short float _Complex, *=)
 405 #elif defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
 406 COMPLEX_PROD_FUNC(c_short_float_complex, opal_short_float_t)
 407 #endif
 408 OP_FUNC(prod, c_float_complex, float _Complex, *=)
 409 OP_FUNC(prod, c_double_complex, double _Complex, *=)
 410 OP_FUNC(prod, c_long_double_complex, long double _Complex, *=)
 411 
 412 /*************************************************************************
 413  * Logical AND
 414  *************************************************************************/
 415 
 416 #undef current_func
 417 #define current_func(a, b) ((a) && (b))
 418 /* C integer */
 419 FUNC_FUNC(land,   int8_t,   int8_t)
 420 FUNC_FUNC(land,  uint8_t,  uint8_t)
 421 FUNC_FUNC(land,  int16_t,  int16_t)
 422 FUNC_FUNC(land, uint16_t, uint16_t)
 423 FUNC_FUNC(land,  int32_t,  int32_t)
 424 FUNC_FUNC(land, uint32_t, uint32_t)
 425 FUNC_FUNC(land,  int64_t,  int64_t)
 426 FUNC_FUNC(land, uint64_t, uint64_t)
 427 /* Logical */
 428 #if OMPI_HAVE_FORTRAN_LOGICAL
 429 FUNC_FUNC(land, fortran_logical, ompi_fortran_logical_t)
 430 #endif
 431 /* C++ bool */
 432 FUNC_FUNC(land, bool, bool)
 433 
 434 /*************************************************************************
 435  * Logical OR
 436  *************************************************************************/
 437 
 438 #undef current_func
 439 #define current_func(a, b) ((a) || (b))
 440 /* C integer */
 441 FUNC_FUNC(lor,   int8_t,   int8_t)
 442 FUNC_FUNC(lor,  uint8_t,  uint8_t)
 443 FUNC_FUNC(lor,  int16_t,  int16_t)
 444 FUNC_FUNC(lor, uint16_t, uint16_t)
 445 FUNC_FUNC(lor,  int32_t,  int32_t)
 446 FUNC_FUNC(lor, uint32_t, uint32_t)
 447 FUNC_FUNC(lor,  int64_t,  int64_t)
 448 FUNC_FUNC(lor, uint64_t, uint64_t)
 449 /* Logical */
 450 #if OMPI_HAVE_FORTRAN_LOGICAL
 451 FUNC_FUNC(lor, fortran_logical, ompi_fortran_logical_t)
 452 #endif
 453 /* C++ bool */
 454 FUNC_FUNC(lor, bool, bool)
 455 
 456 /*************************************************************************
 457  * Logical XOR
 458  *************************************************************************/
 459 
 460 #undef current_func
 461 #define current_func(a, b) ((a ? 1 : 0) ^ (b ? 1: 0))
 462 /* C integer */
 463 FUNC_FUNC(lxor,   int8_t,   int8_t)
 464 FUNC_FUNC(lxor,  uint8_t,  uint8_t)
 465 FUNC_FUNC(lxor,  int16_t,  int16_t)
 466 FUNC_FUNC(lxor, uint16_t, uint16_t)
 467 FUNC_FUNC(lxor,  int32_t,  int32_t)
 468 FUNC_FUNC(lxor, uint32_t, uint32_t)
 469 FUNC_FUNC(lxor,  int64_t,  int64_t)
 470 FUNC_FUNC(lxor, uint64_t, uint64_t)
 471 /* Logical */
 472 #if OMPI_HAVE_FORTRAN_LOGICAL
 473 FUNC_FUNC(lxor, fortran_logical, ompi_fortran_logical_t)
 474 #endif
 475 /* C++ bool */
 476 FUNC_FUNC(lxor, bool, bool)
 477 
 478 /*************************************************************************
 479  * Bitwise AND
 480  *************************************************************************/
 481 
 482 #undef current_func
 483 #define current_func(a, b) ((a) & (b))
 484 /* C integer */
 485 FUNC_FUNC(band,   int8_t,   int8_t)
 486 FUNC_FUNC(band,  uint8_t,  uint8_t)
 487 FUNC_FUNC(band,  int16_t,  int16_t)
 488 FUNC_FUNC(band, uint16_t, uint16_t)
 489 FUNC_FUNC(band,  int32_t,  int32_t)
 490 FUNC_FUNC(band, uint32_t, uint32_t)
 491 FUNC_FUNC(band,  int64_t,  int64_t)
 492 FUNC_FUNC(band, uint64_t, uint64_t)
 493 /* Fortran integer */
 494 #if OMPI_HAVE_FORTRAN_INTEGER
 495 FUNC_FUNC(band, fortran_integer, ompi_fortran_integer_t)
 496 #endif
 497 #if OMPI_HAVE_FORTRAN_INTEGER1
 498 FUNC_FUNC(band, fortran_integer1, ompi_fortran_integer1_t)
 499 #endif
 500 #if OMPI_HAVE_FORTRAN_INTEGER2
 501 FUNC_FUNC(band, fortran_integer2, ompi_fortran_integer2_t)
 502 #endif
 503 #if OMPI_HAVE_FORTRAN_INTEGER4
 504 FUNC_FUNC(band, fortran_integer4, ompi_fortran_integer4_t)
 505 #endif
 506 #if OMPI_HAVE_FORTRAN_INTEGER8
 507 FUNC_FUNC(band, fortran_integer8, ompi_fortran_integer8_t)
 508 #endif
 509 #if OMPI_HAVE_FORTRAN_INTEGER16
 510 FUNC_FUNC(band, fortran_integer16, ompi_fortran_integer16_t)
 511 #endif
 512 /* Byte */
 513 FUNC_FUNC(band, byte, char)
 514 
 515 /*************************************************************************
 516  * Bitwise OR
 517  *************************************************************************/
 518 
 519 #undef current_func
 520 #define current_func(a, b) ((a) | (b))
 521 /* C integer */
 522 FUNC_FUNC(bor,   int8_t,   int8_t)
 523 FUNC_FUNC(bor,  uint8_t,  uint8_t)
 524 FUNC_FUNC(bor,  int16_t,  int16_t)
 525 FUNC_FUNC(bor, uint16_t, uint16_t)
 526 FUNC_FUNC(bor,  int32_t,  int32_t)
 527 FUNC_FUNC(bor, uint32_t, uint32_t)
 528 FUNC_FUNC(bor,  int64_t,  int64_t)
 529 FUNC_FUNC(bor, uint64_t, uint64_t)
 530 /* Fortran integer */
 531 #if OMPI_HAVE_FORTRAN_INTEGER
 532 FUNC_FUNC(bor, fortran_integer, ompi_fortran_integer_t)
 533 #endif
 534 #if OMPI_HAVE_FORTRAN_INTEGER1
 535 FUNC_FUNC(bor, fortran_integer1, ompi_fortran_integer1_t)
 536 #endif
 537 #if OMPI_HAVE_FORTRAN_INTEGER2
 538 FUNC_FUNC(bor, fortran_integer2, ompi_fortran_integer2_t)
 539 #endif
 540 #if OMPI_HAVE_FORTRAN_INTEGER4
 541 FUNC_FUNC(bor, fortran_integer4, ompi_fortran_integer4_t)
 542 #endif
 543 #if OMPI_HAVE_FORTRAN_INTEGER8
 544 FUNC_FUNC(bor, fortran_integer8, ompi_fortran_integer8_t)
 545 #endif
 546 #if OMPI_HAVE_FORTRAN_INTEGER16
 547 FUNC_FUNC(bor, fortran_integer16, ompi_fortran_integer16_t)
 548 #endif
 549 /* Byte */
 550 FUNC_FUNC(bor, byte, char)
 551 
 552 /*************************************************************************
 553  * Bitwise XOR
 554  *************************************************************************/
 555 
 556 #undef current_func
 557 #define current_func(a, b) ((a) ^ (b))
 558 /* C integer */
 559 FUNC_FUNC(bxor,   int8_t,   int8_t)
 560 FUNC_FUNC(bxor,  uint8_t,  uint8_t)
 561 FUNC_FUNC(bxor,  int16_t,  int16_t)
 562 FUNC_FUNC(bxor, uint16_t, uint16_t)
 563 FUNC_FUNC(bxor,  int32_t,  int32_t)
 564 FUNC_FUNC(bxor, uint32_t, uint32_t)
 565 FUNC_FUNC(bxor,  int64_t,  int64_t)
 566 FUNC_FUNC(bxor, uint64_t, uint64_t)
 567 /* Fortran integer */
 568 #if OMPI_HAVE_FORTRAN_INTEGER
 569 FUNC_FUNC(bxor, fortran_integer, ompi_fortran_integer_t)
 570 #endif
 571 #if OMPI_HAVE_FORTRAN_INTEGER1
 572 FUNC_FUNC(bxor, fortran_integer1, ompi_fortran_integer1_t)
 573 #endif
 574 #if OMPI_HAVE_FORTRAN_INTEGER2
 575 FUNC_FUNC(bxor, fortran_integer2, ompi_fortran_integer2_t)
 576 #endif
 577 #if OMPI_HAVE_FORTRAN_INTEGER4
 578 FUNC_FUNC(bxor, fortran_integer4, ompi_fortran_integer4_t)
 579 #endif
 580 #if OMPI_HAVE_FORTRAN_INTEGER8
 581 FUNC_FUNC(bxor, fortran_integer8, ompi_fortran_integer8_t)
 582 #endif
 583 #if OMPI_HAVE_FORTRAN_INTEGER16
 584 FUNC_FUNC(bxor, fortran_integer16, ompi_fortran_integer16_t)
 585 #endif
 586 /* Byte */
 587 FUNC_FUNC(bxor, byte, char)
 588 
 589 /*************************************************************************
 590  * Min and max location "pair" datatypes
 591  *************************************************************************/
 592 
 593 #if OMPI_HAVE_FORTRAN_REAL
 594 LOC_STRUCT(2real, ompi_fortran_real_t, ompi_fortran_real_t)
 595 #endif
 596 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 597 LOC_STRUCT(2double_precision, ompi_fortran_double_precision_t, ompi_fortran_double_precision_t)
 598 #endif
 599 #if OMPI_HAVE_FORTRAN_INTEGER
 600 LOC_STRUCT(2integer, ompi_fortran_integer_t, ompi_fortran_integer_t)
 601 #endif
 602 LOC_STRUCT(float_int, float, int)
 603 LOC_STRUCT(double_int, double, int)
 604 LOC_STRUCT(long_int, long, int)
 605 LOC_STRUCT(2int, int, int)
 606 LOC_STRUCT(short_int, short, int)
 607 LOC_STRUCT(long_double_int, long double, int)
 608 
 609 /*************************************************************************
 610  * Max location
 611  *************************************************************************/
 612 
 613 #if OMPI_HAVE_FORTRAN_REAL
 614 LOC_FUNC(maxloc, 2real, >)
 615 #endif
 616 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 617 LOC_FUNC(maxloc, 2double_precision, >)
 618 #endif
 619 #if OMPI_HAVE_FORTRAN_INTEGER
 620 LOC_FUNC(maxloc, 2integer, >)
 621 #endif
 622 LOC_FUNC(maxloc, float_int, >)
 623 LOC_FUNC(maxloc, double_int, >)
 624 LOC_FUNC(maxloc, long_int, >)
 625 LOC_FUNC(maxloc, 2int, >)
 626 LOC_FUNC(maxloc, short_int, >)
 627 LOC_FUNC(maxloc, long_double_int, >)
 628 
 629 /*************************************************************************
 630  * Min location
 631  *************************************************************************/
 632 
 633 #if OMPI_HAVE_FORTRAN_REAL
 634 LOC_FUNC(minloc, 2real, <)
 635 #endif
 636 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 637 LOC_FUNC(minloc, 2double_precision, <)
 638 #endif
 639 #if OMPI_HAVE_FORTRAN_INTEGER
 640 LOC_FUNC(minloc, 2integer, <)
 641 #endif
 642 LOC_FUNC(minloc, float_int, <)
 643 LOC_FUNC(minloc, double_int, <)
 644 LOC_FUNC(minloc, long_int, <)
 645 LOC_FUNC(minloc, 2int, <)
 646 LOC_FUNC(minloc, short_int, <)
 647 LOC_FUNC(minloc, long_double_int, <)
 648 
 649 
 650 /*
 651  *  This is a three buffer (2 input and 1 output) version of the reduction
 652  *    routines, needed for some optimizations.
 653  */
 654 #define OP_FUNC_3BUF(name, type_name, type, op) \
 655     static void ompi_op_base_3buff_##name##_##type_name(void * restrict in1,   \
 656                                                         void * restrict in2, void * restrict out, int *count, \
 657                                                         struct ompi_datatype_t **dtype, \
 658                                                         struct ompi_op_base_module_1_0_0_t *module) \
 659     {                                                                   \
 660         int i;                                                          \
 661         type *a1 = (type *) in1;                                        \
 662         type *a2 = (type *) in2;                                        \
 663         type *b = (type *) out;                                         \
 664         for (i = 0; i < *count; ++i) {                                  \
 665             *(b++) =  *(a1++) op *(a2++);                               \
 666         }                                                               \
 667     }
 668 
 669 /*
 670  * Since all the functions in this file are essentially identical, we
 671  * use a macro to substitute in names and types.  The core operation
 672  * in all functions that use this macro is the same.
 673  *
 674  * This macro is for (out = op(in1, in2))
 675  */
 676 #define FUNC_FUNC_3BUF(name, type_name, type)                           \
 677     static void ompi_op_base_3buff_##name##_##type_name(void * restrict in1, \
 678                                                         void * restrict in2, void * restrict out, int *count, \
 679                                                         struct ompi_datatype_t **dtype, \
 680                                                         struct ompi_op_base_module_1_0_0_t *module) \
 681     {                                                                   \
 682         int i;                                                          \
 683         type *a1 = (type *) in1;                                        \
 684         type *a2 = (type *) in2;                                        \
 685         type *b = (type *) out;                                         \
 686         for (i = 0; i < *count; ++i) {                                  \
 687             *(b) = current_func(*(a1), *(a2));                          \
 688             ++b;                                                        \
 689             ++a1;                                                       \
 690             ++a2;                                                       \
 691         }                                                               \
 692     }
 693 
 694 /*
 695  * Since all the functions in this file are essentially identical, we
 696  * use a macro to substitute in names and types.  The core operation
 697  * in all functions that use this macro is the same.
 698  *
 699  * This macro is for minloc and maxloc
 700  */
 701 /*
 702 #define LOC_STRUCT(type_name, type1, type2) \
 703   typedef struct { \
 704       type1 v; \
 705       type2 k; \
 706   } ompi_op_predefined_##type_name##_t;
 707 */
 708 
 709 #define LOC_FUNC_3BUF(name, type_name, op) \
 710   static void ompi_op_base_3buff_##name##_##type_name(void * restrict in1,      \
 711                                                       void * restrict in2, void * restrict out, int *count, \
 712                                                       struct ompi_datatype_t **dtype, \
 713                                                       struct ompi_op_base_module_1_0_0_t *module) \
 714   {                                                                     \
 715       int i;                                                            \
 716       ompi_op_predefined_##type_name##_t *a1 = (ompi_op_predefined_##type_name##_t*) in1; \
 717       ompi_op_predefined_##type_name##_t *a2 = (ompi_op_predefined_##type_name##_t*) in2; \
 718       ompi_op_predefined_##type_name##_t *b = (ompi_op_predefined_##type_name##_t*) out; \
 719       for (i = 0; i < *count; ++i, ++a1, ++a2, ++b ) {                  \
 720           if (a1->v op a2->v) {                                         \
 721               b->v = a1->v;                                             \
 722               b->k = a1->k;                                             \
 723           } else if (a1->v == a2->v) {                                  \
 724               b->v = a1->v;                                             \
 725               b->k = (a2->k < a1->k ? a2->k : a1->k);                   \
 726           } else {                                                      \
 727               b->v = a2->v;                                             \
 728               b->k = a2->k;                                             \
 729           }                                                             \
 730       }                                                                 \
 731   }
 732 
 733 /*
 734  * Define a function to calculate sum of complex numbers using a real
 735  * number floating-point type (float, double, etc.).  This macro is used
 736  * when the compiler supports a real number floating-point type but does
 737  * not supports the corresponding complex number type.
 738  */
 739 #define COMPLEX_SUM_FUNC_3BUF(type_name, type) \
 740   static void ompi_op_base_3buff_sum_##type_name(void * restrict in1,    \
 741                                                  void * restrict in2, void * restrict out, int *count, \
 742                                                  struct ompi_datatype_t **dtype, \
 743                                                  struct ompi_op_base_module_1_0_0_t *module) \
 744   {                                                                      \
 745       int i;                                                             \
 746       type (*a1)[2] = (type (*)[2]) in1;                                 \
 747       type (*a2)[2] = (type (*)[2]) in2;                                 \
 748       type (*b)[2] = (type (*)[2]) out;                                  \
 749       for (i = 0; i < *count; ++i, ++a1, ++a2, ++b) {                    \
 750           (*b)[0] = (*a1)[0] + (*a2)[0];                                 \
 751           (*b)[1] = (*a1)[1] + (*a2)[1];                                 \
 752       }                                                                  \
 753   }
 754 
 755 /*
 756  * Define a function to calculate product of complex numbers using a real
 757  * number floating-point type (float, double, etc.).  This macro is used
 758  * when the compiler supports a real number floating-point type but does
 759  * not supports the corresponding complex number type.
 760  */
 761 #define COMPLEX_PROD_FUNC_3BUF(type_name, type) \
 762   static void ompi_op_base_3buff_prod_##type_name(void * restrict in1,   \
 763                                                   void * restrict in2, void * restrict out, int *count, \
 764                                                   struct ompi_datatype_t **dtype, \
 765                                                   struct ompi_op_base_module_1_0_0_t *module) \
 766   {                                                                      \
 767       int i;                                                             \
 768       type (*a1)[2] = (type (*)[2]) in1;                                 \
 769       type (*a2)[2] = (type (*)[2]) in2;                                 \
 770       type (*b)[2] = (type (*)[2]) out;                                  \
 771       for (i = 0; i < *count; ++i, ++a1, ++a2, ++b) {                    \
 772           (*b)[0] = (*a1)[0] * (*a2)[0] - (*a1)[1] * (*a2)[1];           \
 773           (*b)[1] = (*a1)[0] * (*a2)[1] + (*a1)[1] * (*a2)[0];           \
 774       }                                                                  \
 775   }
 776 
 777 /*************************************************************************
 778  * Max
 779  *************************************************************************/
 780 
 781 #undef current_func
 782 #define current_func(a, b) ((a) > (b) ? (a) : (b))
 783 /* C integer */
 784 FUNC_FUNC_3BUF(max,   int8_t,   int8_t)
 785 FUNC_FUNC_3BUF(max,  uint8_t,  uint8_t)
 786 FUNC_FUNC_3BUF(max,  int16_t,  int16_t)
 787 FUNC_FUNC_3BUF(max, uint16_t, uint16_t)
 788 FUNC_FUNC_3BUF(max,  int32_t,  int32_t)
 789 FUNC_FUNC_3BUF(max, uint32_t, uint32_t)
 790 FUNC_FUNC_3BUF(max,  int64_t,  int64_t)
 791 FUNC_FUNC_3BUF(max, uint64_t, uint64_t)
 792 /* Fortran integer */
 793 #if OMPI_HAVE_FORTRAN_INTEGER
 794 FUNC_FUNC_3BUF(max, fortran_integer, ompi_fortran_integer_t)
 795 #endif
 796 #if OMPI_HAVE_FORTRAN_INTEGER1
 797 FUNC_FUNC_3BUF(max, fortran_integer1, ompi_fortran_integer1_t)
 798 #endif
 799 #if OMPI_HAVE_FORTRAN_INTEGER2
 800 FUNC_FUNC_3BUF(max, fortran_integer2, ompi_fortran_integer2_t)
 801 #endif
 802 #if OMPI_HAVE_FORTRAN_INTEGER4
 803 FUNC_FUNC_3BUF(max, fortran_integer4, ompi_fortran_integer4_t)
 804 #endif
 805 #if OMPI_HAVE_FORTRAN_INTEGER8
 806 FUNC_FUNC_3BUF(max, fortran_integer8, ompi_fortran_integer8_t)
 807 #endif
 808 #if OMPI_HAVE_FORTRAN_INTEGER16
 809 FUNC_FUNC_3BUF(max, fortran_integer16, ompi_fortran_integer16_t)
 810 #endif
 811 /* Floating point */
 812 #if defined(HAVE_SHORT_FLOAT)
 813 FUNC_FUNC_3BUF(max, short_float, short float)
 814 #elif defined(HAVE_OPAL_SHORT_FLOAT_T)
 815 FUNC_FUNC_3BUF(max, short_float, opal_short_float_t)
 816 #endif
 817 FUNC_FUNC_3BUF(max, float, float)
 818 FUNC_FUNC_3BUF(max, double, double)
 819 FUNC_FUNC_3BUF(max, long_double, long double)
 820 #if OMPI_HAVE_FORTRAN_REAL
 821 FUNC_FUNC_3BUF(max, fortran_real, ompi_fortran_real_t)
 822 #endif
 823 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 824 FUNC_FUNC_3BUF(max, fortran_double_precision, ompi_fortran_double_precision_t)
 825 #endif
 826 #if OMPI_HAVE_FORTRAN_REAL2
 827 FUNC_FUNC_3BUF(max, fortran_real2, ompi_fortran_real2_t)
 828 #endif
 829 #if OMPI_HAVE_FORTRAN_REAL4
 830 FUNC_FUNC_3BUF(max, fortran_real4, ompi_fortran_real4_t)
 831 #endif
 832 #if OMPI_HAVE_FORTRAN_REAL8
 833 FUNC_FUNC_3BUF(max, fortran_real8, ompi_fortran_real8_t)
 834 #endif
 835 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
 836 FUNC_FUNC_3BUF(max, fortran_real16, ompi_fortran_real16_t)
 837 #endif
 838 
 839 
 840 /*************************************************************************
 841  * Min
 842  *************************************************************************/
 843 
 844 #undef current_func
 845 #define current_func(a, b) ((a) < (b) ? (a) : (b))
 846 /* C integer */
 847 FUNC_FUNC_3BUF(min,   int8_t,   int8_t)
 848 FUNC_FUNC_3BUF(min,  uint8_t,  uint8_t)
 849 FUNC_FUNC_3BUF(min,  int16_t,  int16_t)
 850 FUNC_FUNC_3BUF(min, uint16_t, uint16_t)
 851 FUNC_FUNC_3BUF(min,  int32_t,  int32_t)
 852 FUNC_FUNC_3BUF(min, uint32_t, uint32_t)
 853 FUNC_FUNC_3BUF(min,  int64_t,  int64_t)
 854 FUNC_FUNC_3BUF(min, uint64_t, uint64_t)
 855 /* Fortran integer */
 856 #if OMPI_HAVE_FORTRAN_INTEGER
 857 FUNC_FUNC_3BUF(min, fortran_integer, ompi_fortran_integer_t)
 858 #endif
 859 #if OMPI_HAVE_FORTRAN_INTEGER1
 860 FUNC_FUNC_3BUF(min, fortran_integer1, ompi_fortran_integer1_t)
 861 #endif
 862 #if OMPI_HAVE_FORTRAN_INTEGER2
 863 FUNC_FUNC_3BUF(min, fortran_integer2, ompi_fortran_integer2_t)
 864 #endif
 865 #if OMPI_HAVE_FORTRAN_INTEGER4
 866 FUNC_FUNC_3BUF(min, fortran_integer4, ompi_fortran_integer4_t)
 867 #endif
 868 #if OMPI_HAVE_FORTRAN_INTEGER8
 869 FUNC_FUNC_3BUF(min, fortran_integer8, ompi_fortran_integer8_t)
 870 #endif
 871 #if OMPI_HAVE_FORTRAN_INTEGER16
 872 FUNC_FUNC_3BUF(min, fortran_integer16, ompi_fortran_integer16_t)
 873 #endif
 874 /* Floating point */
 875 #if defined(HAVE_SHORT_FLOAT)
 876 FUNC_FUNC_3BUF(min, short_float, short float)
 877 #elif defined(HAVE_OPAL_SHORT_FLOAT_T)
 878 FUNC_FUNC_3BUF(min, short_float, opal_short_float_t)
 879 #endif
 880 FUNC_FUNC_3BUF(min, float, float)
 881 FUNC_FUNC_3BUF(min, double, double)
 882 FUNC_FUNC_3BUF(min, long_double, long double)
 883 #if OMPI_HAVE_FORTRAN_REAL
 884 FUNC_FUNC_3BUF(min, fortran_real, ompi_fortran_real_t)
 885 #endif
 886 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 887 FUNC_FUNC_3BUF(min, fortran_double_precision, ompi_fortran_double_precision_t)
 888 #endif
 889 #if OMPI_HAVE_FORTRAN_REAL2
 890 FUNC_FUNC_3BUF(min, fortran_real2, ompi_fortran_real2_t)
 891 #endif
 892 #if OMPI_HAVE_FORTRAN_REAL4
 893 FUNC_FUNC_3BUF(min, fortran_real4, ompi_fortran_real4_t)
 894 #endif
 895 #if OMPI_HAVE_FORTRAN_REAL8
 896 FUNC_FUNC_3BUF(min, fortran_real8, ompi_fortran_real8_t)
 897 #endif
 898 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
 899 FUNC_FUNC_3BUF(min, fortran_real16, ompi_fortran_real16_t)
 900 #endif
 901 
 902 /*************************************************************************
 903  * Sum
 904  *************************************************************************/
 905 
 906 /* C integer */
 907 OP_FUNC_3BUF(sum,   int8_t,   int8_t, +)
 908 OP_FUNC_3BUF(sum,  uint8_t,  uint8_t, +)
 909 OP_FUNC_3BUF(sum,  int16_t,  int16_t, +)
 910 OP_FUNC_3BUF(sum, uint16_t, uint16_t, +)
 911 OP_FUNC_3BUF(sum,  int32_t,  int32_t, +)
 912 OP_FUNC_3BUF(sum, uint32_t, uint32_t, +)
 913 OP_FUNC_3BUF(sum,  int64_t,  int64_t, +)
 914 OP_FUNC_3BUF(sum, uint64_t, uint64_t, +)
 915 /* Fortran integer */
 916 #if OMPI_HAVE_FORTRAN_INTEGER
 917 OP_FUNC_3BUF(sum, fortran_integer, ompi_fortran_integer_t, +)
 918 #endif
 919 #if OMPI_HAVE_FORTRAN_INTEGER1
 920 OP_FUNC_3BUF(sum, fortran_integer1, ompi_fortran_integer1_t, +)
 921 #endif
 922 #if OMPI_HAVE_FORTRAN_INTEGER2
 923 OP_FUNC_3BUF(sum, fortran_integer2, ompi_fortran_integer2_t, +)
 924 #endif
 925 #if OMPI_HAVE_FORTRAN_INTEGER4
 926 OP_FUNC_3BUF(sum, fortran_integer4, ompi_fortran_integer4_t, +)
 927 #endif
 928 #if OMPI_HAVE_FORTRAN_INTEGER8
 929 OP_FUNC_3BUF(sum, fortran_integer8, ompi_fortran_integer8_t, +)
 930 #endif
 931 #if OMPI_HAVE_FORTRAN_INTEGER16
 932 OP_FUNC_3BUF(sum, fortran_integer16, ompi_fortran_integer16_t, +)
 933 #endif
 934 /* Floating point */
 935 #if defined(HAVE_SHORT_FLOAT)
 936 OP_FUNC_3BUF(sum, short_float, short float, +)
 937 #elif defined(HAVE_OPAL_SHORT_FLOAT_T)
 938 OP_FUNC_3BUF(sum, short_float, opal_short_float_t, +)
 939 #endif
 940 OP_FUNC_3BUF(sum, float, float, +)
 941 OP_FUNC_3BUF(sum, double, double, +)
 942 OP_FUNC_3BUF(sum, long_double, long double, +)
 943 #if OMPI_HAVE_FORTRAN_REAL
 944 OP_FUNC_3BUF(sum, fortran_real, ompi_fortran_real_t, +)
 945 #endif
 946 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
 947 OP_FUNC_3BUF(sum, fortran_double_precision, ompi_fortran_double_precision_t, +)
 948 #endif
 949 #if OMPI_HAVE_FORTRAN_REAL2
 950 OP_FUNC_3BUF(sum, fortran_real2, ompi_fortran_real2_t, +)
 951 #endif
 952 #if OMPI_HAVE_FORTRAN_REAL4
 953 OP_FUNC_3BUF(sum, fortran_real4, ompi_fortran_real4_t, +)
 954 #endif
 955 #if OMPI_HAVE_FORTRAN_REAL8
 956 OP_FUNC_3BUF(sum, fortran_real8, ompi_fortran_real8_t, +)
 957 #endif
 958 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
 959 OP_FUNC_3BUF(sum, fortran_real16, ompi_fortran_real16_t, +)
 960 #endif
 961 /* Complex */
 962 #if defined(HAVE_SHORT_FLOAT__COMPLEX)
 963 OP_FUNC_3BUF(sum, c_short_float_complex, short float _Complex, +)
 964 #elif defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
 965 COMPLEX_SUM_FUNC_3BUF(c_short_float_complex, opal_short_float_t)
 966 #endif
 967 OP_FUNC_3BUF(sum, c_float_complex, float _Complex, +)
 968 OP_FUNC_3BUF(sum, c_double_complex, double _Complex, +)
 969 OP_FUNC_3BUF(sum, c_long_double_complex, long double _Complex, +)
 970 
 971 /*************************************************************************
 972  * Product
 973  *************************************************************************/
 974 
 975 /* C integer */
 976 OP_FUNC_3BUF(prod,   int8_t,   int8_t, *)
 977 OP_FUNC_3BUF(prod,  uint8_t,  uint8_t, *)
 978 OP_FUNC_3BUF(prod,  int16_t,  int16_t, *)
 979 OP_FUNC_3BUF(prod, uint16_t, uint16_t, *)
 980 OP_FUNC_3BUF(prod,  int32_t,  int32_t, *)
 981 OP_FUNC_3BUF(prod, uint32_t, uint32_t, *)
 982 OP_FUNC_3BUF(prod,  int64_t,  int64_t, *)
 983 OP_FUNC_3BUF(prod, uint64_t, uint64_t, *)
 984 /* Fortran integer */
 985 #if OMPI_HAVE_FORTRAN_INTEGER
 986 OP_FUNC_3BUF(prod, fortran_integer, ompi_fortran_integer_t, *)
 987 #endif
 988 #if OMPI_HAVE_FORTRAN_INTEGER1
 989 OP_FUNC_3BUF(prod, fortran_integer1, ompi_fortran_integer1_t, *)
 990 #endif
 991 #if OMPI_HAVE_FORTRAN_INTEGER2
 992 OP_FUNC_3BUF(prod, fortran_integer2, ompi_fortran_integer2_t, *)
 993 #endif
 994 #if OMPI_HAVE_FORTRAN_INTEGER4
 995 OP_FUNC_3BUF(prod, fortran_integer4, ompi_fortran_integer4_t, *)
 996 #endif
 997 #if OMPI_HAVE_FORTRAN_INTEGER8
 998 OP_FUNC_3BUF(prod, fortran_integer8, ompi_fortran_integer8_t, *)
 999 #endif
1000 #if OMPI_HAVE_FORTRAN_INTEGER16
1001 OP_FUNC_3BUF(prod, fortran_integer16, ompi_fortran_integer16_t, *)
1002 #endif
1003 /* Floating point */
1004 #if defined(HAVE_SHORT_FLOAT)
1005 OP_FUNC_3BUF(prod, short_float, short float, *)
1006 #elif defined(HAVE_OPAL_SHORT_FLOAT_T)
1007 OP_FUNC_3BUF(prod, short_float, opal_short_float_t, *)
1008 #endif
1009 OP_FUNC_3BUF(prod, float, float, *)
1010 OP_FUNC_3BUF(prod, double, double, *)
1011 OP_FUNC_3BUF(prod, long_double, long double, *)
1012 #if OMPI_HAVE_FORTRAN_REAL
1013 OP_FUNC_3BUF(prod, fortran_real, ompi_fortran_real_t, *)
1014 #endif
1015 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
1016 OP_FUNC_3BUF(prod, fortran_double_precision, ompi_fortran_double_precision_t, *)
1017 #endif
1018 #if OMPI_HAVE_FORTRAN_REAL2
1019 OP_FUNC_3BUF(prod, fortran_real2, ompi_fortran_real2_t, *)
1020 #endif
1021 #if OMPI_HAVE_FORTRAN_REAL4
1022 OP_FUNC_3BUF(prod, fortran_real4, ompi_fortran_real4_t, *)
1023 #endif
1024 #if OMPI_HAVE_FORTRAN_REAL8
1025 OP_FUNC_3BUF(prod, fortran_real8, ompi_fortran_real8_t, *)
1026 #endif
1027 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
1028 OP_FUNC_3BUF(prod, fortran_real16, ompi_fortran_real16_t, *)
1029 #endif
1030 /* Complex */
1031 #if defined(HAVE_SHORT_FLOAT__COMPLEX)
1032 OP_FUNC_3BUF(prod, c_short_float_complex, short float _Complex, *)
1033 #elif defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
1034 COMPLEX_PROD_FUNC_3BUF(c_short_float_complex, opal_short_float_t)
1035 #endif
1036 OP_FUNC_3BUF(prod, c_float_complex, float _Complex, *)
1037 OP_FUNC_3BUF(prod, c_double_complex, double _Complex, *)
1038 OP_FUNC_3BUF(prod, c_long_double_complex, long double _Complex, *)
1039 
1040 /*************************************************************************
1041  * Logical AND
1042  *************************************************************************/
1043 
1044 #undef current_func
1045 #define current_func(a, b) ((a) && (b))
1046 /* C integer */
1047 FUNC_FUNC_3BUF(land,   int8_t,   int8_t)
1048 FUNC_FUNC_3BUF(land,  uint8_t,  uint8_t)
1049 FUNC_FUNC_3BUF(land,  int16_t,  int16_t)
1050 FUNC_FUNC_3BUF(land, uint16_t, uint16_t)
1051 FUNC_FUNC_3BUF(land,  int32_t,  int32_t)
1052 FUNC_FUNC_3BUF(land, uint32_t, uint32_t)
1053 FUNC_FUNC_3BUF(land,  int64_t,  int64_t)
1054 FUNC_FUNC_3BUF(land, uint64_t, uint64_t)
1055 /* Logical */
1056 #if OMPI_HAVE_FORTRAN_LOGICAL
1057 FUNC_FUNC_3BUF(land, fortran_logical, ompi_fortran_logical_t)
1058 #endif
1059 /* C++ bool */
1060 FUNC_FUNC_3BUF(land, bool, bool)
1061 
1062 /*************************************************************************
1063  * Logical OR
1064  *************************************************************************/
1065 
1066 #undef current_func
1067 #define current_func(a, b) ((a) || (b))
1068 /* C integer */
1069 FUNC_FUNC_3BUF(lor,   int8_t,   int8_t)
1070 FUNC_FUNC_3BUF(lor,  uint8_t,  uint8_t)
1071 FUNC_FUNC_3BUF(lor,  int16_t,  int16_t)
1072 FUNC_FUNC_3BUF(lor, uint16_t, uint16_t)
1073 FUNC_FUNC_3BUF(lor,  int32_t,  int32_t)
1074 FUNC_FUNC_3BUF(lor, uint32_t, uint32_t)
1075 FUNC_FUNC_3BUF(lor,  int64_t,  int64_t)
1076 FUNC_FUNC_3BUF(lor, uint64_t, uint64_t)
1077 /* Logical */
1078 #if OMPI_HAVE_FORTRAN_LOGICAL
1079 FUNC_FUNC_3BUF(lor, fortran_logical, ompi_fortran_logical_t)
1080 #endif
1081 /* C++ bool */
1082 FUNC_FUNC_3BUF(lor, bool, bool)
1083 
1084 /*************************************************************************
1085  * Logical XOR
1086  *************************************************************************/
1087 
1088 #undef current_func
1089 #define current_func(a, b) ((a ? 1 : 0) ^ (b ? 1: 0))
1090 /* C integer */
1091 FUNC_FUNC_3BUF(lxor,   int8_t,   int8_t)
1092 FUNC_FUNC_3BUF(lxor,  uint8_t,  uint8_t)
1093 FUNC_FUNC_3BUF(lxor,  int16_t,  int16_t)
1094 FUNC_FUNC_3BUF(lxor, uint16_t, uint16_t)
1095 FUNC_FUNC_3BUF(lxor,  int32_t,  int32_t)
1096 FUNC_FUNC_3BUF(lxor, uint32_t, uint32_t)
1097 FUNC_FUNC_3BUF(lxor,  int64_t,  int64_t)
1098 FUNC_FUNC_3BUF(lxor, uint64_t, uint64_t)
1099 /* Logical */
1100 #if OMPI_HAVE_FORTRAN_LOGICAL
1101 FUNC_FUNC_3BUF(lxor, fortran_logical, ompi_fortran_logical_t)
1102 #endif
1103 /* C++ bool */
1104 FUNC_FUNC_3BUF(lxor, bool, bool)
1105 
1106 /*************************************************************************
1107  * Bitwise AND
1108  *************************************************************************/
1109 
1110 #undef current_func
1111 #define current_func(a, b) ((a) & (b))
1112 /* C integer */
1113 FUNC_FUNC_3BUF(band,   int8_t,   int8_t)
1114 FUNC_FUNC_3BUF(band,  uint8_t,  uint8_t)
1115 FUNC_FUNC_3BUF(band,  int16_t,  int16_t)
1116 FUNC_FUNC_3BUF(band, uint16_t, uint16_t)
1117 FUNC_FUNC_3BUF(band,  int32_t,  int32_t)
1118 FUNC_FUNC_3BUF(band, uint32_t, uint32_t)
1119 FUNC_FUNC_3BUF(band,  int64_t,  int64_t)
1120 FUNC_FUNC_3BUF(band, uint64_t, uint64_t)
1121 /* Fortran integer */
1122 #if OMPI_HAVE_FORTRAN_INTEGER
1123 FUNC_FUNC_3BUF(band, fortran_integer, ompi_fortran_integer_t)
1124 #endif
1125 #if OMPI_HAVE_FORTRAN_INTEGER1
1126 FUNC_FUNC_3BUF(band, fortran_integer1, ompi_fortran_integer1_t)
1127 #endif
1128 #if OMPI_HAVE_FORTRAN_INTEGER2
1129 FUNC_FUNC_3BUF(band, fortran_integer2, ompi_fortran_integer2_t)
1130 #endif
1131 #if OMPI_HAVE_FORTRAN_INTEGER4
1132 FUNC_FUNC_3BUF(band, fortran_integer4, ompi_fortran_integer4_t)
1133 #endif
1134 #if OMPI_HAVE_FORTRAN_INTEGER8
1135 FUNC_FUNC_3BUF(band, fortran_integer8, ompi_fortran_integer8_t)
1136 #endif
1137 #if OMPI_HAVE_FORTRAN_INTEGER16
1138 FUNC_FUNC_3BUF(band, fortran_integer16, ompi_fortran_integer16_t)
1139 #endif
1140 /* Byte */
1141 FUNC_FUNC_3BUF(band, byte, char)
1142 
1143 /*************************************************************************
1144  * Bitwise OR
1145  *************************************************************************/
1146 
1147 #undef current_func
1148 #define current_func(a, b) ((a) | (b))
1149 /* C integer */
1150 FUNC_FUNC_3BUF(bor,   int8_t,   int8_t)
1151 FUNC_FUNC_3BUF(bor,  uint8_t,  uint8_t)
1152 FUNC_FUNC_3BUF(bor,  int16_t,  int16_t)
1153 FUNC_FUNC_3BUF(bor, uint16_t, uint16_t)
1154 FUNC_FUNC_3BUF(bor,  int32_t,  int32_t)
1155 FUNC_FUNC_3BUF(bor, uint32_t, uint32_t)
1156 FUNC_FUNC_3BUF(bor,  int64_t,  int64_t)
1157 FUNC_FUNC_3BUF(bor, uint64_t, uint64_t)
1158 /* Fortran integer */
1159 #if OMPI_HAVE_FORTRAN_INTEGER
1160 FUNC_FUNC_3BUF(bor, fortran_integer, ompi_fortran_integer_t)
1161 #endif
1162 #if OMPI_HAVE_FORTRAN_INTEGER1
1163 FUNC_FUNC_3BUF(bor, fortran_integer1, ompi_fortran_integer1_t)
1164 #endif
1165 #if OMPI_HAVE_FORTRAN_INTEGER2
1166 FUNC_FUNC_3BUF(bor, fortran_integer2, ompi_fortran_integer2_t)
1167 #endif
1168 #if OMPI_HAVE_FORTRAN_INTEGER4
1169 FUNC_FUNC_3BUF(bor, fortran_integer4, ompi_fortran_integer4_t)
1170 #endif
1171 #if OMPI_HAVE_FORTRAN_INTEGER8
1172 FUNC_FUNC_3BUF(bor, fortran_integer8, ompi_fortran_integer8_t)
1173 #endif
1174 #if OMPI_HAVE_FORTRAN_INTEGER16
1175 FUNC_FUNC_3BUF(bor, fortran_integer16, ompi_fortran_integer16_t)
1176 #endif
1177 /* Byte */
1178 FUNC_FUNC_3BUF(bor, byte, char)
1179 
1180 /*************************************************************************
1181  * Bitwise XOR
1182  *************************************************************************/
1183 
1184 #undef current_func
1185 #define current_func(a, b) ((a) ^ (b))
1186 /* C integer */
1187 FUNC_FUNC_3BUF(bxor,   int8_t,   int8_t)
1188 FUNC_FUNC_3BUF(bxor,  uint8_t,  uint8_t)
1189 FUNC_FUNC_3BUF(bxor,  int16_t,  int16_t)
1190 FUNC_FUNC_3BUF(bxor, uint16_t, uint16_t)
1191 FUNC_FUNC_3BUF(bxor,  int32_t,  int32_t)
1192 FUNC_FUNC_3BUF(bxor, uint32_t, uint32_t)
1193 FUNC_FUNC_3BUF(bxor,  int64_t,  int64_t)
1194 FUNC_FUNC_3BUF(bxor, uint64_t, uint64_t)
1195 /* Fortran integer */
1196 #if OMPI_HAVE_FORTRAN_INTEGER
1197 FUNC_FUNC_3BUF(bxor, fortran_integer, ompi_fortran_integer_t)
1198 #endif
1199 #if OMPI_HAVE_FORTRAN_INTEGER1
1200 FUNC_FUNC_3BUF(bxor, fortran_integer1, ompi_fortran_integer1_t)
1201 #endif
1202 #if OMPI_HAVE_FORTRAN_INTEGER2
1203 FUNC_FUNC_3BUF(bxor, fortran_integer2, ompi_fortran_integer2_t)
1204 #endif
1205 #if OMPI_HAVE_FORTRAN_INTEGER4
1206 FUNC_FUNC_3BUF(bxor, fortran_integer4, ompi_fortran_integer4_t)
1207 #endif
1208 #if OMPI_HAVE_FORTRAN_INTEGER8
1209 FUNC_FUNC_3BUF(bxor, fortran_integer8, ompi_fortran_integer8_t)
1210 #endif
1211 #if OMPI_HAVE_FORTRAN_INTEGER16
1212 FUNC_FUNC_3BUF(bxor, fortran_integer16, ompi_fortran_integer16_t)
1213 #endif
1214 /* Byte */
1215 FUNC_FUNC_3BUF(bxor, byte, char)
1216 
1217 /*************************************************************************
1218  * Min and max location "pair" datatypes
1219  *************************************************************************/
1220 
1221 /*
1222 #if OMPI_HAVE_FORTRAN_REAL
1223 LOC_STRUCT_3BUF(2real, ompi_fortran_real_t, ompi_fortran_real_t)
1224 #endif
1225 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
1226 LOC_STRUCT_3BUF(2double_precision, ompi_fortran_double_precision_t, ompi_fortran_double_precision_t)
1227 #endif
1228 #if OMPI_HAVE_FORTRAN_INTEGER
1229 LOC_STRUCT_3BUF(2integer, ompi_fortran_integer_t, ompi_fortran_integer_t)
1230 #endif
1231 LOC_STRUCT_3BUF(float_int, float, int)
1232 LOC_STRUCT_3BUF(double_int, double, int)
1233 LOC_STRUCT_3BUF(long_int, long, int)
1234 LOC_STRUCT_3BUF(2int, int, int)
1235 LOC_STRUCT_3BUF(short_int, short, int)
1236 LOC_STRUCT_3BUF(long_double_int, long double, int)
1237 */
1238 
1239 /*************************************************************************
1240  * Max location
1241  *************************************************************************/
1242 
1243 #if OMPI_HAVE_FORTRAN_REAL
1244 LOC_FUNC_3BUF(maxloc, 2real, >)
1245 #endif
1246 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
1247 LOC_FUNC_3BUF(maxloc, 2double_precision, >)
1248 #endif
1249 #if OMPI_HAVE_FORTRAN_INTEGER
1250 LOC_FUNC_3BUF(maxloc, 2integer, >)
1251 #endif
1252 LOC_FUNC_3BUF(maxloc, float_int, >)
1253 LOC_FUNC_3BUF(maxloc, double_int, >)
1254 LOC_FUNC_3BUF(maxloc, long_int, >)
1255 LOC_FUNC_3BUF(maxloc, 2int, >)
1256 LOC_FUNC_3BUF(maxloc, short_int, >)
1257 LOC_FUNC_3BUF(maxloc, long_double_int, >)
1258 
1259 /*************************************************************************
1260  * Min location
1261  *************************************************************************/
1262 
1263 #if OMPI_HAVE_FORTRAN_REAL
1264 LOC_FUNC_3BUF(minloc, 2real, <)
1265 #endif
1266 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
1267 LOC_FUNC_3BUF(minloc, 2double_precision, <)
1268 #endif
1269 #if OMPI_HAVE_FORTRAN_INTEGER
1270 LOC_FUNC_3BUF(minloc, 2integer, <)
1271 #endif
1272 LOC_FUNC_3BUF(minloc, float_int, <)
1273 LOC_FUNC_3BUF(minloc, double_int, <)
1274 LOC_FUNC_3BUF(minloc, long_int, <)
1275 LOC_FUNC_3BUF(minloc, 2int, <)
1276 LOC_FUNC_3BUF(minloc, short_int, <)
1277 LOC_FUNC_3BUF(minloc, long_double_int, <)
1278 
1279 /*
1280  * Helpful defines, because there's soooo many names!
1281  *
1282  * **NOTE** These #define's used to be strictly ordered but the use of
1283  * designated initializers removed this restrictions. When adding new
1284  * operators ALWAYS use a designated initalizer!
1285  */
1286 
1287 /** C integer ***********************************************************/
1288 #define C_INTEGER(name, ftype)                                              \
1289   [OMPI_OP_BASE_TYPE_INT8_T] = ompi_op_base_##ftype##_##name##_int8_t,     \
1290   [OMPI_OP_BASE_TYPE_UINT8_T] = ompi_op_base_##ftype##_##name##_uint8_t,   \
1291   [OMPI_OP_BASE_TYPE_INT16_T] = ompi_op_base_##ftype##_##name##_int16_t,   \
1292   [OMPI_OP_BASE_TYPE_UINT16_T] = ompi_op_base_##ftype##_##name##_uint16_t, \
1293   [OMPI_OP_BASE_TYPE_INT32_T] = ompi_op_base_##ftype##_##name##_int32_t,   \
1294   [OMPI_OP_BASE_TYPE_UINT32_T] = ompi_op_base_##ftype##_##name##_uint32_t, \
1295   [OMPI_OP_BASE_TYPE_INT64_T] = ompi_op_base_##ftype##_##name##_int64_t,   \
1296   [OMPI_OP_BASE_TYPE_UINT64_T] = ompi_op_base_##ftype##_##name##_uint64_t
1297 
1298 /** All the Fortran integers ********************************************/
1299 
1300 #if OMPI_HAVE_FORTRAN_INTEGER
1301 #define FORTRAN_INTEGER_PLAIN(name, ftype) ompi_op_base_##ftype##_##name##_fortran_integer
1302 #else
1303 #define FORTRAN_INTEGER_PLAIN(name, ftype) NULL
1304 #endif
1305 #if OMPI_HAVE_FORTRAN_INTEGER1
1306 #define FORTRAN_INTEGER1(name, ftype) ompi_op_base_##ftype##_##name##_fortran_integer1
1307 #else
1308 #define FORTRAN_INTEGER1(name, ftype) NULL
1309 #endif
1310 #if OMPI_HAVE_FORTRAN_INTEGER2
1311 #define FORTRAN_INTEGER2(name, ftype) ompi_op_base_##ftype##_##name##_fortran_integer2
1312 #else
1313 #define FORTRAN_INTEGER2(name, ftype) NULL
1314 #endif
1315 #if OMPI_HAVE_FORTRAN_INTEGER4
1316 #define FORTRAN_INTEGER4(name, ftype) ompi_op_base_##ftype##_##name##_fortran_integer4
1317 #else
1318 #define FORTRAN_INTEGER4(name, ftype) NULL
1319 #endif
1320 #if OMPI_HAVE_FORTRAN_INTEGER8
1321 #define FORTRAN_INTEGER8(name, ftype) ompi_op_base_##ftype##_##name##_fortran_integer8
1322 #else
1323 #define FORTRAN_INTEGER8(name, ftype) NULL
1324 #endif
1325 #if OMPI_HAVE_FORTRAN_INTEGER16
1326 #define FORTRAN_INTEGER16(name, ftype) ompi_op_base_##ftype##_##name##_fortran_integer16
1327 #else
1328 #define FORTRAN_INTEGER16(name, ftype) NULL
1329 #endif
1330 
1331 #define FORTRAN_INTEGER(name, ftype)                                  \
1332     [OMPI_OP_BASE_TYPE_INTEGER] = FORTRAN_INTEGER_PLAIN(name, ftype), \
1333     [OMPI_OP_BASE_TYPE_INTEGER1] = FORTRAN_INTEGER1(name, ftype),     \
1334     [OMPI_OP_BASE_TYPE_INTEGER2] = FORTRAN_INTEGER2(name, ftype),     \
1335     [OMPI_OP_BASE_TYPE_INTEGER4] = FORTRAN_INTEGER4(name, ftype),     \
1336     [OMPI_OP_BASE_TYPE_INTEGER8] = FORTRAN_INTEGER8(name, ftype),     \
1337     [OMPI_OP_BASE_TYPE_INTEGER16] = FORTRAN_INTEGER16(name, ftype)
1338 
1339 /** All the Fortran reals ***********************************************/
1340 
1341 #if OMPI_HAVE_FORTRAN_REAL
1342 #define FLOATING_POINT_FORTRAN_REAL_PLAIN(name, ftype) ompi_op_base_##ftype##_##name##_fortran_real
1343 #else
1344 #define FLOATING_POINT_FORTRAN_REAL_PLAIN(name, ftype) NULL
1345 #endif
1346 #if OMPI_HAVE_FORTRAN_REAL2
1347 #define FLOATING_POINT_FORTRAN_REAL2(name, ftype) ompi_op_base_##ftype##_##name##_fortran_real2
1348 #else
1349 #define FLOATING_POINT_FORTRAN_REAL2(name, ftype) NULL
1350 #endif
1351 #if OMPI_HAVE_FORTRAN_REAL4
1352 #define FLOATING_POINT_FORTRAN_REAL4(name, ftype) ompi_op_base_##ftype##_##name##_fortran_real4
1353 #else
1354 #define FLOATING_POINT_FORTRAN_REAL4(name, ftype) NULL
1355 #endif
1356 #if OMPI_HAVE_FORTRAN_REAL8
1357 #define FLOATING_POINT_FORTRAN_REAL8(name, ftype) ompi_op_base_##ftype##_##name##_fortran_real8
1358 #else
1359 #define FLOATING_POINT_FORTRAN_REAL8(name, ftype) NULL
1360 #endif
1361 /* If:
1362    - we have fortran REAL*16, *and*
1363    - fortran REAL*16 matches the bit representation of the
1364      corresponding C type
1365    Only then do we put in function pointers for REAL*16 reductions.
1366    Otherwise, just put in NULL. */
1367 #if OMPI_HAVE_FORTRAN_REAL16 && OMPI_REAL16_MATCHES_C
1368 #define FLOATING_POINT_FORTRAN_REAL16(name, ftype) ompi_op_base_##ftype##_##name##_fortran_real16
1369 #else
1370 #define FLOATING_POINT_FORTRAN_REAL16(name, ftype) NULL
1371 #endif
1372 
1373 #define FLOATING_POINT_FORTRAN_REAL(name, ftype)                               \
1374     [OMPI_OP_BASE_TYPE_REAL] = FLOATING_POINT_FORTRAN_REAL_PLAIN(name, ftype), \
1375     [OMPI_OP_BASE_TYPE_REAL2] = FLOATING_POINT_FORTRAN_REAL2(name, ftype),     \
1376     [OMPI_OP_BASE_TYPE_REAL4] = FLOATING_POINT_FORTRAN_REAL4(name, ftype),     \
1377     [OMPI_OP_BASE_TYPE_REAL8] = FLOATING_POINT_FORTRAN_REAL8(name, ftype),     \
1378     [OMPI_OP_BASE_TYPE_REAL16] = FLOATING_POINT_FORTRAN_REAL16(name, ftype)
1379 
1380 /** Fortran double precision ********************************************/
1381 
1382 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
1383 #define FLOATING_POINT_FORTRAN_DOUBLE_PRECISION(name, ftype)  \
1384     ompi_op_base_##ftype##_##name##_fortran_double_precision
1385 #else
1386 #define FLOATING_POINT_FORTRAN_DOUBLE_PRECISION(name, ftype) NULL
1387 #endif
1388 
1389 /** Floating point, including all the Fortran reals *********************/
1390 
1391 #if defined(HAVE_SHORT_FLOAT) || defined(HAVE_OPAL_SHORT_FLOAT_T)
1392 #define SHORT_FLOAT(name, ftype) ompi_op_base_##ftype##_##name##_short_float
1393 #else
1394 #define SHORT_FLOAT(name, ftype) NULL
1395 #endif
1396 #define FLOAT(name, ftype) ompi_op_base_##ftype##_##name##_float
1397 #define DOUBLE(name, ftype) ompi_op_base_##ftype##_##name##_double
1398 #define LONG_DOUBLE(name, ftype) ompi_op_base_##ftype##_##name##_long_double
1399 
1400 #define FLOATING_POINT(name, ftype)                                                            \
1401   [OMPI_OP_BASE_TYPE_SHORT_FLOAT] = SHORT_FLOAT(name, ftype),                                  \
1402   [OMPI_OP_BASE_TYPE_FLOAT] = FLOAT(name, ftype),                                              \
1403   [OMPI_OP_BASE_TYPE_DOUBLE] = DOUBLE(name, ftype),                                            \
1404   FLOATING_POINT_FORTRAN_REAL(name, ftype),                                                    \
1405   [OMPI_OP_BASE_TYPE_DOUBLE_PRECISION] = FLOATING_POINT_FORTRAN_DOUBLE_PRECISION(name, ftype), \
1406   [OMPI_OP_BASE_TYPE_LONG_DOUBLE] = LONG_DOUBLE(name, ftype)
1407 
1408 /** Fortran logical *****************************************************/
1409 
1410 #if OMPI_HAVE_FORTRAN_LOGICAL
1411 #define FORTRAN_LOGICAL(name, ftype)                                          \
1412   ompi_op_base_##ftype##_##name##_fortran_logical  /* OMPI_OP_BASE_TYPE_LOGICAL */
1413 #else
1414 #define FORTRAN_LOGICAL(name, ftype) NULL
1415 #endif
1416 
1417 #define LOGICAL(name, ftype)                                    \
1418     [OMPI_OP_BASE_TYPE_LOGICAL] = FORTRAN_LOGICAL(name, ftype), \
1419     [OMPI_OP_BASE_TYPE_BOOL] = ompi_op_base_##ftype##_##name##_bool
1420 
1421 /** Complex *****************************************************/
1422 
1423 #if defined(HAVE_SHORT_FLOAT__COMPLEX) || defined(HAVE_OPAL_SHORT_FLOAT_COMPLEX_T)
1424 #define SHORT_FLOAT_COMPLEX(name, ftype) ompi_op_base_##ftype##_##name##_c_short_float_complex
1425 #else
1426 #define SHORT_FLOAT_COMPLEX(name, ftype) NULL
1427 #endif
1428 #define FLOAT_COMPLEX(name, ftype) ompi_op_base_##ftype##_##name##_c_float_complex
1429 #define DOUBLE_COMPLEX(name, ftype) ompi_op_base_##ftype##_##name##_c_double_complex
1430 #define LONG_DOUBLE_COMPLEX(name, ftype) ompi_op_base_##ftype##_##name##_c_long_double_complex
1431 
1432 #define COMPLEX(name, ftype)                                                  \
1433     [OMPI_OP_BASE_TYPE_C_SHORT_FLOAT_COMPLEX] = SHORT_FLOAT_COMPLEX(name, ftype), \
1434     [OMPI_OP_BASE_TYPE_C_FLOAT_COMPLEX] = FLOAT_COMPLEX(name, ftype),         \
1435     [OMPI_OP_BASE_TYPE_C_DOUBLE_COMPLEX] = DOUBLE_COMPLEX(name, ftype),       \
1436     [OMPI_OP_BASE_TYPE_C_LONG_DOUBLE_COMPLEX] = LONG_DOUBLE_COMPLEX(name, ftype)
1437 
1438 /** Byte ****************************************************************/
1439 
1440 #define BYTE(name, ftype)                                     \
1441   [OMPI_OP_BASE_TYPE_BYTE] = ompi_op_base_##ftype##_##name##_byte
1442 
1443 /** Fortran complex *****************************************************/
1444 /** Fortran "2" types ***************************************************/
1445 
1446 #if OMPI_HAVE_FORTRAN_REAL
1447 #define TWOLOC_FORTRAN_2REAL(name, ftype) ompi_op_base_##ftype##_##name##_2real
1448 #else
1449 #define TWOLOC_FORTRAN_2REAL(name, ftype) NULL
1450 #endif
1451 #if OMPI_HAVE_FORTRAN_DOUBLE_PRECISION
1452 #define TWOLOC_FORTRAN_2DOUBLE_PRECISION(name, ftype) ompi_op_base_##ftype##_##name##_2double_precision
1453 #else
1454 #define TWOLOC_FORTRAN_2DOUBLE_PRECISION(name, ftype) NULL
1455 #endif
1456 #if OMPI_HAVE_FORTRAN_INTEGER
1457 #define TWOLOC_FORTRAN_2INTEGER(name, ftype) ompi_op_base_##ftype##_##name##_2integer
1458 #else
1459 #define TWOLOC_FORTRAN_2INTEGER(name, ftype) NULL
1460 #endif
1461 
1462 /** All "2" types *******************************************************/
1463 
1464 #define TWOLOC(name, ftype)                                                                   \
1465     [OMPI_OP_BASE_TYPE_2REAL] = TWOLOC_FORTRAN_2REAL(name, ftype),                            \
1466     [OMPI_OP_BASE_TYPE_2DOUBLE_PRECISION] = TWOLOC_FORTRAN_2DOUBLE_PRECISION(name, ftype),    \
1467     [OMPI_OP_BASE_TYPE_2INTEGER] = TWOLOC_FORTRAN_2INTEGER(name, ftype),                      \
1468     [OMPI_OP_BASE_TYPE_FLOAT_INT] = ompi_op_base_##ftype##_##name##_float_int,                \
1469     [OMPI_OP_BASE_TYPE_DOUBLE_INT] = ompi_op_base_##ftype##_##name##_double_int,              \
1470     [OMPI_OP_BASE_TYPE_LONG_INT] = ompi_op_base_##ftype##_##name##_long_int,                  \
1471     [OMPI_OP_BASE_TYPE_2INT] = ompi_op_base_##ftype##_##name##_2int,                          \
1472     [OMPI_OP_BASE_TYPE_SHORT_INT] = ompi_op_base_##ftype##_##name##_short_int,                \
1473     [OMPI_OP_BASE_TYPE_LONG_DOUBLE_INT] = ompi_op_base_##ftype##_##name##_long_double_int
1474 
1475 /*
1476  * MPI_OP_NULL
1477  * All types
1478  */
1479 #define FLAGS_NO_FLOAT \
1480     (OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE)
1481 #define FLAGS \
1482     (OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | \
1483      OMPI_OP_FLAGS_FLOAT_ASSOC | OMPI_OP_FLAGS_COMMUTE)
1484 
1485 ompi_op_base_handler_fn_t ompi_op_base_functions[OMPI_OP_BASE_FORTRAN_OP_MAX][OMPI_OP_BASE_TYPE_MAX] =
1486     {
1487         /* Corresponds to MPI_OP_NULL */
1488         [OMPI_OP_BASE_FORTRAN_NULL] = {
1489             /* Leaving this empty puts in NULL for all entries */
1490             NULL,
1491         },
1492         /* Corresponds to MPI_MAX */
1493         [OMPI_OP_BASE_FORTRAN_MAX] = {
1494             C_INTEGER(max, 2buff),
1495             FORTRAN_INTEGER(max, 2buff),
1496             FLOATING_POINT(max, 2buff),
1497         },
1498         /* Corresponds to MPI_MIN */
1499         [OMPI_OP_BASE_FORTRAN_MIN] = {
1500             C_INTEGER(min, 2buff),
1501             FORTRAN_INTEGER(min, 2buff),
1502             FLOATING_POINT(min, 2buff),
1503         },
1504         /* Corresponds to MPI_SUM */
1505         [OMPI_OP_BASE_FORTRAN_SUM] = {
1506             C_INTEGER(sum, 2buff),
1507             FORTRAN_INTEGER(sum, 2buff),
1508             FLOATING_POINT(sum, 2buff),
1509             COMPLEX(sum, 2buff),
1510         },
1511         /* Corresponds to MPI_PROD */
1512         [OMPI_OP_BASE_FORTRAN_PROD] = {
1513             C_INTEGER(prod, 2buff),
1514             FORTRAN_INTEGER(prod, 2buff),
1515             FLOATING_POINT(prod, 2buff),
1516             COMPLEX(prod, 2buff),
1517         },
1518         /* Corresponds to MPI_LAND */
1519         [OMPI_OP_BASE_FORTRAN_LAND] = {
1520             C_INTEGER(land, 2buff),
1521             LOGICAL(land, 2buff),
1522         },
1523         /* Corresponds to MPI_BAND */
1524         [OMPI_OP_BASE_FORTRAN_BAND] = {
1525             C_INTEGER(band, 2buff),
1526             FORTRAN_INTEGER(band, 2buff),
1527             BYTE(band, 2buff),
1528         },
1529         /* Corresponds to MPI_LOR */
1530         [OMPI_OP_BASE_FORTRAN_LOR] = {
1531             C_INTEGER(lor, 2buff),
1532             LOGICAL(lor, 2buff),
1533         },
1534         /* Corresponds to MPI_BOR */
1535         [OMPI_OP_BASE_FORTRAN_BOR] = {
1536             C_INTEGER(bor, 2buff),
1537             FORTRAN_INTEGER(bor, 2buff),
1538             BYTE(bor, 2buff),
1539         },
1540         /* Corresponds to MPI_LXOR */
1541         [OMPI_OP_BASE_FORTRAN_LXOR] = {
1542             C_INTEGER(lxor, 2buff),
1543             LOGICAL(lxor, 2buff),
1544         },
1545         /* Corresponds to MPI_BXOR */
1546         [OMPI_OP_BASE_FORTRAN_BXOR] = {
1547             C_INTEGER(bxor, 2buff),
1548             FORTRAN_INTEGER(bxor, 2buff),
1549             BYTE(bxor, 2buff),
1550         },
1551         /* Corresponds to MPI_MAXLOC */
1552         [OMPI_OP_BASE_FORTRAN_MAXLOC] = {
1553             TWOLOC(maxloc, 2buff),
1554         },
1555         /* Corresponds to MPI_MINLOC */
1556         [OMPI_OP_BASE_FORTRAN_MINLOC] = {
1557             TWOLOC(minloc, 2buff),
1558         },
1559         /* Corresponds to MPI_REPLACE */
1560         [OMPI_OP_BASE_FORTRAN_REPLACE] = {
1561             /* (MPI_ACCUMULATE is handled differently than the other
1562                reductions, so just zero out its function
1563                impementations here to ensure that users don't invoke
1564                MPI_REPLACE with any reduction operations other than
1565                ACCUMULATE) */
1566             NULL,
1567         },
1568 
1569     };
1570 
1571 
1572 ompi_op_base_3buff_handler_fn_t ompi_op_base_3buff_functions[OMPI_OP_BASE_FORTRAN_OP_MAX][OMPI_OP_BASE_TYPE_MAX] =
1573     {
1574         /* Corresponds to MPI_OP_NULL */
1575         [OMPI_OP_BASE_FORTRAN_NULL] = {
1576             /* Leaving this empty puts in NULL for all entries */
1577             NULL,
1578         },
1579         /* Corresponds to MPI_MAX */
1580         [OMPI_OP_BASE_FORTRAN_MAX] = {
1581             C_INTEGER(max, 3buff),
1582             FORTRAN_INTEGER(max, 3buff),
1583             FLOATING_POINT(max, 3buff),
1584         },
1585         /* Corresponds to MPI_MIN */
1586         [OMPI_OP_BASE_FORTRAN_MIN] = {
1587             C_INTEGER(min, 3buff),
1588             FORTRAN_INTEGER(min, 3buff),
1589             FLOATING_POINT(min, 3buff),
1590         },
1591         /* Corresponds to MPI_SUM */
1592         [OMPI_OP_BASE_FORTRAN_SUM] = {
1593             C_INTEGER(sum, 3buff),
1594             FORTRAN_INTEGER(sum, 3buff),
1595             FLOATING_POINT(sum, 3buff),
1596             COMPLEX(sum, 3buff),
1597         },
1598         /* Corresponds to MPI_PROD */
1599         [OMPI_OP_BASE_FORTRAN_PROD] = {
1600             C_INTEGER(prod, 3buff),
1601             FORTRAN_INTEGER(prod, 3buff),
1602             FLOATING_POINT(prod, 3buff),
1603             COMPLEX(prod, 3buff),
1604         },
1605         /* Corresponds to MPI_LAND */
1606         [OMPI_OP_BASE_FORTRAN_LAND] ={
1607             C_INTEGER(land, 3buff),
1608             LOGICAL(land, 3buff),
1609         },
1610         /* Corresponds to MPI_BAND */
1611         [OMPI_OP_BASE_FORTRAN_BAND] = {
1612             C_INTEGER(band, 3buff),
1613             FORTRAN_INTEGER(band, 3buff),
1614             BYTE(band, 3buff),
1615         },
1616         /* Corresponds to MPI_LOR */
1617         [OMPI_OP_BASE_FORTRAN_LOR] = {
1618             C_INTEGER(lor, 3buff),
1619             LOGICAL(lor, 3buff),
1620         },
1621         /* Corresponds to MPI_BOR */
1622         [OMPI_OP_BASE_FORTRAN_BOR] = {
1623             C_INTEGER(bor, 3buff),
1624             FORTRAN_INTEGER(bor, 3buff),
1625             BYTE(bor, 3buff),
1626         },
1627         /* Corresponds to MPI_LXOR */
1628         [OMPI_OP_BASE_FORTRAN_LXOR] = {
1629             C_INTEGER(lxor, 3buff),
1630             LOGICAL(lxor, 3buff),
1631         },
1632         /* Corresponds to MPI_BXOR */
1633         [OMPI_OP_BASE_FORTRAN_BXOR] = {
1634             C_INTEGER(bxor, 3buff),
1635             FORTRAN_INTEGER(bxor, 3buff),
1636             BYTE(bxor, 3buff),
1637         },
1638         /* Corresponds to MPI_MAXLOC */
1639         [OMPI_OP_BASE_FORTRAN_MAXLOC] = {
1640             TWOLOC(maxloc, 3buff),
1641         },
1642         /* Corresponds to MPI_MINLOC */
1643         [OMPI_OP_BASE_FORTRAN_MINLOC] = {
1644             TWOLOC(minloc, 3buff),
1645         },
1646         /* Corresponds to MPI_REPLACE */
1647         [OMPI_OP_BASE_FORTRAN_REPLACE] = {
1648             /* MPI_ACCUMULATE is handled differently than the other
1649                reductions, so just zero out its function
1650                impementations here to ensure that users don't invoke
1651                MPI_REPLACE with any reduction operations other than
1652                ACCUMULATE */
1653             NULL,
1654         },
1655     };
1656 

/* [<][>][^][v][top][bottom][index][help] */