[mpich2-dev] 64-bit MPI_Aint/32-bit MPICH2/ROMIO

Bob Cernohous bobc at us.ibm.com
Thu Feb 28 20:52:40 CST 2008


diff --git a/lib/mpi/mpich2/configure.in b/lib/mpi/mpich2/configure.in
old mode 100644
new mode 100755
index 855f42c..a7c51e1
--- a/lib/mpi/mpich2/configure.in
+++ b/lib/mpi/mpich2/configure.in
@@ -286,6 +286,10 @@ implementation.  option may be a list of common separated names including
     mutex    - Enable error checking on pthread mutexes
     all      - All of the above choices],,enable_g=none)
 dnl
+AC_ARG_WITH(aint-size,
+[--with-aint-size - Override the size of MPI_Aint],,
+with_aint_size=0)
+dnl
 dnl --enable-sharedlibs=kind is set with the PAC_ARG_SHAREDLIBS macro 
 dnl
 dnl AC_ARG_ENABLE(internat,
@@ -4879,13 +4883,14 @@ AC_SUBST(MPICH_TIMER_KIND)
 AC_SUBST(MPILIBNAME)
 AC_SUBST(PMPILIBNAME)
 MPI_AINT=int
+#MPI_AINT="long long"
 for type in int long long_long short ; do
     eval len=\$ac_cv_sizeof_$type
     if test "$len" = "$ac_cv_sizeof_void_p" ; then
         MPI_AINT=`echo $type | sed -e 's/_/ /'`
         # Make the sizeof AINT available to other configures
         MPI_SIZEOF_AINT=$len
-        export MPI_SIZEOF_AINT
+#        export MPI_SIZEOF_AINT
         case $type in
             int)
                 MPI_AINT_FMT_DEC_SPEC="%d"
@@ -4909,13 +4914,59 @@ for type in int long long_long short ; do
                 MPI_AINT_FMT_HEX_SPEC="%x"
             ;;
         esac
-        export MPI_AINT_FMT_DEC_SPEC MPI_AINT_FMT_HEX_SPEC
+#        export MPI_AINT_FMT_DEC_SPEC MPI_AINT_FMT_HEX_SPEC
         break
     fi
 done
-AC_SUBST(MPI_AINT)
-AC_SUBST(MPI_AINT_FMT_DEC_SPEC)
-AC_SUBST(MPI_AINT_FMT_HEX_SPEC)
+if test "$with_aint_size" == "0" ; then
+    # use default size
+    AC_MSG_RESULT([Default MPI_Aint $with_aint_size $MPI_SIZEOF_AINT])
+    with_aint_size = $MPI_SIZEOF_AINT
+    AC_SUBST(with_aint_size)
+fi
+if test "$with_aint_size" == "8" ; then
+    # use 8 byte MPI_Aint override
+    AC_MSG_RESULT([Overriding MPI_Aint $with_aint_size])
+    MPI_SIZEOF_AINT=8
+    MPI_AINT="long long"
+
+    MPI_AINT_FMT_DEC_SPEC="%lld"
+    MPI_AINT_FMT_HEX_SPEC="%#llx"
+
+    MPI_AINT_CAST_TO_VOID_PTR="(void*)(long)"
+    MPI_VOID_PTR_CAST_TO_MPI_AINT="(MPI_Aint)(unsigned long)"
+    MPI_AINT_CAST_TO_LONG_LONG="(long long)"
+
+    export MPI_SIZEOF_AINT
+    export MPI_AINT_FMT_DEC_SPEC MPI_AINT_FMT_HEX_SPEC
+    export MPI_AINT_CAST_TO_VOID_PTR
+    export MPI_VOID_PTR_CAST_TO_MPI_AINT
+    export MPI_AINT_CAST_TO_LONG_LONG
+    AC_SUBST(MPI_AINT)
+    AC_SUBST(MPI_AINT_FMT_DEC_SPEC)
+    AC_SUBST(MPI_AINT_FMT_HEX_SPEC)
+    AC_SUBST(MPI_AINT_CAST_TO_VOID_PTR)
+    AC_SUBST(MPI_VOID_PTR_CAST_TO_MPI_AINT)
+    AC_SUBST(MPI_AINT_CAST_TO_LONG_LONG)
+else
+    # use calculated MPI_Aint values
+    AC_MSG_RESULT([Use configured MPI_Aint $with_aint_size])
+    MPI_AINT_CAST_TO_VOID_PTR="(void*)"
+    MPI_VOID_PTR_CAST_TO_MPI_AINT="(MPI_Aint)(unsigned long)"
+    MPI_AINT_CAST_TO_LONG_LONG="(long long)(unsigned long)"
+
+    export MPI_SIZEOF_AINT
+    export MPI_AINT_FMT_DEC_SPEC MPI_AINT_FMT_HEX_SPEC
+    export MPI_AINT_CAST_TO_VOID_PTR
+    export MPI_VOID_PTR_CAST_TO_MPI_AINT
+    export MPI_AINT_CAST_TO_LONG_LONG
+    AC_SUBST(MPI_AINT)
+    AC_SUBST(MPI_AINT_FMT_DEC_SPEC)
+    AC_SUBST(MPI_AINT_FMT_HEX_SPEC)
+    AC_SUBST(MPI_AINT_CAST_TO_VOID_PTR)
+    AC_SUBST(MPI_VOID_PTR_CAST_TO_MPI_AINT)
+    AC_SUBST(MPI_AINT_CAST_TO_LONG_LONG)
+fi
 
 # If sizeof(mpi_aint) = sizeof(int), set this value
 if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_void_p" ; then
