root/ompi/mca/io/romio321/romio/adio/common/iscontig.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_Datatype_iscontig
  2. ADIOI_Datatype_iscontig
  3. ADIOI_Datatype_iscontig
  4. ADIOI_Datatype_iscontig

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *   Copyright (C) 1997 University of Chicago. 
   4  *   See COPYRIGHT notice in top-level directory.
   5  */
   6 
   7 #include "adio.h"
   8 /* #ifdef MPISGI
   9 #include "mpisgi2.h"
  10 #endif */
  11 
  12 #if defined(MPICH)
  13 /* MPICH also provides this routine */
  14 void MPIR_Datatype_iscontig(MPI_Datatype datatype, int *flag);
  15 
  16 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
  17 {
  18     MPIR_Datatype_iscontig(datatype, flag);
  19 
  20     /* if the datatype is reported as contigous, check if the true_lb is
  21      * non-zero, and if so, mark the datatype as noncontiguous */
  22     if (*flag) {
  23         MPI_Aint true_extent, true_lb;
  24 
  25         MPI_Type_get_true_extent(datatype, &true_lb, &true_extent);
  26 
  27         if (true_lb > 0)
  28             *flag = 0;
  29     }
  30 }
  31 
  32 #elif (defined(MPIHP) && defined(HAVE_MPI_INFO))
  33 /* i.e. HPMPI 1.4 only */
  34 
  35 int hpmp_dtiscontig(MPI_Datatype datatype);
  36 
  37 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
  38 {
  39     *flag = hpmp_dtiscontig(datatype);
  40 }
  41 
  42 #elif (defined(MPISGI) && !defined(NO_MPI_SGI_type_is_contig))
  43 
  44 int MPI_SGI_type_is_contig(MPI_Datatype datatype);
  45 
  46 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
  47 {
  48     MPI_Aint displacement;
  49     MPI_Type_lb(datatype, &distplacement);
  50 
  51     /* SGI's MPI_SGI_type_is_contig() returns true for indexed
  52      * datatypes with holes at the beginning, which causes
  53      * problems with ROMIO's use of this function.
  54      */
  55     *flag = MPI_SGI_type_is_contig(datatype) && (displacement == 0);
  56 }
  57 
  58 #elif defined(OMPI_BUILDING) && OMPI_BUILDING
  59 
  60 /* void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag) is defined
  61  * and implemented in OpenMPI itself */
  62 
  63 #else
  64 
  65 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
  66 {
  67     int nints, nadds, ntypes, combiner;
  68     int *ints, ni, na, nt, cb;
  69     MPI_Aint *adds;
  70     MPI_Datatype *types;
  71 
  72     MPI_Type_get_envelope(datatype, &nints, &nadds, &ntypes, &combiner);
  73 
  74     switch (combiner) {
  75     case MPI_COMBINER_NAMED:
  76         *flag = 1;
  77         break;
  78     case MPI_COMBINER_CONTIGUOUS:
  79         ints = (int *) ADIOI_Malloc((nints+1)*sizeof(int));
  80         adds = (MPI_Aint *) ADIOI_Malloc((nadds+1)*sizeof(MPI_Aint));
  81         types = (MPI_Datatype *) ADIOI_Malloc((ntypes+1)*sizeof(MPI_Datatype));
  82         MPI_Type_get_contents(datatype, nints, nadds, ntypes, ints,
  83                               adds, types); 
  84         ADIOI_Datatype_iscontig(types[0], flag);
  85 
  86 #ifndef MPISGI
  87 /* There is a bug in SGI's impl. of MPI_Type_get_contents. It doesn't
  88    return new datatypes. Therefore no need to free. */
  89         MPI_Type_get_envelope(types[0], &ni, &na, &nt, &cb);
  90         if (cb != MPI_COMBINER_NAMED) MPI_Type_free(types);
  91 #endif
  92 
  93         ADIOI_Free(ints);
  94         ADIOI_Free(adds);
  95         ADIOI_Free(types);
  96         break;
  97     default:
  98         *flag = 0;
  99         break;
 100     }
 101 
 102     /* This function needs more work. It should check for contiguity 
 103        in other cases as well.*/
 104 }
 105 #endif

/* [<][>][^][v][top][bottom][index][help] */