00001 
00002 
00003 
00004 
00005 
00006 
00007 #include "adio.h"
00008 
00009 
00010 
00011 
00012 #ifdef AMPI
00013 void MPIR_Datatype_iscontig(MPI_Datatype datatype, int *flag){
00014   AMPI_Type_is_contiguous(datatype, flag);
00015 }
00016 
00017 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
00018 {
00019     MPIR_Datatype_iscontig(datatype, flag);
00020 }
00021 
00022 #elif (defined(MPICH) || defined(MPICH2))
00023 
00024 void MPIR_Datatype_iscontig(MPI_Datatype datatype, int *flag);
00025 
00026 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
00027 {
00028     MPIR_Datatype_iscontig(datatype, flag);
00029 
00030     
00031 
00032 
00033 #ifdef MPICH2
00034     if (*flag) {
00035         MPI_Aint true_extent, true_lb;
00036         
00037         MPI_Type_get_true_extent(datatype, &true_lb, &true_extent);
00038 
00039         if (true_lb > 0)
00040             *flag = 0;
00041     }
00042 #endif
00043 }
00044 
00045 #elif (defined(MPIHP) && defined(HAVE_MPI_INFO))
00046 
00047 
00048 int hpmp_dtiscontig(MPI_Datatype datatype);
00049 
00050 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
00051 {
00052     *flag = hpmp_dtiscontig(datatype);
00053 }
00054 
00055 #elif (defined(MPISGI) && !defined(NO_MPI_SGI_type_is_contig))
00056 
00057 int MPI_SGI_type_is_contig(MPI_Datatype datatype);
00058 
00059 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
00060 {
00061     MPI_Aint displacement;
00062     MPI_Type_lb(datatype, &distplacement);
00063 
00064     
00065 
00066 
00067 
00068     *flag = MPI_SGI_type_is_contig(datatype) && (displacement == 0);
00069 }
00070 
00071 #elif defined(OMPI_BUILDING) && OMPI_BUILDING
00072 
00073 
00074 
00075 
00076 #else
00077 
00078 void ADIOI_Datatype_iscontig(MPI_Datatype datatype, int *flag)
00079 {
00080     int nints, nadds, ntypes, combiner;
00081     int *ints, ni, na, nt, cb;
00082     MPI_Aint *adds;
00083     MPI_Datatype *types;
00084 
00085     MPI_Type_get_envelope(datatype, &nints, &nadds, &ntypes, &combiner);
00086 
00087     switch (combiner) {
00088     case MPI_COMBINER_NAMED:
00089     *flag = 1;
00090     break;
00091     case MPI_COMBINER_CONTIGUOUS:
00092     ints = (int *) ADIOI_Malloc((nints+1)*sizeof(int));
00093     adds = (MPI_Aint *) ADIOI_Malloc((nadds+1)*sizeof(MPI_Aint));
00094     types = (MPI_Datatype *) ADIOI_Malloc((ntypes+1)*sizeof(MPI_Datatype));
00095     MPI_Type_get_contents(datatype, nints, nadds, ntypes, ints,
00096                   adds, types); 
00097     ADIOI_Datatype_iscontig(types[0], flag);
00098 
00099 #ifndef MPISGI
00100 
00101 
00102     MPI_Type_get_envelope(types[0], &ni, &na, &nt, &cb);
00103     if (cb != MPI_COMBINER_NAMED) MPI_Type_free(types);
00104 #endif
00105 
00106     ADIOI_Free(ints);
00107     ADIOI_Free(adds);
00108     ADIOI_Free(types);
00109     break;
00110     default:
00111     *flag = 0;
00112     break;
00113     }
00114 
00115     
00116 
00117 }
00118 #endif