oplxor.c 4.51 KB
Newer Older
1
2
3
4
5
6
7
8
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
 *
 *  (C) 2001 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#include "mpiimpl.h"
9
#include "oputil.h"
10
11
12
13
#ifdef HAVE_FORTRAN_BINDING
#include "mpi_fortlogical.h"
#endif

14
15
16
17
18
19
/* We have enabled extensive warnings when using gcc for certain builds.
   For this file, this generates many specious warnings */
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif

20
21
22
/*
 * In MPI-2.1, this operation is valid only for C integer and Logical
 * types (5.9.2 Predefined reduce operations)
23
24
25
26
 */
#ifndef MPIR_LLXOR
#define MPIR_LLXOR(a,b) (((a)&&(!b))||((!a)&&(b)))
#endif
27
28
29
30
31
32
33
34
35

#undef FUNCNAME
#define FUNCNAME MPIR_LXOR
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
void MPIR_LXOR (
    void *invec,
    void *inoutvec,
    int *Len,
36
37
38
    MPI_Datatype *type )
{
    int i, len = *Len;
39

40
    switch (*type) {
41
#undef MPIR_OP_TYPE_MACRO
42
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LLXOR)
43
44
45
46
47
48
        /* no semicolons by necessity */
        MPIR_OP_TYPE_GROUP(C_INTEGER)

        /* MPI_LOGICAL requires special handling (MPIR_{TO,FROM}_FLOG) */
#if defined(HAVE_FORTRAN_BINDING)
#  undef MPIR_OP_TYPE_MACRO_HAVE_FORTRAN
49
#  define MPIR_OP_TYPE_MACRO_HAVE_FORTRAN(mpi_type_, c_type_, type_name_)  \
50
51
52
53
54
55
56
57
58
59
        case (mpi_type_): {                                                \
                c_type_ * restrict a = (c_type_ *)inoutvec;                \
                c_type_ * restrict b = (c_type_ *)invec;                   \
                for (i=0; i<len; i++)                                      \
                    a[i] = MPIR_TO_FLOG(MPIR_LLXOR(MPIR_FROM_FLOG(a[i]),   \
                                                   MPIR_FROM_FLOG(b[i]))); \
                break;                                                     \
        }
        /* expand logicals (which may include MPI_C_BOOL, a non-Fortran type) */
        MPIR_OP_TYPE_GROUP(LOGICAL)
60
        MPIR_OP_TYPE_GROUP(LOGICAL_EXTRA)
61
62
        /* now revert _HAVE_FORTRAN macro to default */
#  undef MPIR_OP_TYPE_MACRO_HAVE_FORTRAN
63
#  define MPIR_OP_TYPE_MACRO_HAVE_FORTRAN(mpi_type_, c_type_, type_name_) MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_)
64
65
66
67
#else
        /* if we don't have Fortran support then we don't have to jump through
           any hoops, simply expand the group */
        MPIR_OP_TYPE_GROUP(LOGICAL)
68
        MPIR_OP_TYPE_GROUP(LOGICAL_EXTRA)
69
#endif
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

        /* extra types that are not required to be supported by the MPI Standard */
        MPIR_OP_TYPE_GROUP(C_INTEGER_EXTRA)
        MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
        MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER_EXTRA)
        /* We previously supported floating point types, although I question
           their utility in logical boolean ops [goodell@ 2009-03-16] */
        MPIR_OP_TYPE_GROUP(FLOATING_POINT)
        MPIR_OP_TYPE_GROUP(FLOATING_POINT_EXTRA)
#undef MPIR_OP_TYPE_MACRO
        /* --BEGIN ERROR HANDLING-- */
        default: {
            MPIU_THREADPRIV_DECL;
            MPIU_THREADPRIV_GET;
            MPIU_THREADPRIV_FIELD(op_errno) = MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OP, "**opundefined","**opundefined %s", "MPI_LXOR" );
            break;
        }
        /* --END ERROR HANDLING-- */
88
89
90
91
    }
}


92
93
94
95
#undef FUNCNAME
#define FUNCNAME MPIR_LXOR
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
96
97
98
int MPIR_LXOR_check_dtype ( MPI_Datatype type )
{
    switch (type) {
99
#undef MPIR_OP_TYPE_MACRO
100
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) case (mpi_type_):
101
102
        MPIR_OP_TYPE_GROUP(C_INTEGER)
        MPIR_OP_TYPE_GROUP(LOGICAL) /* no special handling needed in check_dtype code */
103
        MPIR_OP_TYPE_GROUP(LOGICAL_EXTRA)
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

        /* extra types that are not required to be supported by the MPI Standard */
        MPIR_OP_TYPE_GROUP(C_INTEGER_EXTRA)
        MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
        MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER_EXTRA)
        /* We previously supported floating point types, although I question
           their utility in logical boolean ops [goodell@ 2009-03-16] */
        MPIR_OP_TYPE_GROUP(FLOATING_POINT)
        MPIR_OP_TYPE_GROUP(FLOATING_POINT_EXTRA)
#undef MPIR_OP_TYPE_MACRO
            return MPI_SUCCESS;
        /* --BEGIN ERROR HANDLING-- */
        default:
            return MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OP, "**opundefined","**opundefined %s", "MPI_LXOR" );
        /* --END ERROR HANDLING-- */
119
120
121
    }
}