-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/coll/opband.c
        -:    0:Object:opband.bb
        -:    1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
        -:    2:/*
        -:    3: *
        -:    4: *  (C) 2001 by Argonne National Laboratory.
        -:    5: *      See COPYRIGHT in top-level directory.
        -:    6: */
        -:    7:
        -:    8:#include "mpiimpl.h"
        -:    9:
        -:   10:/* 
        -:   11: * In MPI-1, this operation is valid only for  C integer, Fortran integer,
        -:   12: * and byte data items (4.9.2 Predefined reduce operations)
        -:   13: */
        -:   14:#ifndef MPIR_LBAND
        -:   15:#define MPIR_LBAND(a,b) ((a)&(b))
        -:   16:#endif
        -:   17:void MPIR_BAND ( 
        -:   18:    void *invec, 
        -:   19:    void *inoutvec, 
        -:   20:    int *Len, 
        -:   21:    MPI_Datatype *type )
   465881:   22:{
   465881:   23:    static const char FCNAME[] = "MPIR_BAND";
   465881:   24:    int i, len = *Len;
        -:   25:    
   465881:   26:    switch (*type) {
        -:   27:#ifdef HAVE_FORTRAN_BINDING
        -:   28:    case MPI_LOGICAL: case MPI_INTEGER: {
     1730:   29:        MPI_Fint * restrict a = (MPI_Fint *)inoutvec; 
     1730:   30:        MPI_Fint * restrict b = (MPI_Fint *)invec;
  1657043:   31:        for ( i=0; i<len; i++ )
  1655313:   32:            a[i] = MPIR_LBAND(a[i],b[i]);
    #####:   33:        break;
        -:   34:    }
        -:   35:#endif
        -:   36:#ifdef MPIR_INTEGER1_CTYPE
        -:   37:    case MPI_INTEGER1: {
    #####:   38:        MPIR_INTEGER1_CTYPE * restrict a = (MPIR_INTEGER1_CTYPE *)inoutvec; 
    #####:   39:        MPIR_INTEGER1_CTYPE * restrict b = (MPIR_INTEGER1_CTYPE *)invec;
    #####:   40:        for ( i=0; i<len; i++ )
    #####:   41:            a[i] = MPIR_LBAND(a[i],b[i]);
    #####:   42:        break;
        -:   43:    }
        -:   44:#endif
        -:   45:#ifdef MPIR_INTEGER2_CTYPE
        -:   46:    case MPI_INTEGER2: {
    #####:   47:        MPIR_INTEGER2_CTYPE * restrict a = (MPIR_INTEGER2_CTYPE *)inoutvec; 
    #####:   48:        MPIR_INTEGER2_CTYPE * restrict b = (MPIR_INTEGER2_CTYPE *)invec;
    #####:   49:        for ( i=0; i<len; i++ )
    #####:   50:            a[i] = MPIR_LBAND(a[i],b[i]);
    #####:   51:        break;
        -:   52:    }
        -:   53:#endif
        -:   54:#ifdef MPIR_INTEGER4_CTYPE
        -:   55:    case MPI_INTEGER4: {
    #####:   56:        MPIR_INTEGER4_CTYPE * restrict a = (MPIR_INTEGER4_CTYPE *)inoutvec; 
    #####:   57:        MPIR_INTEGER4_CTYPE * restrict b = (MPIR_INTEGER4_CTYPE *)invec;
    #####:   58:        for ( i=0; i<len; i++ )
    #####:   59:            a[i] = MPIR_LBAND(a[i],b[i]);
    #####:   60:        break;
        -:   61:    }
        -:   62:#endif
        -:   63:#ifdef MPIR_INTEGER8_CTYPE
        -:   64:    case MPI_INTEGER8: {
    #####:   65:        MPIR_INTEGER8_CTYPE * restrict a = (MPIR_INTEGER8_CTYPE *)inoutvec; 
    #####:   66:        MPIR_INTEGER8_CTYPE * restrict b = (MPIR_INTEGER8_CTYPE *)invec;
    #####:   67:        for ( i=0; i<len; i++ )
    #####:   68:            a[i] = MPIR_LBAND(a[i],b[i]);
   461373:   69:        break;
        -:   70:    }
        -:   71:#endif
        -:   72:#ifdef MPIR_INTEGER16_CTYPE
        -:   73:    case MPI_INTEGER16: {
        -:   74:        MPIR_INTEGER16_CTYPE * restrict a = (MPIR_INTEGER16_CTYPE *)inoutvec; 
        -:   75:        MPIR_INTEGER16_CTYPE * restrict b = (MPIR_INTEGER16_CTYPE *)invec;
        -:   76:        for ( i=0; i<len; i++ )
        -:   77:            a[i] = MPIR_LBAND(a[i],b[i]);
        -:   78:        break;
        -:   79:    }
        -:   80:#endif
        -:   81:    case MPI_INT: {
   461373:   82:        int * restrict a = (int *)inoutvec; 
   461373:   83:        int * restrict b = (int *)invec;
 15645051:   84:        for ( i=0; i<len; i++ )
 15183678:   85:            a[i] = MPIR_LBAND(a[i],b[i]);
      546:   86:        break;
        -:   87:    }
        -:   88:    case MPI_UNSIGNED: {
      546:   89:        unsigned * restrict a = (unsigned *)inoutvec; 
      546:   90:        unsigned * restrict b = (unsigned *)invec;
   437673:   91:        for ( i=0; i<len; i++ )
   437127:   92:            a[i] = MPIR_LBAND(a[i],b[i]);
      546:   93:        break;
        -:   94:    }
        -:   95:    case MPI_LONG: {
      546:   96:        long * restrict a = (long *)inoutvec; 
      546:   97:        long * restrict b = (long *)invec;
   437673:   98:        for ( i=0; i<len; i++ )
   437127:   99:            a[i] = MPIR_LBAND(a[i],b[i]);
        3:  100:        break;
        -:  101:    }
        -:  102:#if defined(HAVE_LONG_LONG_INT)
        -:  103:    case MPI_LONG_LONG: {
        -:  104:	/* case MPI_LONG_LONG_INT: defined to be the same as long_long */
        3:  105:        long long * restrict a = (long long *)inoutvec; 
        3:  106:        long long * restrict b = (long long *)invec;
       12:  107:        for ( i=0; i<len; i++ )
        9:  108:            a[i] = MPIR_LBAND(a[i],b[i]);
      546:  109:        break;
        -:  110:    }
        -:  111:#endif
        -:  112:    case MPI_UNSIGNED_LONG: {
      546:  113:        unsigned long * restrict a = (unsigned long *)inoutvec; 
      546:  114:        unsigned long * restrict b = (unsigned long *)invec;
   437673:  115:        for ( i=0; i<len; i++ )
   437127:  116:            a[i] = MPIR_LBAND(a[i],b[i]);
      546:  117:        break;
        -:  118:    }
        -:  119:    case MPI_SHORT: {
      546:  120:        short * restrict a = (short *)inoutvec; 
      546:  121:        short * restrict b = (short *)invec;
   874071:  122:        for ( i=0; i<len; i++ )
   873525:  123:            a[i] = MPIR_LBAND(a[i],b[i]);
      546:  124:        break;
        -:  125:    }
        -:  126:    case MPI_UNSIGNED_SHORT: {
      546:  127:        unsigned short * restrict a = (unsigned short *)inoutvec; 
      546:  128:        unsigned short * restrict b = (unsigned short *)invec;
   874071:  129:        for ( i=0; i<len; i++ )
   873525:  130:            a[i] = MPIR_LBAND(a[i],b[i]);
        3:  131:        break;
        -:  132:    }
        -:  133:    case MPI_CHAR: 
        -:  134:#ifdef HAVE_FORTRAN_BINDING
        -:  135:    case MPI_CHARACTER: 
        -:  136:#endif
        -:  137:    {
        3:  138:        char * restrict a = (char *)inoutvec; 
        3:  139:        char * restrict b = (char *)invec;
       12:  140:        for ( i=0; i<len; i++ )
        9:  141:            a[i] = MPIR_LBAND(a[i],b[i]);
        3:  142:        break;
        -:  143:    }
        -:  144:    case MPI_UNSIGNED_CHAR: {
        3:  145:        unsigned char * restrict a = (unsigned char *)inoutvec; 
        3:  146:        unsigned char * restrict b = (unsigned char *)invec;
       12:  147:        for ( i=0; i<len; i++ )
        9:  148:            a[i] = MPIR_LBAND(a[i],b[i]);
       39:  149:        break;
        -:  150:    }
        -:  151:    case MPI_BYTE: {
       39:  152:        unsigned char * restrict a = (unsigned char *)inoutvec; 
       39:  153:        unsigned char * restrict b = (unsigned char *)invec;
      408:  154:        for ( i=0; i<len; i++ )
      369:  155:            a[i] = MPIR_LBAND(a[i],b[i]);
    #####:  156:        break;
        -:  157:    }
        -:  158:	/* --BEGIN ERROR HANDLING-- */
        -:  159:    default: {
    #####:  160:        MPICH_PerThread_t *p;
    #####:  161:        MPIR_GetPerThread(&p);
    #####:  162:        p->op_errno = MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OP, "**opundefined","**opundefined %s", "MPI_BAND" );
   465881:  163:        break;
        -:  164:    }
        -:  165:	/* --END ERROR HANDLING-- */
        -:  166:    }
        -:  167:}
        -:  168:
        -:  169:
        -:  170:int MPIR_BAND_check_dtype ( MPI_Datatype type )
   445833:  171:{
   445833:  172:    static const char FCNAME[] = "MPIR_BAND_check_dtype";
   445833:  173:    switch (type) {
        -:  174:#ifdef HAVE_FORTRAN_BINDING
        -:  175:    case MPI_LOGICAL: case MPI_INTEGER: 
        -:  176:#endif
        -:  177:    case MPI_INT: 
        -:  178:    case MPI_UNSIGNED: 
        -:  179:    case MPI_LONG: 
        -:  180:#if defined(HAVE_LONG_LONG_INT)
        -:  181:    case MPI_LONG_LONG: 
        -:  182:#endif
        -:  183:    case MPI_UNSIGNED_LONG: 
        -:  184:    case MPI_SHORT: 
        -:  185:    case MPI_UNSIGNED_SHORT: 
        -:  186:    case MPI_CHAR: 
        -:  187:#ifdef HAVE_FORTRAN_BINDING
        -:  188:    case MPI_CHARACTER: 
        -:  189:#endif
        -:  190:    case MPI_UNSIGNED_CHAR: 
        -:  191:    case MPI_BYTE: 
        -:  192:/* The length type can be provided without Fortran, so we do so */
        -:  193:#ifdef MPIR_INTEGER1_CTYPE
        -:  194:    case MPI_INTEGER1:
        -:  195:#endif
        -:  196:#ifdef MPIR_INTEGER2_CTYPE
        -:  197:    case MPI_INTEGER2:
        -:  198:#endif
        -:  199:#ifdef MPIR_INTEGER4_CTYPE
        -:  200:    case MPI_INTEGER4:
        -:  201:#endif
        -:  202:#ifdef MPIR_INTEGER8_CTYPE
        -:  203:    case MPI_INTEGER8:
        -:  204:#endif
        -:  205:#ifdef MPIR_INTEGER16_CTYPE
        -:  206:    case MPI_INTEGER16:
        -:  207:#endif
   445801:  208:        return MPI_SUCCESS;
        -:  209:	/* --BEGIN ERROR HANDLING-- */
        -:  210:    default: 
       32:  211:        return MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OP, "**opundefined","**opundefined %s", "MPI_BAND" );
        -:  212:	/* --END ERROR HANDLING-- */
        -:  213:    }
        -:  214:}
        -:  215: