opband.c 2.39 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
/*
 * In MPI-2.1, this operation is valid only for C integer, Fortran integer,
 * and byte types (5.9.2 Predefined reduce operations)
14
15
16
17
 */
#ifndef MPIR_LBAND
#define MPIR_LBAND(a,b) ((a)&(b))
#endif
18
19
20
21
22
23
24
25
26

#undef FUNCNAME
#define FUNCNAME MPIR_BAND
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
void MPIR_BAND (
    void *invec,
    void *inoutvec,
    int *Len,
27
28
29
    MPI_Datatype *type )
{
    int i, len = *Len;
30

31
    switch (*type) {
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_) MPIR_OP_TYPE_REDUCE_CASE(mpi_type_, c_type_, MPIR_LBAND)
        /* no semicolons by necessity */
        MPIR_OP_TYPE_GROUP(C_INTEGER)
        MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
        MPIR_OP_TYPE_GROUP(BYTE)
        /* 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_EXTRA)
        MPIR_OP_TYPE_GROUP(BYTE_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_BAND" );
            break;
        }
        /* --END ERROR HANDLING-- */
51
52
53
54
    }
}


55
56
57
58
#undef FUNCNAME
#define FUNCNAME MPIR_BAND_check_dtype
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
59
60
61
int MPIR_BAND_check_dtype ( MPI_Datatype type )
{
    switch (type) {
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#undef MPIR_OP_TYPE_MACRO
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_) case (mpi_type_):
        MPIR_OP_TYPE_GROUP(C_INTEGER)
        MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
        MPIR_OP_TYPE_GROUP(BYTE)
        /* 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_EXTRA)
        MPIR_OP_TYPE_GROUP(BYTE_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_BAND" );
        /* --END ERROR HANDLING-- */
77
78
79
    }
}