1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5 
6 #include "mpiimpl.h"
7 #include "mpir_op_util.h"
8 
9 /*
10  * In MPI-2.1, this operation is valid only for C integer, Fortran integer,
11  * and byte data items (5.9.2 Predefined reduce operations)
12  */
13 #ifndef MPIR_LBOR
14 #define MPIR_LBOR(a,b) ((a)|(b))
15 #endif
16 
MPIR_BOR(void * invec,void * inoutvec,int * Len,MPI_Datatype * type)17 void MPIR_BOR(void *invec, void *inoutvec, int *Len, MPI_Datatype * type)
18 {
19     int i, len = *Len;
20 
21     switch (*type) {
22 #undef MPIR_OP_TYPE_MACRO
23 #define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LBOR)
24             /* no semicolons by necessity */
25             MPIR_OP_TYPE_GROUP(C_INTEGER)
26                 MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
27                 MPIR_OP_TYPE_GROUP(BYTE)
28                 /* extra types that are not required to be supported by the MPI Standard */
29                 MPIR_OP_TYPE_GROUP(C_INTEGER_EXTRA)
30                 MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER_EXTRA)
31                 MPIR_OP_TYPE_GROUP(BYTE_EXTRA)
32 #undef MPIR_OP_TYPE_MACRO
33         default:
34             MPIR_Assert(0);
35             break;
36     }
37 }
38 
39 
MPIR_BOR_check_dtype(MPI_Datatype type)40 int MPIR_BOR_check_dtype(MPI_Datatype type)
41 {
42     switch (type) {
43 #undef MPIR_OP_TYPE_MACRO
44 #define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) case (mpi_type_):
45             MPIR_OP_TYPE_GROUP(C_INTEGER)
46                 MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
47                 MPIR_OP_TYPE_GROUP(BYTE)
48                 /* extra types that are not required to be supported by the MPI Standard */
49                 MPIR_OP_TYPE_GROUP(C_INTEGER_EXTRA)
50                 MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER_EXTRA)
51                 MPIR_OP_TYPE_GROUP(BYTE_EXTRA)
52 #undef MPIR_OP_TYPE_MACRO
53                 return MPI_SUCCESS;
54             /* --BEGIN ERROR HANDLING-- */
55         default:
56             return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, __func__, __LINE__,
57                                         MPI_ERR_OP, "**opundefined", "**opundefined %s", "MPI_BOR");
58             /* --END ERROR HANDLING-- */
59     }
60 }
61