示例#1
0
文件: util.c 项目: jeffhammond/mpich
static inline int mpi_to_ofi(MPI_Datatype dt, enum fi_datatype *fi_dt, MPI_Op op, enum fi_op *fi_op)
{
    *fi_dt = FI_DATATYPE_LAST;
    *fi_op = FI_ATOMIC_OP_LAST;

    if (isS_INT(dt))
        *fi_dt = FI_INT32;
    else if (isUS_INT(dt))
        *fi_dt = FI_UINT32;
    else if (isFLOAT(dt))
        *fi_dt = FI_FLOAT;
    else if (isDOUBLE(dt))
        *fi_dt = FI_DOUBLE;
    else if (isLONG_DOUBLE(dt))
        *fi_dt = FI_LONG_DOUBLE;
    else if (isS_CHAR(dt))
        *fi_dt = FI_INT8;
    else if (isUS_CHAR(dt))
        *fi_dt = FI_UINT8;
    else if (isS_SHORT(dt))
        *fi_dt = FI_INT16;
    else if (isUS_SHORT(dt))
        *fi_dt = FI_UINT16;
    else if (isS_LONG(dt))
        *fi_dt = FI_INT64;
    else if (isUS_LONG(dt))
        *fi_dt = FI_UINT64;
    else if (isS_LONG_LONG(dt))
        *fi_dt = FI_INT64;
    else if (isUS_LONG_LONG(dt))
        *fi_dt = FI_UINT64;
    else if (isSINGLE_COMPLEX(dt))
        *fi_dt = FI_FLOAT_COMPLEX;
    else if (isDOUBLE_COMPLEX(dt))
        *fi_dt = FI_DOUBLE_COMPLEX;
    else if (isLOC_TYPE(dt))
        *fi_dt = FI_DATATYPE_LAST;
    else if (isLOGICAL(dt))
        *fi_dt = FI_UINT32;
    else if (isBOOL(dt))
        *fi_dt = FI_UINT8;

    if (*fi_dt == FI_DATATYPE_LAST)
        goto fn_fail;

    *fi_op = FI_ATOMIC_OP_LAST;

    switch (op) {
        case MPI_SUM:
            *fi_op = FI_SUM;
            goto fn_exit;

        case MPI_PROD:
            *fi_op = FI_PROD;
            goto fn_exit;

        case MPI_MAX:
            *fi_op = FI_MAX;
            goto fn_exit;

        case MPI_MIN:
            *fi_op = FI_MIN;
            goto fn_exit;

        case MPI_BAND:
            *fi_op = FI_BAND;
            goto fn_exit;

        case MPI_BOR:
            *fi_op = FI_BOR;
            goto fn_exit;

        case MPI_BXOR:
            *fi_op = FI_BXOR;
            goto fn_exit;
            break;

        case MPI_LAND:
            if (isLONG_DOUBLE(dt))
                goto fn_fail;

            *fi_op = FI_LAND;
            goto fn_exit;

        case MPI_LOR:
            if (isLONG_DOUBLE(dt))
                goto fn_fail;

            *fi_op = FI_LOR;
            goto fn_exit;

        case MPI_LXOR:
            if (isLONG_DOUBLE(dt))
                goto fn_fail;

            *fi_op = FI_LXOR;
            goto fn_exit;

        case MPI_REPLACE:{
                *fi_op = FI_ATOMIC_WRITE;
                goto fn_exit;
            }

        case MPI_NO_OP:{
                *fi_op = FI_ATOMIC_READ;
                goto fn_exit;
            }

        case MPI_OP_NULL:{
                *fi_op = FI_CSWAP;
                goto fn_exit;
            }

        default:
            goto fn_fail;
    }

  fn_exit:
    return MPI_SUCCESS;
  fn_fail:
    return -1;
}
示例#2
0
int MPIDI_Datatype_to_pami(MPI_Datatype        dt,
                           pami_type_t        *pdt,
                           MPI_Op              op,
                           pami_data_function *pop,
                           int                *musupport)
{
   *musupport = MUSUPPORTED;
   *pdt = PAMI_TYPE_NULL;
   if(op != -1)
      *pop = PAMI_DATA_NOOP;
   if(isS_INT(dt))       *pdt = PAMI_TYPE_SIGNED_INT;
   else if(isUS_INT(dt)) *pdt = PAMI_TYPE_UNSIGNED_INT;
   else if(isFLOAT(dt))  *pdt = PAMI_TYPE_FLOAT;
   else if(isDOUBLE(dt)) *pdt = PAMI_TYPE_DOUBLE;
   else if(isLONG_DOUBLE(dt)) *pdt = PAMI_TYPE_LONG_DOUBLE;
   else
   {
      *musupport = MUUNSUPPORTED;
      if(isS_CHAR(dt))              *pdt = PAMI_TYPE_SIGNED_CHAR;
      else if(isUS_CHAR(dt))        *pdt = PAMI_TYPE_UNSIGNED_CHAR;
      else if(isS_SHORT(dt))        *pdt = PAMI_TYPE_SIGNED_SHORT;
      else if(isUS_SHORT(dt))       *pdt = PAMI_TYPE_UNSIGNED_SHORT;
      else if(isS_LONG(dt))         *pdt = PAMI_TYPE_SIGNED_LONG;
      else if(isUS_LONG(dt))        *pdt = PAMI_TYPE_UNSIGNED_LONG;
      else if(isS_LONG_LONG(dt))    *pdt = PAMI_TYPE_SIGNED_LONG_LONG;
      else if(isUS_LONG_LONG(dt))   *pdt = PAMI_TYPE_UNSIGNED_LONG_LONG;
      else if(isSINGLE_COMPLEX(dt)) *pdt = PAMI_TYPE_SINGLE_COMPLEX;
      else if(isDOUBLE_COMPLEX(dt)) *pdt = PAMI_TYPE_DOUBLE_COMPLEX;
      else if(isLOC_TYPE(dt))
      {
         switch(dt)
         {
            case MPI_2INT:              *pdt = PAMI_TYPE_LOC_2INT;       break;
            case MPI_FLOAT_INT:         *pdt = PAMI_TYPE_LOC_FLOAT_INT;  break;
            case MPI_DOUBLE_INT:        *pdt = PAMI_TYPE_LOC_DOUBLE_INT; break;
            case MPI_SHORT_INT:         *pdt = PAMI_TYPE_LOC_SHORT_INT;  break;

            case MPI_LONG_INT:          *pdt = PAMI_TYPE_LOC_LONG_INT;   break;
            case MPI_LONG_DOUBLE_INT:   *pdt = PAMI_TYPE_LOC_LONGDOUBLE_INT;  break;
            default:
              /* The following is needed to catch missing fortran bindings */
              if (dt == MPI_2REAL)
                *pdt = PAMI_TYPE_LOC_2FLOAT;
              else if (dt == MPI_2DOUBLE_PRECISION)
                *pdt = PAMI_TYPE_LOC_2DOUBLE;
              else if (dt == MPI_2INTEGER)
                *pdt = PAMI_TYPE_LOC_2INT;
         }
         /* 
          * There are some 2-element types that PAMI doesn't support, so we 
          * need to bail on anything that's left of the LOC_TYPEs 
          */
         if(*pdt == PAMI_TYPE_NULL) return -1;

         if(op == -1) return MPI_SUCCESS;
         if(op == MPI_MINLOC)
         {
            *pop = PAMI_DATA_MINLOC;
            return MPI_SUCCESS;
         }
         if(op == MPI_MAXLOC) 
         {
            *pop = PAMI_DATA_MAXLOC;
            return MPI_SUCCESS;
         }
         if(op == MPI_REPLACE) 
         {
            *pop = PAMI_DATA_COPY;
            return MPI_SUCCESS;
         }
         else return -1;
      }
      else if(isLOGICAL(dt))
      {
         *pdt = PAMI_TYPE_LOGICAL4;
         if(op == -1) return MPI_SUCCESS;
         if(op == MPI_LOR) 
         {   
            *pop = PAMI_DATA_LOR;
            return MPI_SUCCESS;
         }
         if(op == MPI_LAND) 
         {   
            *pop = PAMI_DATA_LAND;
            return MPI_SUCCESS;
         }
         if(op == MPI_LXOR) 
         {   
            *pop = PAMI_DATA_LXOR;
            return MPI_SUCCESS;
         }
         if(op == MPI_REPLACE) 
         {   
            *pop = PAMI_DATA_COPY;
            return MPI_SUCCESS;
         }
         return -1;
      }
      else if(isBOOL(dt))
      {
         *pdt = PAMI_TYPE_LOGICAL1;
         if(op == -1) return MPI_SUCCESS;
         if(op == MPI_LOR) 
         {   
            *pop = PAMI_DATA_LOR;
            return MPI_SUCCESS;
         }
         if(op == MPI_LAND) 
         {   
            *pop = PAMI_DATA_LAND;
            return MPI_SUCCESS;
         }
         if(op == MPI_LXOR) 
         {   
            *pop = PAMI_DATA_LXOR;
            return MPI_SUCCESS;
         }
         if(op == MPI_REPLACE) 
         {   
            *pop = PAMI_DATA_COPY;
            return MPI_SUCCESS;
         }
         return -1;
      }
   }

   if(*pdt == PAMI_TYPE_NULL) return -1;

   if(op == -1) return MPI_SUCCESS; /* just doing DT conversion */

   *pop = PAMI_DATA_NOOP;
   switch(op)
   {
      case MPI_SUM: *pop = PAMI_DATA_SUM; return MPI_SUCCESS; break;
      case MPI_PROD: *pop = PAMI_DATA_PROD; return MPI_SUCCESS; break;
      case MPI_MAX: *pop = PAMI_DATA_MAX; return MPI_SUCCESS; break;
      case MPI_MIN: *pop = PAMI_DATA_MIN; return MPI_SUCCESS; break;
      case MPI_BAND: *pop = PAMI_DATA_BAND; return MPI_SUCCESS; break;
      case MPI_BOR: *pop = PAMI_DATA_BOR; return MPI_SUCCESS; break;
      case MPI_BXOR: *pop = PAMI_DATA_BXOR; return MPI_SUCCESS; break;
      case MPI_LAND: 
         if(isLONG_DOUBLE(dt)) return -1; 
         *pop = PAMI_DATA_LAND; return MPI_SUCCESS; break;
      case MPI_LOR: 
         if(isLONG_DOUBLE(dt)) return -1; 
         *pop = PAMI_DATA_LOR; return MPI_SUCCESS; break;
      case MPI_LXOR: 
         if(isLONG_DOUBLE(dt)) return -1; 
         *pop = PAMI_DATA_LXOR; return MPI_SUCCESS; break;
      case MPI_REPLACE: *pop = PAMI_DATA_COPY; return MPI_SUCCESS; break;
   }
   if(*pop == PAMI_DATA_NOOP) return -1;

   return MPI_SUCCESS;
}