diff --git a/lib/mpi/mpich2/maint/extracterrmsgs b/lib/mpi/mpich2/maint/extracterrmsgs
index 0f912d7..6ecfafd 100755
--- a/lib/mpi/mpich2/maint/extracterrmsgs
+++ b/lib/mpi/mpich2/maint/extracterrmsgs
@@ -372,6 +372,11 @@ sub AddTestCall {
 		print TESTFD "    int i$narg = $narg;\n";
 		$args[$#args+1] = "i$narg";
 	    }
+	    elsif ($type eq "L")
+	    {
+		print TESTFD "    long long i$narg = $narg;\n";
+		$args[$#args+1] = "i$narg";
+	    }
 	    elsif ($type eq "i")
 	    {
 		print TESTFD "    int i$narg = $narg;\n";
@@ -715,7 +720,7 @@ sub ProcessFile
 		    if ($followchar ne "%") {
 			$nargs ++;
 		    }
-		    if (! ($followchar =~ /[%sditpDCRWOEIGFA]/) ) {
+		    if (! ($followchar =~ /[%sditpLDCRWOEIGFA]/) ) {
 			print STDERR "Warning: Unrecognized format specifier in specific message $specific_msg in $filename\n";
 		    }
 		}
diff --git a/lib/mpi/mpich2/src/include/mpi.h.in b/lib/mpi/mpich2/src/include/mpi.h.in
index 3c9f31c..8973900 100644
--- a/lib/mpi/mpich2/src/include/mpi.h.in
+++ b/lib/mpi/mpich2/src/include/mpi.h.in
@@ -303,6 +303,9 @@ typedef @MPI_AINT@ MPI_Aint;
 typedef @MPI_FINT@ MPI_Fint;
 #define MPI_AINT_FMT_DEC_SPEC "@MPI_AINT_FMT_DEC_SPEC@"
 #define MPI_AINT_FMT_HEX_SPEC "@MPI_AINT_FMT_HEX_SPEC@"
+#define MPI_AINT_CAST_TO_VOID_PTR @MPI_AINT_CAST_TO_VOID_PTR@
+#define MPI_VOID_PTR_CAST_TO_MPI_AINT @MPI_VOID_PTR_CAST_TO_MPI_AINT@
+#define MPI_AINT_CAST_TO_LONG_LONG @MPI_AINT_CAST_TO_LONG_LONG@
 
 /* Let ROMIO know that MPI_Offset is already defined */
 #define HAVE_MPI_OFFSET
diff --git a/lib/mpi/mpich2/src/include/mpidbg.h b/lib/mpi/mpich2/src/include/mpidbg.h
index ceaa378..1192ea1 100644
--- a/lib/mpi/mpich2/src/include/mpidbg.h
+++ b/lib/mpi/mpich2/src/include/mpidbg.h
@@ -98,6 +98,7 @@ enum MPIU_DBG_CLASS { MPIU_DBG_PT2PT         = 0x1,
                       MPIU_DBG_NEM_SOCK_DET  = 0x80000,
 		      MPIU_DBG_VC            = 0x100000,
 		      MPIU_DBG_REFCOUNT      = 0x200000,
+		      MPIU_DBG_ROMIO         = 0x400000,
 		      MPIU_DBG_ALL           = (~0) };   /* alias for all */
 
 extern int MPIU_DBG_ActiveClasses;
diff --git a/lib/mpi/mpich2/src/include/mpiutil.h b/lib/mpi/mpich2/src/include/mpiutil.h
index 0d61512..0c20f99 100644
--- a/lib/mpi/mpich2/src/include/mpiutil.h
+++ b/lib/mpi/mpich2/src/include/mpiutil.h
@@ -79,4 +79,32 @@ int MPID_Abort( struct MPID_Comm *comm, int mpi_errno, int exit_code, const char
     }								\
 }
 
+/*
+ * Ensure an MPI_Aint value fits into a positive int.
+ * Useful for detecting overflow when MPI_Aint is larger than an int.
+ *
+ * \param[in]  aint  Variable of type MPI_Aint
+ */
+#define MPID_Ensure_Aint_fits_in_positive_int( aint ) \
+  MPIU_Assert( (aint) == (MPI_Aint)(int)(aint) );
+
+/*
+ * Ensure an MPI_Aint value fits into an unsigned int.
+ * Useful for detecting overflow when MPI_Aint is larger than an 
+ * unsigned int.
+ *
+ * \param[in]  aint  Variable of type MPI_Aint
+ */
+#define MPID_Ensure_Aint_fits_in_uint( aint ) \
+  MPIU_Assert( (aint) == (MPI_Aint)(unsigned int)(aint) );
+
+/*
+ * Ensure an MPI_Aint value fits into a pointer.
+ * Useful for detecting overflow when MPI_Aint is larger than a pointer.
+ *
+ * \param[in]  aint  Variable of type MPI_Aint
+ */
+#define MPID_Ensure_Aint_fits_in_pointer( aint ) \
+  MPIU_Assert( (aint) == (MPI_Aint)(unsigned long) MPI_AINT_CAST_TO_VOID_PTR (aint) );
+
 #endif /* !defined(MPIUTIL_H_INCLUDED) */
diff --git a/lib/mpi/mpich2/src/mpi/datatype/address.c b/lib/mpi/mpich2/src/mpi/datatype/address.c
index 24fc454..5ce6263 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/address.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/address.c
@@ -37,7 +37,7 @@ Input Parameter:
 . location - location in caller memory (choice) 
 
 Output Parameter:
-. address - address of location (integer) 
+. address - address of location (address integer) 
 
     Note:
     This routine is provided for both the Fortran and C programmers.
@@ -88,14 +88,16 @@ int MPI_Address( void *location, MPI_Aint *address )
        standard, I can't tell if this is a compiler bug or a language bug.
     */
 #ifdef CHAR_PTR_IS_ADDRESS
-    *address = (MPI_Aint) ((char *)location);
+    *address = MPI_VOID_PTR_CAST_TO_MPI_AINT ((char *)location);
 #else
     /* Note that this is the "portable" way to generate an address.
        The difference of two pointers is the number of elements
        between them, so this gives the number of chars between location
        and ptr.  As long as sizeof(char) represents one byte, 
        of bytes from 0 to location */
-    *address = (MPI_Aint) ((char *)location - (char *)MPI_BOTTOM);
+    /* To cover the case where a pointer is 32 bits and MPI_Aint is 64 bits,
+       add cast to unsigned so the high order address bit is not sign-extended. */
+    *address = MPI_VOID_PTR_CAST_TO_MPI_AINT ((char *)location - (char *)MPI_BOTTOM);
 #endif
     /* The same code is used in MPI_Get_address */
     
diff --git a/lib/mpi/mpich2/src/mpi/datatype/get_address.c b/lib/mpi/mpich2/src/mpi/datatype/get_address.c
index 5ab1a63..9fdc911 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/get_address.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/get_address.c
@@ -37,7 +37,7 @@ Input Parameter:
 . location - location in caller memory (choice) 
 
 Output Parameter:
-. address - address of location (address) 
+. address - address of location (address integer) 
 
    Notes:
     This routine is provided for both the Fortran and C programmers.
@@ -98,14 +98,14 @@ int MPI_Get_address(void *location, MPI_Aint *address)
        standard, I can't tell if this is a compiler bug or a language bug.
     */
 #ifdef CHAR_PTR_IS_ADDRESS
-    *address = (MPI_Aint) ((char *)location);
+    *address = MPI_VOID_PTR_CAST_TO_MPI_AINT ((char *)location);
 #else
     /* Note that this is the "portable" way to generate an address.
        The difference of two pointers is the number of elements
        between them, so this gives the number of chars between location
        and ptr.  As long as sizeof(char) represents one byte, 
        of bytes from 0 to location */
-    *address = (MPI_Aint) ((char *)location - (char *)MPI_BOTTOM);
+    *address = MPI_VOID_PTR_CAST_TO_MPI_AINT ((char *)location - (char *)MPI_BOTTOM);
 #endif
     /* The same code is used in MPI_Address */
     
diff --git a/lib/mpi/mpich2/src/mpi/datatype/pack.c b/lib/mpi/mpich2/src/mpi/datatype/pack.c
index 22cf41e..88b593b 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/pack.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/pack.c
@@ -195,6 +195,9 @@ int MPI_Pack(void *inbuf,
 		      &last,
 		      (void *) ((char *) outbuf + *position));
 
+    /* Ensure that "last" fits into an int datatype and is positive. */
+    MPID_Ensure_Aint_fits_in_positive_int( last );
+
     *position += (int) last;
 
     MPID_Segment_free(segp);
diff --git a/lib/mpi/mpich2/src/mpi/datatype/pack_external.c b/lib/mpi/mpich2/src/mpi/datatype/pack_external.c
index ef980d5..19dbf00 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/pack_external.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/pack_external.c
@@ -37,13 +37,13 @@
 . inbuf - input buffer start (choice)  
 . incount - number of input data items (integer)  
 . datatype - datatype of each input data item (handle)  
-- outsize - output buffer size, in bytes (integer)  
+- outcount - output buffer size, in bytes (address integer)  
 
    Output Parameter:
 . outbuf - output buffer start (choice)  
 
    Input/Output Parameter:
-. position - current position in buffer, in bytes (integer)  
+. position - current position in buffer, in bytes (address integer)  
 
 .N ThreadSafe
 
@@ -134,12 +134,15 @@ int MPI_Pack_external(char *datarep,
     first = 0;
     last  = SEGMENT_IGNORE_LAST;
 
+    /* Ensure that position fits in a pointer */
+    MPID_Ensure_Aint_fits_in_pointer( *position );
+
     MPID_Segment_pack_external32(segp,
 				 first,
 				 &last,
 				 (void *)((char *) outbuf + *position));
 
-    *position += (int) last;
+    *position += last;
 
     MPID_Segment_free(segp);
 
@@ -155,7 +158,8 @@ int MPI_Pack_external(char *datarep,
     {
 	mpi_errno = MPIR_Err_create_code(
 	    mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_pack_external",
-	    "**mpi_pack_external %s %p %d %D %p %d %p", datarep, inbuf, incount, datatype, outbuf, outcount, position);
+	    "**mpi_pack_external %s %p %d %D %p %L %p", 
+	    datarep, inbuf, incount, datatype, outbuf, MPI_AINT_CAST_TO_LONG_LONG outcount, position);
     }
 #   endif
     mpi_errno = MPIR_Err_return_comm( 0, FCNAME, mpi_errno );
diff --git a/lib/mpi/mpich2/src/mpi/datatype/pack_external_size.c b/lib/mpi/mpich2/src/mpi/datatype/pack_external_size.c
index 6a8ae13..ced3c00 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/pack_external_size.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/pack_external_size.c
@@ -40,7 +40,7 @@
 - datatype - datatype of each input data item (handle)  
 
    Output Parameters:
-. size - output buffer size, in bytes (integer)  
+. size - output buffer size, in bytes (address integer)  
 
 .N ThreadSafe
 
diff --git a/lib/mpi/mpich2/src/mpi/datatype/type_create_hindexed.c b/lib/mpi/mpich2/src/mpi/datatype/type_create_hindexed.c
index fde5ced..63054d3 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/type_create_hindexed.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/type_create_hindexed.c
@@ -36,7 +36,7 @@
 + count - number of blocks --- also number of entries in 
   displacements and blocklengths (integer) 
 . blocklengths - number of elements in each block (array of nonnegative integers) 
-. displacements - byte displacement of each block (array of integer) 
+. displacements - byte displacement of each block (array of address integers) 
 - oldtype - old datatype (handle) 
 
    Output Parameter:
diff --git a/lib/mpi/mpich2/src/mpi/datatype/type_create_hvector.c b/lib/mpi/mpich2/src/mpi/datatype/type_create_hvector.c
index 78ddd92..2cfe2da 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/type_create_hvector.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/type_create_hvector.c
@@ -35,7 +35,7 @@
    Input Parameters:
 + count - number of blocks (nonnegative integer) 
 . blocklength - number of elements in each block (nonnegative integer) 
-. stride - number of bytes between start of each block (integer) 
+. stride - number of bytes between start of each block (address integer) 
 - oldtype - old datatype (handle) 
 
    Output Parameter:
@@ -124,8 +124,8 @@ int MPI_Type_create_hvector(int count,
 	mpi_errno = MPIR_Err_create_code(
 	    mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
 	    MPI_ERR_OTHER, "**mpi_type_create_hvector",
-	    "**mpi_type_create_hvector %d %d %d %D %p", count,
-	    blocklength, stride, oldtype, newtype);
+	    "**mpi_type_create_hvector %d %d %L %D %p", count,
+	    blocklength, MPI_AINT_CAST_TO_LONG_LONG stride, oldtype, newtype);
     }
 #   endif
     mpi_errno = MPIR_Err_return_comm( NULL, FCNAME, mpi_errno );
diff --git a/lib/mpi/mpich2/src/mpi/datatype/type_extent.c b/lib/mpi/mpich2/src/mpi/datatype/type_extent.c
index ab2e2d8..fe278b8 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/type_extent.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/type_extent.c
@@ -37,7 +37,7 @@ Input Parameters:
 . datatype - datatype (handle) 
 
 Output Parameter:
-. extent - datatype extent (integer) 
+. extent - datatype extent (address integer) 
 
 .N SignalSafe
 
diff --git a/lib/mpi/mpich2/src/mpi/datatype/type_get_extent.c b/lib/mpi/mpich2/src/mpi/datatype/type_get_extent.c
index c5f53f1..0064051 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/type_get_extent.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/type_get_extent.c
@@ -37,8 +37,8 @@
 . datatype - datatype to get information on (handle) 
 
    Output Parameters:
-+ lb - lower bound of datatype (integer) 
-- extent - extent of datatype (integer) 
++ lb - lower bound of datatype (address integer) 
+- extent - extent of datatype (address integer) 
 
 .N SignalSafe
 
diff --git a/lib/mpi/mpich2/src/mpi/errhan/errnames.txt b/lib/mpi/mpich2/src/mpi/errhan/errnames.txt
index 2a6e42e..c4ba160 100644
--- a/lib/mpi/mpich2/src/mpi/errhan/errnames.txt
+++ b/lib/mpi/mpich2/src/mpi/errhan/errnames.txt
@@ -1337,7 +1337,7 @@ with MPI_Alloc_mem.
 **mpi_info_set:MPI_Info_set failed
 **mpi_info_set %I %s %s:MPI_Info_set(%I, key=%s, value=%s) failed
 **mpi_pack_external:MPI_Pack_external failed
-**mpi_pack_external %s %p %d %D %p %d %p:MPI_Pack_external(datarep=%s, inbuf=%p, incount=%d, %D, outbuf=%p, outcount=%d, position=%p) failed
+**mpi_pack_external %s %p %d %D %p %L %p:MPI_Pack_external(datarep=%s, inbuf=%p, incount=%d, %D, outbuf=%p, outcount=%L, position=%p) failed
 **mpi_pack_external_size:MPI_Pack_external_size failed
 **mpi_pack_external_size %s %d %D %p:MPI_Pack_external_size(datarep=%s, incount=%d, %D, size=%p) failed
 **mpi_request_get_status:MPI_Request_get_status failed
@@ -1351,7 +1351,7 @@ with MPI_Alloc_mem.
 **mpi_type_create_hindexed:MPI_Type_create_hindexed failed
 **mpi_type_create_hindexed %d %p %p %D %p:MPI_Type_create_hindexed(count=%d, array_of_blocklengths=%p, array_of_displacements=%p, %D, newtype=%p) failed
 **mpi_type_create_hvector:MPI_Type_create_hvector failed
-**mpi_type_create_hvector %d %d %d %D %p:MPI_Type_create_hvector(count=%d, blocklength=%d, stride=%d, %D, newtype=%p) failed
+**mpi_type_create_hvector %d %d %L %D %p:MPI_Type_create_hvector(count=%d, blocklength=%d, stride=%L, %D, newtype=%p) failed
 **mpi_type_create_indexed_block:MPI_Type_create_indexed_block failed
 **mpi_type_create_indexed_block %d %d %p %D %p:MPI_Type_create_indexed_block(count=%d, blocklength=%d, array_of_displacements=%p, %D, newtype=%p) failed
 **mpi_type_create_resized:MPI_Type_create_resized failed
diff --git a/lib/mpi/mpich2/src/mpi/errhan/errutil.c b/lib/mpi/mpich2/src/mpi/errhan/errutil.c
index 72813ae..2e1e511 100644
--- a/lib/mpi/mpich2/src/mpi/errhan/errutil.c
+++ b/lib/mpi/mpich2/src/mpi/errhan/errutil.c
@@ -914,6 +914,7 @@ static int vsnprintf_mpi(char *str, size_t maxlen, const char *fmt_orig,
     MPI_Errhandler E;
     char *s;
     int t, i, d, mpi_errno=MPI_SUCCESS;
+    long long ll;
     void *p;
 
     fmt = MPIU_Strdup(fmt_orig);
@@ -954,6 +955,10 @@ static int vsnprintf_mpi(char *str, size_t maxlen, const char *fmt_orig,
 	    d = va_arg(list, int);
 	    MPIU_Snprintf(str, maxlen, "%d", d);
 	    break;
+	case (int)'L':
+	    ll = va_arg(list, long long);
+	    MPIU_Snprintf(str, maxlen, "%lld", ll);
+	    break;
 	case (int)'i':
 	    i = va_arg(list, int);
 	    switch (i)
diff --git a/lib/mpi/mpich2/src/mpi/romio/adio/common/flatten.c b/lib/mpi/mpich2/src/mpi/romio/adio/common/flatten.c
index ab3f211..20b0640 100644
--- a/lib/mpi/mpich2/src/mpi/romio/adio/common/flatten.c
+++ b/lib/mpi/mpich2/src/mpi/romio/adio/common/flatten.c
@@ -76,9 +76,8 @@ void ADIOI_Flatten_datatype(MPI_Datatype datatype)
 /*    FPRINTF(stderr, "%d\n", flat->count);*/
 
     if (flat->count) {
-	flat->blocklens = (int *) ADIOI_Malloc(flat->count * sizeof(int));
-	flat->indices = (ADIO_Offset *) ADIOI_Malloc(flat->count * \
-						  sizeof(ADIO_Offset));
+	flat->blocklens = (ADIO_Offset *) ADIOI_Malloc(flat->count * sizeof(ADIO_Offset));
+	flat->indices = (ADIO_Offset *) ADIOI_Malloc(flat->count * sizeof(ADIO_Offset));
     }
 	
     curr_index = 0;
@@ -841,7 +840,7 @@ int ADIOI_Count_contiguous_blocks(MPI_Datatype datatype, int *curr_index)
 void ADIOI_Optimize_flattened(ADIOI_Flatlist_node *flat_type)
 {
     int i, j, opt_blocks;
-    int *opt_blocklens;
+    ADIO_Offset *opt_blocklens;
     ADIO_Offset *opt_indices;
 
     opt_blocks = 1;
@@ -856,7 +855,7 @@ void ADIOI_Optimize_flattened(ADIOI_Flatlist_node *flat_type)
     /* if we can't reduce the number of blocks, quit now */
     if (opt_blocks == flat_type->count) return;
 
-    opt_blocklens = (int *) ADIOI_Malloc(opt_blocks * sizeof(int));
+    opt_blocklens = (ADIO_Offset *) ADIOI_Malloc(opt_blocks * sizeof(ADIO_Offset));
     opt_indices = (ADIO_Offset *)ADIOI_Malloc(opt_blocks*sizeof(ADIO_Offset));
 
     /* fill in new blocklists */
diff --git a/lib/mpi/mpich2/src/mpi/romio/adio/include/adioi.h b/lib/mpi/mpich2/src/mpi/romio/adio/include/adioi.h
index 581ca5a..225e94a 100644
--- a/lib/mpi/mpich2/src/mpi/romio/adio/include/adioi.h
+++ b/lib/mpi/mpich2/src/mpi/romio/adio/include/adioi.h
@@ -92,8 +92,7 @@ enum {
 typedef struct ADIOI_Fl_node {  
     MPI_Datatype type;
     int count;                   /* no. of contiguous blocks */
-    int *blocklens;              /* array of contiguous block lengths (bytes)*/
-    /* may need to make it ADIO_Offset *blocklens */
+    ADIO_Offset *blocklens;      /* array of contiguous block lengths (bytes)*/
     ADIO_Offset *indices;        /* array of byte offsets of each block */
     struct ADIOI_Fl_node *next;  /* pointer to next node */
 } ADIOI_Flatlist_node;
@@ -644,5 +643,23 @@ int  ADIOI_MPE_postwrite_a;
 int  ADIOI_MPE_postwrite_b;
 #endif
 
+#if 1  /*todo fix dependency on mpich? */
+/* Assert that this MPI_Aint value can be cast to a ptr value without problem.*/
+/* Basic idea is the value should be unchanged after casting 
+   (no loss of (meaningful) high order bytes in 8 byte MPI_Aint 
+      to (possible) 4 byte ptr cast)                              */
+/* Should work even on 64bit or old 32bit configs                 */
+  /* Use MPID_Ensure_Aint_fits_in_pointer from mpiutil.h and 
+         MPI_AINT_CAST_TO_VOID_PTR from configure (mpi.h) */
+  #include "mpiimpl.h"
+
+  #define ADIOI_AINT_CAST_TO_VOID_PTR MPI_AINT_CAST_TO_VOID_PTR
+  #define ADIOI_ENSURE_AINT_FITS_IN_PTR(aint_value) MPID_Ensure_Aint_fits_in_pointer(aint_value)
+#else
+  #include <assert.h>
+  #define ADIOI_AINT_CAST_TO_VOID_PTR (void*)
+  #define ADIOI_ENSURE_AINT_FITS_IN_PTR(aint_value) 
+#endif
+
 #endif
 




More information about the mpich2-dev mailing list