[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.1b1-165-g12478f2

mysql vizuser noreply at mpich.org
Thu Oct 31 11:24:49 CDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  12478f2f41665a2c207333b16215c30e853dfa99 (commit)
       via  9f8bc14f1fb1c61535a928b0dbab59b2794bc773 (commit)
       via  0f06d7ac36d5b510992cf071067f22618fdc1aa7 (commit)
       via  e289f45f4e42a310e994a7a9c05ab6ffe44a5e73 (commit)
       via  255780e99270ad931b33d0480a76555f780b6849 (commit)
       via  d15c4289c05f26afcd1fa8806c941bcd916b182d (commit)
       via  6f267e79b478df773d2343a6738e1cfadd28c995 (commit)
       via  bf57cc474ad6e29469bd91dd67b680c533edcd02 (commit)
       via  91e91a4027c734b2d994aa10671f3e99f71465c7 (commit)
       via  e192ccc594a0f086c4bb5239d413df0e1f3d4f03 (commit)
       via  615d1acb0578253395f4fb9b00d07f52cb30482a (commit)
       via  e6962c162c743eb130e732e1d3ae8a8f6f7c719c (commit)
       via  d4e6334c3ae2ae9925306087051b5a930d9ffde2 (commit)
       via  c66f901220b086cda4cdc5d3739abc66a885bee0 (commit)
       via  e527fa1dea458e32f97083d49e8689666e5bb363 (commit)
       via  e518cb4c0c80bf14b5eb828fc32397991a8d38e8 (commit)
       via  d1bf416117ccff40533f9c3007ba2859b944fb47 (commit)
      from  4f691ba86f15151b51ec808943a2b940887c5e22 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/12478f2f41665a2c207333b16215c30e853dfa99

commit 12478f2f41665a2c207333b16215c30e853dfa99
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Fri Oct 18 16:54:12 2013 -0500

    type promotion for MPIR_Bsend structure
    
    configure determines the right type for MPI_Aint, MPI_Fint, and
    MPI_Count, so we have to move the MPIR_Bsend checks later in configure.
    Then we can promote a plain int to MPI_Aint.
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/configure.ac b/configure.ac
index 5d7bf15..5300fa8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4486,29 +4486,6 @@ int main(int argc, char **argv )
          AC_DEFINE(HAVE_ANY_INT32_T_ALIGNMENT,1,[Define if int32_t works with any alignment])
     fi
 fi
-
-# Get the size for the bsendoverhead
-AC_CHECK_SIZEOF(MPIR_Bsend_data_t,0,[
-#define MPI_Datatype int
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include "${master_top_srcdir}/src/include/mpibsend.h"]
-)
-if test "$ac_cv_sizeof_MPIR_Bsend_data_t" = "0" ; then
-    AC_MSG_ERROR([Unable to determine the size of MPI_BSEND_OVERHEAD])
-    # In the past, a default of 128 was used (still likely good enough),
-    # but the autoconf SIZEOF macro has been changed to ignore the second
-    # argument, so code that depended on the prior defined behavior now
-    # silently breaks.
-fi
-BSEND_OVERHEAD=$ac_cv_sizeof_MPIR_Bsend_data_t
-export BSEND_OVERHEAD
-AC_SUBST(BSEND_OVERHEAD)
-
 # Check for special compile characteristics
 # If we are either gcc or icc, see if we can use __asm__
 # We test on prog_gcc to allow gcc by any name; if we are using
@@ -5244,6 +5221,31 @@ AC_DEFINE_UNQUOTED(MPIU_SIZE_T,$MPIU_SIZE_T,[Set to a type that can express the
 if test "$ac_cv_sizeof_void_p" -lt "$aint_size" ; then
     AC_DEFINE(USE_AINT_FOR_ATTRVAL,1,[Define if MPI_Aint should be used instead of void * for storing attribute values])
 fi
+
+# with MPI_AINT defined, now we can
+# Get the size for the bsendoverhead
+AC_CHECK_SIZEOF(MPIR_Bsend_data_t,0,[
+#define MPI_Datatype int
+typedef $MPI_AINT MPI_Aint;
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include "${master_top_srcdir}/src/include/mpibsend.h"]
+)
+if test "$ac_cv_sizeof_MPIR_Bsend_data_t" = "0" ; then
+    AC_MSG_ERROR([Unable to determine the size of MPI_BSEND_OVERHEAD])
+    # In the past, a default of 128 was used (still likely good enough),
+    # but the autoconf SIZEOF macro has been changed to ignore the second
+    # argument, so code that depended on the prior defined behavior now
+    # silently breaks.
+fi
+BSEND_OVERHEAD=$ac_cv_sizeof_MPIR_Bsend_data_t
+export BSEND_OVERHEAD
+AC_SUBST(BSEND_OVERHEAD)
+
 #
 # See if we need to update the timer type (which was converted to uppercase)
 if test "$timer_type" = "DEVICE" ; then
diff --git a/src/include/mpibsend.h b/src/include/mpibsend.h
index 05b7c7d..91996d7 100644
--- a/src/include/mpibsend.h
+++ b/src/include/mpibsend.h
@@ -53,7 +53,7 @@ struct MPID_Comm;
    request is not currently available */
 typedef struct MPIR_Bsend_msg {
     void         *msgbuf;
-    int          count;     /* int type to match needs of Pack routine */
+    MPI_Aint     count;
     MPI_Datatype dtype;
     int          tag;
     struct MPID_Comm    *comm_ptr;

http://git.mpich.org/mpich.git/commitdiff/9f8bc14f1fb1c61535a928b0dbab59b2794bc773

commit 9f8bc14f1fb1c61535a928b0dbab59b2794bc773
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Fri Oct 18 16:25:57 2013 -0500

    defective MPI_Pack/Unpack/Pack_size interface
    
    MPI_Pack, MPI_Unpack, and MPI_Pack_size use integers to describe counts
    of bytes and posistions in a bytestream.  In a world of 2 GiB+
    datatypes, this is not correct.  It will take an army to change the
    standard, but we can at least do the right thing internally.
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index 4eb398d..4786d60 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -4375,9 +4375,9 @@ int MPIR_Type_indexed_impl(int count, const int blocklens[], const int indices[]
 void MPIR_Type_free_impl(MPI_Datatype *datatype);
 int MPIR_Type_vector_impl(int count, int blocklength, int stride, MPI_Datatype old_type, MPI_Datatype *newtype_p);
 int MPIR_Type_struct_impl(int count, const int blocklens[], const MPI_Aint indices[], const MPI_Datatype old_types[], MPI_Datatype *newtype);
-int MPIR_Pack_impl(const void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, int outcount, int *position);
-void MPIR_Pack_size_impl(int incount, MPI_Datatype datatype, int *size);
-int MPIR_Unpack_impl(const void *inbuf, int insize, int *position,
+int MPIR_Pack_impl(const void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position);
+void MPIR_Pack_size_impl(int incount, MPI_Datatype datatype, MPI_Aint *size);
+int MPIR_Unpack_impl(const void *inbuf, MPI_Aint insize, MPI_Aint *position,
                      void *outbuf, int outcount, MPI_Datatype datatype);
 void MPIR_Type_lb_impl(MPI_Datatype datatype, MPI_Aint *displacement);
 int MPIR_Ibsend_impl(const void *buf, int count, MPI_Datatype datatype, int dest, int tag,
diff --git a/src/mpi/coll/alltoall.c b/src/mpi/coll/alltoall.c
index 921852b..96e1f9b 100644
--- a/src/mpi/coll/alltoall.c
+++ b/src/mpi/coll/alltoall.c
@@ -91,7 +91,8 @@ int MPIR_Alltoall_intra(
     int mpi_errno=MPI_SUCCESS, src, dst, rank, nbytes;
     int mpi_errno_ret = MPI_SUCCESS;
     MPI_Status status;
-    int sendtype_size, pack_size, block, position, *displs, count;
+    int sendtype_size, block, *displs, count;
+    MPI_Aint pack_size, position;
     MPI_Datatype newtype = MPI_DATATYPE_NULL;
     void *tmp_buf;
     MPI_Comm comm;
diff --git a/src/mpi/coll/bcast.c b/src/mpi/coll/bcast.c
index f644bfd..6b56ad7 100644
--- a/src/mpi/coll/bcast.c
+++ b/src/mpi/coll/bcast.c
@@ -47,7 +47,7 @@ static int MPIR_Bcast_binomial(
     MPI_Status status;
     int is_contig, is_homogeneous;
     MPI_Aint type_size;
-    int position;
+    MPI_Aint position;
     void *tmp_buf=NULL;
     MPI_Comm comm;
     MPID_Datatype *dtp;
@@ -404,7 +404,8 @@ static int MPIR_Bcast_scatter_doubling_allgather(
     int j, k, i, tmp_mask, is_contig, is_homogeneous;
     MPI_Aint type_size, nbytes = 0;
     int relative_dst, dst_tree_root, my_tree_root, send_offset;
-    int recv_offset, tree_root, nprocs_completed, offset, position;
+    int recv_offset, tree_root, nprocs_completed, offset;
+    MPI_Aint position;
     MPIU_CHKLMEM_DECL(1);
     MPI_Comm comm;
     MPID_Datatype *dtp;
@@ -707,10 +708,9 @@ static int MPIR_Bcast_scatter_ring_allgather(
     int rank, comm_size;
     int mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
-    int scatter_size, nbytes;
+    int scatter_size;
     int j, i, is_contig, is_homogeneous;
-    MPI_Aint type_size;
-    int position;
+    MPI_Aint nbytes, type_size, position;
     int left, right, jnext;
     int curr_size = 0;
     void *tmp_buf;
@@ -1143,7 +1143,8 @@ int MPIR_Bcast_intra (
     int mpi_errno_ret = MPI_SUCCESS;
     int comm_size;
     int nbytes=0;
-    int type_size, is_homogeneous;
+    int is_homogeneous;
+    MPI_Aint type_size;
     MPID_MPI_STATE_DECL(MPID_STATE_MPIR_BCAST);
 
     MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_BCAST);
diff --git a/src/mpi/coll/helper_fns.c b/src/mpi/coll/helper_fns.c
index 1c16730..8fbaedf 100644
--- a/src/mpi/coll/helper_fns.c
+++ b/src/mpi/coll/helper_fns.c
@@ -493,8 +493,8 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
     MPID_Request *sreq;
     MPID_Request *rreq;
     void *tmpbuf = NULL;
-    int tmpbuf_size = 0;
-    int tmpbuf_count = 0;
+    MPI_Aint tmpbuf_size = 0;
+    MPI_Aint tmpbuf_count = 0;
     MPID_Comm *comm_ptr;
     MPIU_CHKLMEM_DECL(1);
     MPIDI_STATE_DECL(MPID_STATE_MPIC_SENDRECV_REPLACE_FT);
diff --git a/src/mpi/coll/ibcast.c b/src/mpi/coll/ibcast.c
index f80d6d2..483c335 100644
--- a/src/mpi/coll/ibcast.c
+++ b/src/mpi/coll/ibcast.c
@@ -40,8 +40,8 @@ int MPIR_Ibcast_binomial(void *buffer, int count, MPI_Datatype datatype, int roo
     int mpi_errno = MPI_SUCCESS;
     int mask;
     int comm_size, rank;
-    int type_size, is_contig, is_homogeneous;
-    int nbytes;
+    int is_contig, is_homogeneous;
+    MPI_Aint nbytes, type_size;
     int relative_rank;
     int src, dst;
     void *tmp_buf = NULL;
@@ -669,7 +669,8 @@ fn_fail:
 int MPIR_Ibcast_SMP(void *buffer, int count, MPI_Datatype datatype, int root, MPID_Comm *comm_ptr, MPID_Sched_t s)
 {
     int mpi_errno = MPI_SUCCESS;
-    int type_size, is_homogeneous;
+    int is_homogeneous;
+    MPI_Aint type_size;
 
     if (!MPIR_CVAR_ENABLE_SMP_COLLECTIVES || !MPIR_CVAR_ENABLE_SMP_BCAST)
         MPID_Abort(comm_ptr, MPI_ERR_OTHER, 1, "SMP collectives are disabled!");
@@ -754,7 +755,8 @@ fn_fail:
 int MPIR_Ibcast_intra(void *buffer, int count, MPI_Datatype datatype, int root, MPID_Comm *comm_ptr, MPID_Sched_t s)
 {
     int mpi_errno = MPI_SUCCESS;
-    int comm_size, is_homogeneous, type_size, nbytes;
+    int comm_size, is_homogeneous;
+    MPI_Aint type_size, nbytes;
 
     MPIU_Assert(comm_ptr->comm_kind == MPID_INTRACOMM);
 
diff --git a/src/mpi/datatype/pack.c b/src/mpi/datatype/pack.c
index 54b607d..fb5456c 100644
--- a/src/mpi/datatype/pack.c
+++ b/src/mpi/datatype/pack.c
@@ -31,8 +31,8 @@ int MPIR_Pack_impl(const void *inbuf,
                    int incount,
                    MPI_Datatype datatype,
                    void *outbuf,
-                   int outsize,
-                   int *position)
+                   MPI_Aint outsize,
+                   MPI_Aint *position)
 {
     int mpi_errno = MPI_SUCCESS;
     MPI_Aint first, last;
@@ -151,6 +151,7 @@ int MPI_Pack(const void *inbuf,
 	     MPI_Comm comm)
 {
     int mpi_errno = MPI_SUCCESS;
+    MPI_Aint position_x;
     MPID_Comm *comm_ptr = NULL;
     
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_PACK);
@@ -240,7 +241,9 @@ int MPI_Pack(const void *inbuf,
 
     /* ... body of routine ... */
 
-    mpi_errno = MPIR_Pack_impl(inbuf, incount, datatype, outbuf, outsize, position);
+    position_x = *position;
+    mpi_errno = MPIR_Pack_impl(inbuf, incount, datatype, outbuf, outsize, &position_x);
+    MPIU_Assign_trunc(*position, position_x, int);
     if (mpi_errno) goto fn_fail;
     
    /* ... end of body of routine ... */
diff --git a/src/mpi/datatype/pack_size.c b/src/mpi/datatype/pack_size.c
index 4f69a14..a4ef60a 100644
--- a/src/mpi/datatype/pack_size.c
+++ b/src/mpi/datatype/pack_size.c
@@ -27,9 +27,9 @@
 #define FUNCNAME MPIR_Pack_size_impl
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
-void MPIR_Pack_size_impl(int incount, MPI_Datatype datatype, int *size)
+void MPIR_Pack_size_impl(int incount, MPI_Datatype datatype, MPI_Aint *size)
 {
-    int typesize;
+    MPI_Aint typesize;
     MPID_Datatype_get_size_macro(datatype, typesize);
     *size = incount * typesize;
 }
@@ -76,6 +76,7 @@ int MPI_Pack_size(int incount,
 {
     MPID_Comm *comm_ptr = NULL;
     int mpi_errno = MPI_SUCCESS;
+    MPI_Aint size_x = MPI_UNDEFINED;
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_PACK_SIZE);
 
     MPIR_ERRTEST_INITIALIZED_ORDIE();
@@ -124,8 +125,9 @@ int MPI_Pack_size(int incount,
 
     /* ... body of routine ... */
 
-    MPIR_Pack_size_impl(incount, datatype, size);
-    
+    MPIR_Pack_size_impl(incount, datatype, &size_x);
+    MPIU_Assign_trunc(*size, size_x, int);
+
     /* ... end of body of routine ... */
 
 #ifdef HAVE_ERROR_CHECKING
diff --git a/src/mpi/datatype/unpack.c b/src/mpi/datatype/unpack.c
index b468068..bb567a0 100644
--- a/src/mpi/datatype/unpack.c
+++ b/src/mpi/datatype/unpack.c
@@ -27,7 +27,7 @@
 #define FUNCNAME MPIR_Unpack_impl
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Unpack_impl(const void *inbuf, int insize, int *position,
+int MPIR_Unpack_impl(const void *inbuf, MPI_Aint insize, MPI_Aint *position,
                      void *outbuf, int outcount, MPI_Datatype datatype)
 {
     int mpi_errno = MPI_SUCCESS;
@@ -137,6 +137,7 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
 	       MPI_Comm comm)
 {
     int mpi_errno = MPI_SUCCESS;
+    MPI_Aint position_x;
     MPID_Comm *comm_ptr = NULL;
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_UNPACK);
 
@@ -193,8 +194,10 @@ int MPI_Unpack(const void *inbuf, int insize, int *position,
 
     /* ... body of routine ...  */
     
-    mpi_errno = MPIR_Unpack_impl(inbuf, insize, position, outbuf, outcount, datatype);
+    position_x = *position;
+    mpi_errno = MPIR_Unpack_impl(inbuf, insize, &position_x, outbuf, outcount, datatype);
     if (mpi_errno) goto fn_fail;
+    MPIU_Assign_trunc(*position, position_x, int);
     
     /* ... end of body of routine ... */
 
diff --git a/src/mpi/pt2pt/bsendutil.c b/src/mpi/pt2pt/bsendutil.c
index 6c2dda0..5309e9f 100644
--- a/src/mpi/pt2pt/bsendutil.c
+++ b/src/mpi/pt2pt/bsendutil.c
@@ -213,7 +213,8 @@ int MPIR_Bsend_isend(const void *buf, int count, MPI_Datatype dtype,
     int mpi_errno = MPI_SUCCESS;
     MPIR_Bsend_data_t *p;
     MPIR_Bsend_msg_t *msg;
-    int packsize, pass;
+    MPI_Aint packsize;
+    int pass;
 
     /* Find a free segment and copy the data into it.  If we could 
        have, we would already have used tBsend to send the message with
@@ -234,7 +235,7 @@ int MPIR_Bsend_isend(const void *buf, int count, MPI_Datatype dtype,
     else
         packsize = count;
 
-    MPIU_DBG_MSG_D(BSEND,TYPICAL,"looking for buffer of size %d", packsize);
+    MPIU_DBG_MSG_D(BSEND,TYPICAL,"looking for buffer of size %ld", packsize);
     /*
      * Use two passes.  Each pass is the same; between the two passes,
      * attempt to complete any active requests, and start any pending
@@ -246,7 +247,7 @@ int MPIR_Bsend_isend(const void *buf, int count, MPI_Datatype dtype,
 	p = MPIR_Bsend_find_buffer( packsize );
 	if (p) {
 	    MPIU_DBG_MSG_FMT(BSEND,TYPICAL,(MPIU_DBG_FDEST,
-                     "found buffer of size %d with address %p",packsize,p));
+                     "found buffer of size %ld with address %p",packsize,p));
 	    /* Found a segment */
 
 	    msg = &p->msg;
diff --git a/src/mpi/pt2pt/sendrecv_rep.c b/src/mpi/pt2pt/sendrecv_rep.c
index 4e022ac..dda4dd7 100644
--- a/src/mpi/pt2pt/sendrecv_rep.c
+++ b/src/mpi/pt2pt/sendrecv_rep.c
@@ -140,8 +140,8 @@ int MPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
 	MPID_Request * sreq;
 	MPID_Request * rreq;
 	void * tmpbuf = NULL;
-	int tmpbuf_size = 0;
-	int tmpbuf_count = 0;
+	MPI_Aint tmpbuf_size = 0;
+	MPI_Aint tmpbuf_count = 0;
 
 	if (count > 0 && dest != MPI_PROC_NULL)
 	{

http://git.mpich.org/mpich.git/commitdiff/0f06d7ac36d5b510992cf071067f22618fdc1aa7

commit 0f06d7ac36d5b510992cf071067f22618fdc1aa7
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Mon Oct 28 09:56:05 2013 -0500

    remove MPIR_Type_get_contig_blocks
    
    MPIR_Type_get_contig_blocks is buggy for certain datatypes (example:
    HDF5 multi-dataset IO generated type results in a contig block count of
    5 billion.  should be more like 200).  Nothing uses this function except
    ROMIO's flattening code.  I'd like to see profiling suggesting the count
    of contiguous blocks is a profitable short-circuit before spending a ton
    of time debugging it.
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpi/romio/adio/common/flatten.c b/src/mpi/romio/adio/common/flatten.c
index 2f995eb..420ef21 100644
--- a/src/mpi/romio/adio/common/flatten.c
+++ b/src/mpi/romio/adio/common/flatten.c
@@ -733,13 +733,6 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
  */
 MPI_Count ADIOI_Count_contiguous_blocks(MPI_Datatype datatype, MPI_Count *curr_index)
 {
-#ifdef HAVE_MPIR_TYPE_GET_CONTIG_BLOCKS
-    /* MPICH can get us this value without all the envelope/contents calls */
-    MPI_Count blks;
-    MPIR_Type_get_contig_blocks(datatype, &blks);
-    *curr_index = blks;
-    return blks;
-#else
     int i, n;
     MPI_Count count=0, prev_index, num, basic_num;
     int top_count, combiner, old_combiner, old_is_contig;
@@ -1008,7 +1001,6 @@ MPI_Count ADIOI_Count_contiguous_blocks(MPI_Datatype datatype, MPI_Count *curr_i
     ADIOI_Free(adds);
     ADIOI_Free(types);
     return count;
-#endif /* HAVE_MPIR_TYPE_GET_CONTIG_BLOCKS */
 }
 
 /* removezeros() make a second pass over the
diff --git a/src/mpi/romio/adio/include/adioi.h b/src/mpi/romio/adio/include/adioi.h
index 4eb926a..ea07491 100644
--- a/src/mpi/romio/adio/include/adioi.h
+++ b/src/mpi/romio/adio/include/adioi.h
@@ -559,9 +559,6 @@ int ADIOI_Error(ADIO_File fd, int error_code, char *string);
 int MPIR_Err_setmsg( int, int, const char *, const char *, const char *, ... );
 int ADIOI_End_call(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state);
 int MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype datatype, MPI_Count nbytes);
-#ifdef HAVE_MPIR_TYPE_GET_CONTIG_BLOCKS
-MPI_Count MPIR_Type_get_contig_blocks(MPI_Datatype datatype, MPI_Count *nr_blocks_p);
-#endif
 int ADIOI_Uses_generic_read(ADIO_File fd);
 int ADIOI_Uses_generic_write(ADIO_File fd);
 int ADIOI_Err_create_code(const char *myname, const char *filename, int my_errno);
diff --git a/src/mpid/common/datatype/Makefile.mk b/src/mpid/common/datatype/Makefile.mk
index 5a91f55..31a8c64 100644
--- a/src/mpid/common/datatype/Makefile.mk
+++ b/src/mpid/common/datatype/Makefile.mk
@@ -29,8 +29,7 @@ lib_lib at MPILIBNAME@_la_SOURCES +=                          \
     src/mpid/common/datatype/mpid_type_struct.c            \
     src/mpid/common/datatype/mpid_type_vector.c            \
     src/mpid/common/datatype/mpid_type_zerolen.c           \
-    src/mpid/common/datatype/mpir_type_flatten.c           \
-    src/mpid/common/datatype/mpir_type_get_contig_blocks.c
+    src/mpid/common/datatype/mpir_type_flatten.c
 
 # there are no AC_OUTPUT_FILES headers, so builddir is unnecessary
 AM_CPPFLAGS += -I$(top_srcdir)/src/mpid/common/datatype
diff --git a/src/mpid/common/datatype/mpir_type_get_contig_blocks.c b/src/mpid/common/datatype/mpir_type_get_contig_blocks.c
deleted file mode 100644
index 6b3d9d6..0000000
--- a/src/mpid/common/datatype/mpir_type_get_contig_blocks.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-
-/*
- *  (C) 2001 by Argonne National Laboratory.
- *      See COPYRIGHT in top-level directory.
- */
-
-#include <mpiimpl.h>
-#include <mpid_dataloop.h>
-#include <stdlib.h>
-
-/*@
-  MPIR_Type_get_contig_blocks
- 
-Input Parameters:
-. type - MPI Datatype (must have been committed)
-
-Output Parameters:
-. nr_blocks_p - pointer to int in which to store the number of contiguous blocks in the type
-
-
-  Return Value:
-  0 on success, -1 on failure.
-@*/
-
-MPI_Count MPIR_Type_get_contig_blocks(MPI_Datatype type,
-				MPI_Count *nr_blocks_p)
-{
-    MPID_Datatype *datatype_ptr;
-
-    if (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN) {
-	*nr_blocks_p = 1;
-	return 0;
-    }
-
-    MPID_Datatype_get_ptr(type, datatype_ptr);
-    MPIU_Assert(datatype_ptr->is_committed);
-
-    *nr_blocks_p = datatype_ptr->max_contig_blocks;
-    return 0;
-}

http://git.mpich.org/mpich.git/commitdiff/e289f45f4e42a310e994a7a9c05ab6ffe44a5e73

commit e289f45f4e42a310e994a7a9c05ab6ffe44a5e73
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Fri Oct 18 16:22:25 2013 -0500

    casting to make formatting happy
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpid/common/datatype/mpid_segment.c b/src/mpid/common/datatype/mpid_segment.c
index 65e4afb..412e7eb 100644
--- a/src/mpid/common/datatype/mpid_segment.c
+++ b/src/mpid/common/datatype/mpid_segment.c
@@ -321,8 +321,8 @@ static int MPID_Segment_vector_pack_to_iov(DLOOP_Offset *blocks_p,
              ", blks=" MPI_AINT_FMT_DEC_SPEC,
 		    (MPI_Aint) rel_off,
 		    bufp,
-		    paramp->u.pack_vector.length,
-		    paramp->u.pack_vector.index,
+		    (MPI_Aint) paramp->u.pack_vector.length,
+		    (MPI_Aint) paramp->u.pack_vector.index,
 		    count,
 		    blksz,
 		    (MPI_Aint) stride,

http://git.mpich.org/mpich.git/commitdiff/255780e99270ad931b33d0480a76555f780b6849

commit 255780e99270ad931b33d0480a76555f780b6849
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Fri Oct 18 16:21:34 2013 -0500

    Small parens-related warning with clang
    
    clang carped about too many parens around (( a == b))
    
    Fixes #1929
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_win_fns.c b/src/mpid/ch3/channels/nemesis/src/ch3_win_fns.c
index 89ef6f9..cdec858 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_win_fns.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_win_fns.c
@@ -85,7 +85,7 @@ static int MPIDI_CH3I_Win_allocate_shm(MPI_Aint size, int disp_unit, MPID_Info *
         char alloc_shared_nctg_value[MPI_MAX_INFO_VAL+1];
         MPIR_Info_get_impl(info, "alloc_shared_noncontig", MPI_MAX_INFO_VAL,
                            alloc_shared_nctg_value, &alloc_shared_nctg_flag);
-        if ((alloc_shared_nctg_flag == 1)) {
+        if (alloc_shared_nctg_flag == 1) {
             if (!strncmp(alloc_shared_nctg_value, "true", strlen("true")))
                 (*win_ptr)->info_args.alloc_shared_noncontig = 1;
             if (!strncmp(alloc_shared_nctg_value, "false", strlen("false")))

http://git.mpich.org/mpich.git/commitdiff/d15c4289c05f26afcd1fa8806c941bcd916b182d

commit d15c4289c05f26afcd1fa8806c941bcd916b182d
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Wed Oct 16 10:59:42 2013 -0500

    A round of 64-to-32 warning squashes
    
    formatting fixes and type promotions to chip away at the 1500 lines of
    warnings that pop up with clang's -Wshorten-64-to-32 flag.
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpi/romio/adio/ad_testfs/ad_testfs_seek.c b/src/mpi/romio/adio/ad_testfs/ad_testfs_seek.c
index d5ef7c3..a2f6234 100644
--- a/src/mpi/romio/adio/ad_testfs/ad_testfs_seek.c
+++ b/src/mpi/romio/adio/ad_testfs/ad_testfs_seek.c
@@ -28,8 +28,8 @@ ADIO_Offset ADIOI_TESTFS_SeekIndividual(ADIO_File fd, ADIO_Offset offset,
     int i, n_etypes_in_filetype, n_filetypes, etype_in_filetype;
     ADIO_Offset abs_off_in_filetype=0, sum;
     int size_in_filetype;
-    int filetype_size, etype_size, filetype_is_contig;
-    MPI_Aint filetype_extent;
+    int filetype_size, filetype_is_contig;
+    MPI_Aint etype_size, filetype_extent;
 
     *error_code = MPI_SUCCESS;
 
diff --git a/src/mpi/romio/adio/common/ad_coll_exch_new.c b/src/mpi/romio/adio/common/ad_coll_exch_new.c
index 62c9282..08fb83a 100644
--- a/src/mpi/romio/adio/common/ad_coll_exch_new.c
+++ b/src/mpi/romio/adio/common/ad_coll_exch_new.c
@@ -134,7 +134,7 @@ void ADIOI_Exch_file_views(int myrank, int nprocs, int file_ptr_type,
     ADIOI_Flatlist_node *flat_mem_p = NULL, *flat_file_p = NULL;
     int memtype_sz = -1;
     int memtype_is_contig = -1;
-    int filetype_sz = -1;
+    ADIO_Offset filetype_sz = -1;
 
 #ifdef AGGREGATION_PROFILE
     MPE_Log_event (5014, 0, NULL);
@@ -157,7 +157,7 @@ void ADIOI_Exch_file_views(int myrank, int nprocs, int file_ptr_type,
     }
 
     MPI_Type_extent(fd->filetype, &filetype_extent);
-    MPI_Type_size(fd->filetype, &filetype_sz);
+    MPI_Type_size_x(fd->filetype, &filetype_sz);
     if (filetype_extent == filetype_sz) {
 	flat_file_p = ADIOI_Add_contig_flattened(fd->filetype);
 	flat_file_p->blocklens[0] = memtype_sz*count;
diff --git a/src/mpi/romio/adio/common/ad_fstype.c b/src/mpi/romio/adio/common/ad_fstype.c
index 85d2142..4bd1a11 100644
--- a/src/mpi/romio/adio/common/ad_fstype.c
+++ b/src/mpi/romio/adio/common/ad_fstype.c
@@ -172,7 +172,7 @@ static void ADIO_FileSysType_parentdir(const char *filename, char **dirnamep)
 	 * but this code doesn't care if the target is really there
 	 * or not.
 	 */
-	int namelen;
+	ssize_t namelen;
 	char *linkbuf;
 
 	linkbuf = ADIOI_Malloc(PATH_MAX+1);
diff --git a/src/mpi/romio/adio/common/ad_get_sh_fp.c b/src/mpi/romio/adio/common/ad_get_sh_fp.c
index 1252043..c73b499 100644
--- a/src/mpi/romio/adio/common/ad_get_sh_fp.c
+++ b/src/mpi/romio/adio/common/ad_get_sh_fp.c
@@ -18,7 +18,7 @@ void ADIOI_BG_Get_shared_fp(ADIO_File fd, int size, ADIO_Offset *shared_fp, int
    shared_fp by the number of etypes to be accessed (incr) in the read
    or write following this function. */
 
-void ADIOI_NFS_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp,
+void ADIOI_NFS_Get_shared_fp(ADIO_File fd, ADIO_Offset incr, ADIO_Offset *shared_fp,
                              int *error_code);
 
 void ADIO_Get_shared_fp(ADIO_File fd, ADIO_Offset incr, ADIO_Offset *shared_fp,
diff --git a/src/mpi/romio/adio/common/ad_io_coll.c b/src/mpi/romio/adio/common/ad_io_coll.c
index 198ba62..22d6f43 100644
--- a/src/mpi/romio/adio/common/ad_io_coll.c
+++ b/src/mpi/romio/adio/common/ad_io_coll.c
@@ -701,11 +701,11 @@ void ADIOI_Calc_bounds (ADIO_File fd, int count, MPI_Datatype buftype,
 			ADIO_Offset *st_offset, ADIO_Offset *end_offset)
 {
     int filetype_size, buftype_size, etype_size;
-    int i, sum;
+    int sum;
     MPI_Aint filetype_extent;
     ADIO_Offset total_io;
     int filetype_is_contig;
-    int remainder;
+    ADIO_Offset i, remainder;
     ADIOI_Flatlist_node *flat_file;
     
     ADIO_Offset st_byte_off, end_byte_off;
diff --git a/src/mpi/romio/adio/common/ad_iwrite.c b/src/mpi/romio/adio/common/ad_iwrite.c
index 8848dfd..f263a74 100644
--- a/src/mpi/romio/adio/common/ad_iwrite.c
+++ b/src/mpi/romio/adio/common/ad_iwrite.c
@@ -219,7 +219,7 @@ int ADIOI_GEN_aio_poll_fn(void *extra_state, MPI_Status *status)
     else if (errno == ECANCELED) {
 	    /* TODO: unsure how to handle this */
     } else if (errno == 0) {
-	    int n = aio_return(aio_req->aiocbp);
+	    ssize_t n = aio_return(aio_req->aiocbp);
 	    aio_req->nbytes = n;
 	    errcode = MPI_Grequest_complete(aio_req->req);
 	    /* --BEGIN ERROR HANDLING-- */
@@ -278,7 +278,7 @@ int ADIOI_GEN_aio_wait_fn(int count, void ** array_of_states,
 			continue;
 		    errno = aio_error(aio_reqlist[i]->aiocbp);
 		    if (errno == 0) {
-			int n = aio_return(aio_reqlist[i]->aiocbp);
+			ssize_t n = aio_return(aio_reqlist[i]->aiocbp);
 			aio_reqlist[i]->nbytes = n;
 			errcode = MPI_Grequest_complete(aio_reqlist[i]->req);
 			if (errcode != MPI_SUCCESS) {
@@ -323,8 +323,7 @@ int ADIOI_GEN_aio_query_fn(void *extra_state, MPI_Status *status)
 
 	aio_req = (ADIOI_AIO_Request *)extra_state;
 
-
-	MPI_Status_set_elements(status, MPI_BYTE, aio_req->nbytes); 
+	MPI_Status_set_elements_x(status, MPI_BYTE, aio_req->nbytes);
 
 	/* can never cancel so always true */ 
 	MPI_Status_set_cancelled(status, 0); 
diff --git a/src/mpi/romio/adio/common/ad_read_str_naive.c b/src/mpi/romio/adio/common/ad_read_str_naive.c
index 95c14b4..6ff428e 100644
--- a/src/mpi/romio/adio/common/ad_read_str_naive.c
+++ b/src/mpi/romio/adio/common/ad_read_str_naive.c
@@ -22,7 +22,7 @@ void ADIOI_GEN_ReadStrided_naive(ADIO_File fd, void *buf, int count,
     ADIO_Offset n_filetypes, etype_in_filetype;
     ADIO_Offset abs_off_in_filetype=0;
     unsigned bufsize, filetype_size, buftype_size, size_in_filetype;
-    int etype_size;
+    ADIO_Offset etype_size;
     MPI_Aint filetype_extent, buftype_extent; 
     int buf_count, buftype_is_contig, filetype_is_contig;
     ADIO_Offset userbuf_off;
diff --git a/src/mpi/romio/adio/common/ad_write_coll.c b/src/mpi/romio/adio/common/ad_write_coll.c
index e5ed05c..583fc48 100644
--- a/src/mpi/romio/adio/common/ad_write_coll.c
+++ b/src/mpi/romio/adio/common/ad_write_coll.c
@@ -530,9 +530,10 @@ static void ADIOI_Exch_and_write(ADIO_File fd, void *buf, MPI_Datatype
 
     for (i=0; i<nprocs; i++) count[i] = recv_size[i] = 0;
     for (m=ntimes; m<max_ntimes; m++) {
+	ADIOI_Assert(size == (int)size);
 	/* nothing to recv, but check for send. */
 	ADIOI_W_Exchange_data(fd, buf, write_buf, flat_buf, offset_list, 
-                            len_list, send_size, recv_size, off, size, count, 
+                            len_list, send_size, recv_size, off, (int)size, count,
                             start_pos, partial_recv, 
                             sent_to_proc, nprocs, myrank, 
 			    buftype_is_contig, contig_access_count,
@@ -659,7 +660,8 @@ static void ADIOI_W_Exchange_data(ADIO_File fd, void *buf, char *write_buf,
         else { /* coalesce the sorted offset-length pairs */
             for (i=1; i<sum; i++) {
                 if (srt_off[i] <= srt_off[0] + srt_len[0]) {
-		    int new_len = srt_off[i] + srt_len[i] - srt_off[0];
+		    /* ok to cast: operating on cb_buffer_size chunks */
+		    int new_len = (int)srt_off[i] + srt_len[i] - (int)srt_off[0];
 		    if (new_len > srt_len[0]) srt_len[0] = new_len;
 		}
 		else
@@ -929,7 +931,8 @@ static void ADIOI_Fill_send_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node
       ADIOI_Assert((curr_to_proc[p] + len - done_to_proc[p]) == (unsigned)(curr_to_proc[p] + len - done_to_proc[p]));
 		        buf_incr = curr_to_proc[p] + len - done_to_proc[p];
       ADIOI_Assert((done_to_proc[p] + size) == (unsigned)(done_to_proc[p] + size));
-			curr_to_proc[p] = done_to_proc[p] + size;
+			/* ok to cast: bounded by cb buffer size */
+			curr_to_proc[p] = done_to_proc[p] + (int)size;
 		        ADIOI_BUF_COPY
 		    }
 		    else {
diff --git a/src/mpi/romio/adio/common/ad_write_nolock.c b/src/mpi/romio/adio/common/ad_write_nolock.c
index 47a6079..7048198 100644
--- a/src/mpi/romio/adio/common/ad_write_nolock.c
+++ b/src/mpi/romio/adio/common/ad_write_nolock.c
@@ -31,8 +31,7 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, const void *buf, int count,
     off_t err_lseek=-1;
     ssize_t err=-1;
     ADIO_Offset fwr_size=0, bwr_size, new_bwr_size, new_fwr_size, i_offset, num;
-    unsigned bufsize; 
-    int n_etypes_in_filetype;
+    ADIO_Offset bufsize, n_etypes_in_filetype;
     ADIO_Offset n_filetypes, etype_in_filetype, size, sum;
     ADIO_Offset abs_off_in_filetype=0, size_in_filetype;
     MPI_Count filetype_size, etype_size, buftype_size;
diff --git a/src/mpi/romio/adio/common/ad_write_str.c b/src/mpi/romio/adio/common/ad_write_str.c
index c095b34..b09d6f5 100644
--- a/src/mpi/romio/adio/common/ad_write_str.c
+++ b/src/mpi/romio/adio/common/ad_write_str.c
@@ -119,9 +119,8 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, const void *buf, int count,
     ADIOI_Flatlist_node *flat_buf, *flat_file;
     ADIO_Offset i_offset, sum, size_in_filetype;
     int i, j, k, st_index=0;
-    int n_etypes_in_filetype;
     ADIO_Offset num, size, n_filetypes, etype_in_filetype, st_n_filetypes;
-    ADIO_Offset abs_off_in_filetype=0;
+    ADIO_Offset n_etypes_in_filetype, abs_off_in_filetype=0;
     MPI_Count filetype_size, etype_size, buftype_size;
     MPI_Aint filetype_extent, buftype_extent; 
     int buf_count, buftype_is_contig, filetype_is_contig;
diff --git a/src/mpi/romio/adio/common/ad_write_str_naive.c b/src/mpi/romio/adio/common/ad_write_str_naive.c
index c37e3a1..aa4d4c9 100644
--- a/src/mpi/romio/adio/common/ad_write_str_naive.c
+++ b/src/mpi/romio/adio/common/ad_write_str_naive.c
@@ -20,7 +20,7 @@ void ADIOI_GEN_WriteStrided_naive(ADIO_File fd, const void *buf, int count,
     ADIO_Offset bwr_size, fwr_size=0, sum, size_in_filetype; 
     int b_index;
     unsigned bufsize; 
-    int n_etypes_in_filetype;
+    ADIO_Offset n_etypes_in_filetype;
     ADIO_Offset size, n_filetypes, etype_in_filetype;
     ADIO_Offset abs_off_in_filetype=0, req_len;
     MPI_Count filetype_size, etype_size, buftype_size;
diff --git a/src/mpi/romio/adio/common/cb_config_list.c b/src/mpi/romio/adio/common/cb_config_list.c
index 83e9f29..9db91af 100644
--- a/src/mpi/romio/adio/common/cb_config_list.c
+++ b/src/mpi/romio/adio/common/cb_config_list.c
@@ -666,7 +666,7 @@ static int get_max_procs(int cb_nodes)
 	if (token != AGG_WILDCARD && token != AGG_STRING) return -1;
 	if (token == AGG_WILDCARD) max_procs = cb_nodes;
 	else if (token == AGG_STRING) {
-	    max_procs = strtol(yylval, &errptr, 10);
+	    max_procs = (int)strtol(yylval, &errptr, 10);
 	    if (*errptr != '\0') {
 		/* some garbage value; default to 1 */
 		max_procs = 1;
diff --git a/src/mpi/romio/adio/common/flatten.c b/src/mpi/romio/adio/common/flatten.c
index c75bce0..2f995eb 100644
--- a/src/mpi/romio/adio/common/flatten.c
+++ b/src/mpi/romio/adio/common/flatten.c
@@ -61,7 +61,7 @@ void ADIOI_Flatten_datatype(MPI_Datatype datatype)
 
     flat->count = ADIOI_Count_contiguous_blocks(datatype, &curr_index);
 #ifdef FLATTEN_DEBUG 
-    DBG_FPRINTF(stderr,"ADIOI_Flatten_datatype:: count %#z, cur_idx = %#X\n",flat->count,curr_index);
+    DBG_FPRINTF(stderr,"ADIOI_Flatten_datatype:: count %llX, cur_idx = %#llX\n",flat->count,curr_index);
 #endif
 /*    DBG_FPRINTF(stderr, "%d\n", flat->count);*/
 
@@ -107,13 +107,13 @@ void ADIOI_Flatten_datatype(MPI_Datatype datatype)
 void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat, 
 		  ADIO_Offset st_offset, MPI_Count *curr_index)
 {
-    int i, j, k, m, n, num, basic_num, prev_index;
+    int i, k, m, n, basic_num;
     int combiner, old_combiner, old_is_contig;
     int nints, nadds, ntypes, old_nints, old_nadds, old_ntypes;
     /* By using ADIO_Offset we preserve +/- sign and 
          avoid >2G integer arithmetic problems */
     ADIO_Offset top_count;
-    MPI_Count old_size;
+    MPI_Count j, old_size, prev_index, num;
     MPI_Aint old_extent;/* Assume extents are non-negative */
     int *ints;
     MPI_Aint *adds; /* Make no assumptions about +/- sign on these */
@@ -125,7 +125,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
     MPI_Type_get_contents(datatype, nints, nadds, ntypes, ints, adds, types);
 
   #ifdef FLATTEN_DEBUG 
-  DBG_FPRINTF(stderr,"ADIOI_Flatten:: st_offset %#llX, curr_index %#X\n",st_offset,*curr_index);
+  DBG_FPRINTF(stderr,"ADIOI_Flatten:: st_offset %#llX, curr_index %#llX\n",st_offset,*curr_index);
   DBG_FPRINTF(stderr,"ADIOI_Flatten:: nints %#X, nadds %#X, ntypes %#X\n",nints, nadds, ntypes);
   for(i=0; i< nints; ++i)
   {
@@ -194,12 +194,12 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 				    types[0],
 				    &dtype);
       #ifdef FLATTEN_DEBUG 
-      DBG_FPRINTF(stderr,"ADIOI_Flatten:: MPI_COMBINER_DARRAY <ADIOI_Flatten(dtype, flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX, st_offset %#llX, curr_index %#X);\n",
+      DBG_FPRINTF(stderr,"ADIOI_Flatten:: MPI_COMBINER_DARRAY <ADIOI_Flatten(dtype, flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX, st_offset %#llX, curr_index %#llX);\n",
               0, flat->indices[0], 0, flat->blocklens[0], st_offset, *curr_index);
       #endif
 	    ADIOI_Flatten(dtype, flat, st_offset, curr_index);
       #ifdef FLATTEN_DEBUG 
-      DBG_FPRINTF(stderr,"ADIOI_Flatten:: MPI_COMBINER_DARRAY >ADIOI_Flatten(dtype, flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX, st_offset %#llX, curr_index %#X);\n",
+      DBG_FPRINTF(stderr,"ADIOI_Flatten:: MPI_COMBINER_DARRAY >ADIOI_Flatten(dtype, flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX, st_offset %#llX, curr_index %#llX);\n",
               0, flat->indices[0], 0, flat->blocklens[0], st_offset, *curr_index);
       #endif
 	    MPI_Type_free(&dtype);
@@ -226,7 +226,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 	    MPI_Type_size_x(types[0], &old_size);
 	    flat->blocklens[j] = top_count * old_size;
       #ifdef FLATTEN_DEBUG 
-      DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",j, flat->indices[j], j, flat->blocklens[j]);
+      DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",j, flat->indices[j], j, flat->blocklens[j]);
       #endif
 	    (*curr_index)++;
 	}
@@ -242,7 +242,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 		    flat->indices[j] = flat->indices[j-num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
 		    flat->blocklens[j] = flat->blocklens[j-num];
           #ifdef FLATTEN_DEBUG 
-          DBG_FPRINTF(stderr,"ADIOI_Flatten:: derived flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",j, flat->indices[j], j, flat->blocklens[j]);
+          DBG_FPRINTF(stderr,"ADIOI_Flatten:: derived flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",j, flat->indices[j], j, flat->blocklens[j]);
           #endif
 		    j++;
 		}
@@ -615,7 +615,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 		MPI_Type_size_x(types[n], &old_size);
 		flat->blocklens[j] = blocklength * old_size;
         #ifdef FLATTEN_DEBUG 
-        DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",n,adds[n],j, flat->indices[j], j, flat->blocklens[j]);
+        DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",n,adds[n],j, flat->indices[j], j, flat->blocklens[j]);
         #endif
 		(*curr_index)++;
 	    }
@@ -632,7 +632,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 			flat->indices[j] = flat->indices[j-num] + ADIOI_AINT_CAST_TO_OFFSET old_extent;
 			flat->blocklens[j] = flat->blocklens[j-num];
             #ifdef FLATTEN_DEBUG 
-            DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple old_extent "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",old_extent,j, flat->indices[j], j, flat->blocklens[j]);
+            DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple old_extent "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",old_extent,j, flat->indices[j], j, flat->blocklens[j]);
             #endif
 			j++;
 		    }
@@ -655,7 +655,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 	flat->blocklens[j] = 0;
 
         #ifdef FLATTEN_DEBUG 
-        DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",0,adds[0],j, flat->indices[j], j, flat->blocklens[j]);
+        DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",0,adds[0],j, flat->indices[j], j, flat->blocklens[j]);
         #endif
 
 	(*curr_index)++;
@@ -677,7 +677,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 	    flat->blocklens[j] = old_size;
 
             #ifdef FLATTEN_DEBUG 
-	    DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",0,adds[0],j, flat->indices[j], j, flat->blocklens[j]);
+	    DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",0,adds[0],j, flat->indices[j], j, flat->blocklens[j]);
             #endif
 
 	    (*curr_index)++;
@@ -689,7 +689,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 	flat->blocklens[j] = 0;
 
         #ifdef FLATTEN_DEBUG 
-        DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",1,adds[1],j, flat->indices[j], j, flat->blocklens[j]);
+        DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#llX] %#llX, flat->blocklens[%#llX] %#llX\n",1,adds[1],j, flat->indices[j], j, flat->blocklens[j]);
         #endif
 
 	(*curr_index)++;
@@ -717,7 +717,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
     ADIOI_Free(types);
 
   #ifdef FLATTEN_DEBUG 
-  DBG_FPRINTF(stderr,"ADIOI_Flatten:: return st_offset %#llX, curr_index %#X\n",st_offset,*curr_index);
+  DBG_FPRINTF(stderr,"ADIOI_Flatten:: return st_offset %#llX, curr_index %#llX\n",st_offset,*curr_index);
   #endif
 
 }
@@ -740,8 +740,8 @@ MPI_Count ADIOI_Count_contiguous_blocks(MPI_Datatype datatype, MPI_Count *curr_i
     *curr_index = blks;
     return blks;
 #else
-    int i, n, num, basic_num, prev_index;
-    MPI_Count count=0;
+    int i, n;
+    MPI_Count count=0, prev_index, num, basic_num;
     int top_count, combiner, old_combiner, old_is_contig;
     int nints, nadds, ntypes, old_nints, old_nadds, old_ntypes;
     int *ints;
diff --git a/src/mpi/romio/adio/common/get_fp_posn.c b/src/mpi/romio/adio/common/get_fp_posn.c
index 8f5b907..671dde3 100644
--- a/src/mpi/romio/adio/common/get_fp_posn.c
+++ b/src/mpi/romio/adio/common/get_fp_posn.c
@@ -16,8 +16,8 @@ void ADIOI_Get_position(ADIO_File fd, ADIO_Offset *offset)
 {
     ADIOI_Flatlist_node *flat_file;
     int i, flag;
-    MPI_Count filetype_size;
-    int etype_size, filetype_is_contig;
+    MPI_Count filetype_size, etype_size;
+    int filetype_is_contig;
     MPI_Aint filetype_extent;
     ADIO_Offset disp, byte_offset, sum=0, size_in_file, n_filetypes, frd_size;
     
diff --git a/src/mpi/romio/adio/common/hint_fns.c b/src/mpi/romio/adio/common/hint_fns.c
index 560b614..34c898b 100644
--- a/src/mpi/romio/adio/common/hint_fns.c
+++ b/src/mpi/romio/adio/common/hint_fns.c
@@ -143,7 +143,8 @@ int ADIOI_Info_check_and_install_true(ADIO_File fd, MPI_Info info, const char *k
 int ADIOI_Info_check_and_install_str(ADIO_File fd, MPI_Info info, const char *key, 
 	char **local_cache, char *funcname, int *error_code)
 {
-    int flag, len;
+    int flag;
+    size_t len;
     char *value;
 
     value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
diff --git a/src/mpi/romio/adio/common/shfp_fname.c b/src/mpi/romio/adio/common/shfp_fname.c
index 308b946..c88fe18 100644
--- a/src/mpi/romio/adio/common/shfp_fname.c
+++ b/src/mpi/romio/adio/common/shfp_fname.c
@@ -26,7 +26,8 @@
 void ADIOI_Shfp_fname(ADIO_File fd, int rank)
 {
     double tm;
-    int i, len;
+    int i;
+    int len;
     char *slash, *ptr, tmp[128];
     int pid = 0;
 
@@ -60,7 +61,8 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank)
 	    slash = strrchr(fd->shared_fp_fname, '/');
 #endif
 	    ADIOI_Strncpy(slash + 1, ".", 2);
-	    len = 256 - (slash+2 - fd->shared_fp_fname);
+	    /* ok to cast: file names bounded by PATH_MAX and NAME_MAX */
+	    len = (int) (256 - (slash+2 - fd->shared_fp_fname));
 	    ADIOI_Strncpy(slash + 2, ptr + 1, len);
 	}
 	    
diff --git a/src/mpid/common/datatype/mpid_segment.c b/src/mpid/common/datatype/mpid_segment.c
index f52a5eb..65e4afb 100644
--- a/src/mpid/common/datatype/mpid_segment.c
+++ b/src/mpid/common/datatype/mpid_segment.c
@@ -314,7 +314,8 @@ static int MPID_Segment_vector_pack_to_iov(DLOOP_Offset *blocks_p,
              "    vector to vec: do=" MPI_AINT_FMT_DEC_SPEC
              ", dp=%p"
              ", len=" MPI_AINT_FMT_DEC_SPEC
-	     ", ind=%d, ct=" MPI_AINT_FMT_DEC_SPEC
+	     ", ind=" MPI_AINT_FMT_DEC_SPEC
+	     ", ct=" MPI_AINT_FMT_DEC_SPEC
 	     ", blksz=" MPI_AINT_FMT_DEC_SPEC
              ", str=" MPI_AINT_FMT_DEC_SPEC
              ", blks=" MPI_AINT_FMT_DEC_SPEC,
diff --git a/src/pm/hydra/ui/mpich/utils.c b/src/pm/hydra/ui/mpich/utils.c
index 9d55fd4..fb86e42 100644
--- a/src/pm/hydra/ui/mpich/utils.c
+++ b/src/pm/hydra/ui/mpich/utils.c
@@ -237,7 +237,7 @@ static void genvlist_help_fn(void)
 
 static HYD_status genvlist_fn(char *arg, char ***argv)
 {
-    int len;
+    size_t len;
     HYD_status status = HYD_SUCCESS;
 
     if (reading_config_file && HYD_server_info.user_global.global_env.prop) {
@@ -684,7 +684,7 @@ static void envlist_help_fn(void)
 
 static HYD_status envlist_fn(char *arg, char ***argv)
 {
-    int len;
+    size_t len;
     struct HYD_exec *exec;
     HYD_status status = HYD_SUCCESS;
 
@@ -1632,7 +1632,8 @@ static HYD_status parse_args(char **t_argv)
 
 HYD_status HYD_uii_mpx_get_parameters(char **t_argv)
 {
-    int ret, len;
+    int ret;
+    size_t len;
     char **argv = t_argv;
     char *progname = *argv;
     char *post, *loc, *tmp[HYD_NUM_TMP_STRINGS], *conf_file;

http://git.mpich.org/mpich.git/commitdiff/6f267e79b478df773d2343a6738e1cfadd28c995

commit 6f267e79b478df773d2343a6738e1cfadd28c995
Author: Jeff Hammond <jeff.science at gmail.com>
Date:   Tue Oct 15 14:09:02 2013 -0500

    remove cast-to-integer associated with count field
    
    goal: make MPICH count-safe
    problem: casting to int when value exceeds INT_MAX
    solution: remove all "(int)" in front of values assigned to the count
    field
    
    Signed-off-by: Rob Latham <robl at mcs.anl.gov>

diff --git a/src/mpid/ch3/channels/nemesis/netmod/mx/mx_poll.c b/src/mpid/ch3/channels/nemesis/netmod/mx/mx_poll.c
index c4f79e7..8b39b7e 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/mx/mx_poll.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/mx/mx_poll.c
@@ -607,7 +607,7 @@ MPID_nem_mx_handle_rreq(MPID_Request *req, mx_status_t status)
     MPID_Segment_unpack( req->dev.segment_ptr, 0, &last, req->dev.tmpbuf );
     MPIU_Free(req->dev.tmpbuf);       
     if (last != data_sz) {
-      MPIR_STATUS_SET_COUNT(req->status, (int)last);
+      MPIR_STATUS_SET_COUNT(req->status, last);
       if (req->dev.recv_data_sz <= userbuf_sz) {
 	MPIU_ERR_SETSIMPLE(req->status.MPI_ERROR,MPI_ERR_TYPE,"**dtypemismatch");
       }
diff --git a/src/mpid/ch3/channels/nemesis/netmod/newmad/newmad_poll.c b/src/mpid/ch3/channels/nemesis/netmod/newmad/newmad_poll.c
index 0346378..2dba872 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/newmad/newmad_poll.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/newmad/newmad_poll.c
@@ -373,7 +373,7 @@ MPID_nem_newmad_handle_rreq(MPID_Request *req, nm_tag_t match_info, size_t size)
 	MPID_Segment_unpack( req->dev.segment_ptr, 0, &last, req->dev.tmpbuf);
 	MPIU_Free(req->dev.tmpbuf);
 	if (last != data_sz) {
-	    MPIR_STATUS_SET_COUNT(req->status, (int)last);
+	    MPIR_STATUS_SET_COUNT(req->status, last);
 	    if (req->dev.recv_data_sz <= userbuf_sz) {
 		MPIU_ERR_SETSIMPLE(req->status.MPI_ERROR,MPI_ERR_TYPE,"**dtypemismatch");
 	    }
diff --git a/src/mpid/ch3/src/ch3u_buffer.c b/src/mpid/ch3/src/ch3u_buffer.c
index 2d271c2..abee52d 100644
--- a/src/mpid/ch3/src/ch3u_buffer.c
+++ b/src/mpid/ch3/src/ch3u_buffer.c
@@ -239,7 +239,7 @@ int MPIDI_CH3_RecvFromSelf( MPID_Request *rreq, void *buf, int count,
 			       sreq->dev.datatype, &sreq->status.MPI_ERROR,
 			       buf, count, datatype, &data_sz, 
 			       &rreq->status.MPI_ERROR);
-	MPIR_STATUS_SET_COUNT(rreq->status, (int)data_sz);
+	MPIR_STATUS_SET_COUNT(rreq->status, data_sz);
 	MPID_REQUEST_SET_COMPLETED(sreq);
 	MPID_Request_release(sreq);
     }
diff --git a/src/mpid/ch3/src/ch3u_eager.c b/src/mpid/ch3/src/ch3u_eager.c
index 1890b2c..3d185f8 100644
--- a/src/mpid/ch3/src/ch3u_eager.c
+++ b/src/mpid/ch3/src/ch3u_eager.c
@@ -405,7 +405,7 @@ int MPIDI_CH3_PktHandler_EagerShortSend( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
 		    /* There are two cases:  a datatype mismatch (could
 		       not consume all data) or a too-short buffer. We
 		       need to distinguish between these two types. */
-		    MPIR_STATUS_SET_COUNT(rreq->status, (int)last);
+		    MPIR_STATUS_SET_COUNT(rreq->status, last);
 		    if (rreq->dev.recv_data_sz <= userbuf_sz) {
 			MPIU_ERR_SETSIMPLE(rreq->status.MPI_ERROR,MPI_ERR_TYPE,
 					   "**dtypemismatch");
diff --git a/src/mpid/ch3/src/ch3u_handle_recv_pkt.c b/src/mpid/ch3/src/ch3u_handle_recv_pkt.c
index 426429c..92d3e6b 100644
--- a/src/mpid/ch3/src/ch3u_handle_recv_pkt.c
+++ b/src/mpid/ch3/src/ch3u_handle_recv_pkt.c
@@ -198,7 +198,7 @@ int MPIDI_CH3U_Receive_data_found(MPID_Request *rreq, char *buf, MPIDI_msg_sz_t
                    mismatch between the datatype and the amount of
                    data received.  Throw away received data. */
                 MPIU_ERR_SET(rreq->status.MPI_ERROR, MPI_ERR_TYPE, "**dtypemismatch");
-                MPIR_STATUS_SET_COUNT(rreq->status, (int)rreq->dev.segment_first);
+                MPIR_STATUS_SET_COUNT(rreq->status, rreq->dev.segment_first);
                 *buflen = data_sz;
                 *complete = TRUE;
 		/* FIXME: Set OnDataAvail to 0?  If not, why not? */
diff --git a/src/mpid/ch3/src/ch3u_request.c b/src/mpid/ch3/src/ch3u_request.c
index ef1779a..af39b3d 100644
--- a/src/mpid/ch3/src/ch3u_request.c
+++ b/src/mpid/ch3/src/ch3u_request.c
@@ -381,7 +381,7 @@ int MPIDI_CH3U_Request_load_recv_iov(MPID_Request * const rreq)
 	    rreq->status.MPI_ERROR = MPIR_Err_create_code(MPI_SUCCESS, 
 		       MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_TYPE,
 		       "**dtypemismatch", 0);
-            MPIR_STATUS_SET_COUNT(rreq->status, (int)rreq->dev.segment_first);
+            MPIR_STATUS_SET_COUNT(rreq->status, rreq->dev.segment_first);
 	    rreq->dev.segment_size = rreq->dev.segment_first;
 	    mpi_errno = MPIDI_CH3U_Request_load_recv_iov(rreq);
 	    goto fn_exit;
@@ -518,7 +518,7 @@ int MPIDI_CH3U_Request_unpack_srbuf(MPID_Request * rreq)
 	/* If no data can be unpacked, then we have a datatype processing 
 	   problem.  Adjust the segment info so that the remaining
 	   data is received and thrown away. */
-	MPIR_STATUS_SET_COUNT(rreq->status, (int)rreq->dev.segment_first);
+	MPIR_STATUS_SET_COUNT(rreq->status, rreq->dev.segment_first);
 	rreq->dev.segment_size = rreq->dev.segment_first;
 	rreq->dev.segment_first += tmpbuf_last;
 	rreq->status.MPI_ERROR = MPIR_Err_create_code(MPI_SUCCESS, 
@@ -536,7 +536,7 @@ int MPIDI_CH3U_Request_unpack_srbuf(MPID_Request * rreq)
 	       Note: the segment_first field is set to segment_last so that if
 	       this is a truncated message, extra data will be read
 	       off the pipe. */
-	    MPIR_STATUS_SET_COUNT(rreq->status, (int)last);
+	    MPIR_STATUS_SET_COUNT(rreq->status, last);
 	    rreq->dev.segment_size = last;
 	    rreq->dev.segment_first = tmpbuf_last;
 	    rreq->status.MPI_ERROR = MPIR_Err_create_code(MPI_SUCCESS, 
@@ -600,7 +600,7 @@ int MPIDI_CH3U_Request_unpack_uebuf(MPID_Request * rreq)
 	      ", buf_sz=" MPIDI_MSG_SZ_FMT, 
                 rreq->dev.recv_data_sz, userbuf_sz));
 	unpack_sz = userbuf_sz;
-	MPIR_STATUS_SET_COUNT(rreq->status, (int)userbuf_sz);
+	MPIR_STATUS_SET_COUNT(rreq->status, userbuf_sz);
 	rreq->status.MPI_ERROR = MPIR_Err_create_code(MPI_SUCCESS, 
 		 MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_TRUNCATE,
 		 "**truncate", "**truncate %d %d", 
@@ -636,7 +636,7 @@ int MPIDI_CH3U_Request_unpack_uebuf(MPID_Request * rreq)
 		/* received data was not entirely consumed by unpack() 
 		   because too few bytes remained to fill the next basic
 		   datatype */
-		MPIR_STATUS_SET_COUNT(rreq->status, (int)last);
+		MPIR_STATUS_SET_COUNT(rreq->status, last);
 		rreq->status.MPI_ERROR = MPIR_Err_create_code(MPI_SUCCESS, 
                          MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_TYPE,
 			 "**dtypemismatch", 0);
diff --git a/src/mpid/ch3/src/mpidi_isend_self.c b/src/mpid/ch3/src/mpidi_isend_self.c
index 0658630..4d3ff12 100644
--- a/src/mpid/ch3/src/mpidi_isend_self.c
+++ b/src/mpid/ch3/src/mpidi_isend_self.c
@@ -74,7 +74,7 @@ int MPIDI_Isend_self(const void * buf, int count, MPI_Datatype datatype, int ran
 	    
 	MPIDI_CH3U_Buffer_copy(buf, count, datatype, &sreq->status.MPI_ERROR,
 			       rreq->dev.user_buf, rreq->dev.user_count, rreq->dev.datatype, &data_sz, &rreq->status.MPI_ERROR);
-	MPIR_STATUS_SET_COUNT(rreq->status, (int)data_sz);
+	MPIR_STATUS_SET_COUNT(rreq->status, data_sz);
 	MPID_REQUEST_SET_COMPLETED(rreq);
 	MPID_Request_release(rreq);
 	/* sreq has never been seen by the user or outside this thread, so it is safe to reset ref_count and cc */

http://git.mpich.org/mpich.git/commitdiff/bf57cc474ad6e29469bd91dd67b680c533edcd02

commit bf57cc474ad6e29469bd91dd67b680c533edcd02
Author: Jeff Hammond <jeff.science at gmail.com>
Date:   Tue Oct 15 14:07:53 2013 -0500

    return result of strlen to proper type
    
    strlen returns size_t.  since the return argument is localized, there is
    no reason to not use the proper type to hold the result.
    
    Signed-off-by: Rob Latham <robl at mcs.anl.gov>

diff --git a/src/mpl/src/mplstr.c b/src/mpl/src/mplstr.c
index a9ecb73..1f1f8f6 100644
--- a/src/mpl/src/mplstr.c
+++ b/src/mpl/src/mplstr.c
@@ -70,7 +70,7 @@ int MPL_snprintf(char *str, size_t size, mpl_const char *format, ...)
                     val = va_arg(list, int);
                     sprintf(tmp, "%d", val);
                     if (width > 0) {
-                        int tmplen = strlen(tmp);
+                        size_t tmplen = strlen(tmp);
                         /* If a width was specified, pad with spaces on the
                          * left (on the right if %-3d given; not implemented yet */
                         while (size-- > 0 && width-- > tmplen)
@@ -91,7 +91,7 @@ int MPL_snprintf(char *str, size_t size, mpl_const char *format, ...)
                     val = va_arg(list, int);
                     sprintf(tmp, "%x", val);
                     if (width > 0) {
-                        int tmplen = strlen(tmp);
+                        size_t tmplen = strlen(tmp);
                         /* If a width was specified, pad with spaces on the
                          * left (on the right if %-3d given; not implemented yet */
                         while (size-- > 0 && width-- > tmplen)
@@ -112,7 +112,7 @@ int MPL_snprintf(char *str, size_t size, mpl_const char *format, ...)
                     val = va_arg(list, void *);
                     sprintf(tmp, "%p", val);
                     if (width > 0) {
-                        int tmplen = strlen(tmp);
+                        size_t tmplen = strlen(tmp);
                         /* If a width was specified, pad with spaces on the
                          * left (on the right if %-3d given; not implemented yet */
                         while (size-- > 0 && width-- > tmplen)

http://git.mpich.org/mpich.git/commitdiff/91e91a4027c734b2d994aa10671f3e99f71465c7

commit 91e91a4027c734b2d994aa10671f3e99f71465c7
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Tue Oct 15 13:23:22 2013 -0500

    make shared file pointer code "large datatype" safe
    
    this internal-to-romio code was using 'ints' to store things like
    "datatype_size * count" calculation.  Promote that and all called paths
    to ADIO_Offset
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpi/romio/adio/ad_bg/ad_bg.h b/src/mpi/romio/adio/ad_bg/ad_bg.h
index a4de5e8..763c8de 100644
--- a/src/mpi/romio/adio/ad_bg/ad_bg.h
+++ b/src/mpi/romio/adio/ad_bg/ad_bg.h
@@ -86,7 +86,7 @@ void ADIOI_BG_WriteStridedColl(ADIO_File fd, const void *buf, int count,
                        ADIO_Offset offset, ADIO_Status *status, int
                        *error_code);
 
-void ADIOI_BG_Get_shared_fp(ADIO_File fd, int size, ADIO_Offset *shared_fp, int *error_code);
+void ADIOI_BG_Get_shared_fp(ADIO_File fd, ADIO_Offset size, ADIO_Offset *shared_fp, int *error_code);
 void ADIOI_BG_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code);
 
 void ADIOI_BG_Flush(ADIO_File fd, int *error_code);
diff --git a/src/mpi/romio/adio/ad_bg/ad_bg_getsh.c b/src/mpi/romio/adio/ad_bg/ad_bg_getsh.c
index 4195d55..f18db25 100644
--- a/src/mpi/romio/adio/ad_bg/ad_bg_getsh.c
+++ b/src/mpi/romio/adio/ad_bg/ad_bg_getsh.c
@@ -19,7 +19,7 @@
    shared_fp by the number of etypes to be accessed (incr) in the read
    or write following this function. */
 
-void ADIOI_BG_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp, 
+void ADIOI_BG_Get_shared_fp(ADIO_File fd, ADIO_Offset incr, ADIO_Offset *shared_fp,
 			 int *error_code)
 {
     ADIO_Offset new_fp;
diff --git a/src/mpi/romio/adio/ad_bgl/ad_bgl.h b/src/mpi/romio/adio/ad_bgl/ad_bgl.h
index 89d247b..73ab111 100644
--- a/src/mpi/romio/adio/ad_bgl/ad_bgl.h
+++ b/src/mpi/romio/adio/ad_bgl/ad_bgl.h
@@ -86,7 +86,7 @@ void ADIOI_BGL_WriteStridedColl(ADIO_File fd, void *buf, int count,
                        ADIO_Offset offset, ADIO_Status *status, int
                        *error_code);
 
-void ADIOI_BGL_Get_shared_fp(ADIO_File fd, int size, ADIO_Offset *shared_fp, int *error_code);
+void ADIOI_BGL_Get_shared_fp(ADIO_File fd, ADIO_Offset size, ADIO_Offset *shared_fp, int *error_code);
 void ADIOI_BGL_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code);
 
 void ADIOI_BGL_Flush(ADIO_File fd, int *error_code);
diff --git a/src/mpi/romio/adio/ad_bgl/ad_bgl_getsh.c b/src/mpi/romio/adio/ad_bgl/ad_bgl_getsh.c
index 2c51b1f..4b47c35 100644
--- a/src/mpi/romio/adio/ad_bgl/ad_bgl_getsh.c
+++ b/src/mpi/romio/adio/ad_bgl/ad_bgl_getsh.c
@@ -19,7 +19,7 @@
    shared_fp by the number of etypes to be accessed (incr) in the read
    or write following this function. */
 
-void ADIOI_BGL_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp, 
+void ADIOI_BGL_Get_shared_fp(ADIO_File fd, ADIO_Offset incr, ADIO_Offset *shared_fp,
 			 int *error_code)
 {
     ADIO_Offset new_fp;
diff --git a/src/mpi/romio/adio/ad_nfs/ad_nfs.h b/src/mpi/romio/adio/ad_nfs/ad_nfs.h
index b103779..83d394a 100644
--- a/src/mpi/romio/adio/ad_nfs/ad_nfs.h
+++ b/src/mpi/romio/adio/ad_nfs/ad_nfs.h
@@ -74,7 +74,7 @@ void ADIOI_NFS_ReadStrided(ADIO_File fd, void *buf, int count,
 		       ADIO_Offset offset, ADIO_Status *status, int
 		       *error_code);
 void ADIOI_NFS_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code);
-void ADIOI_NFS_Get_shared_fp(ADIO_File fd, int size, ADIO_Offset *shared_fp, 
+void ADIOI_NFS_Get_shared_fp(ADIO_File fd, ADIO_Offset size, ADIO_Offset *shared_fp,
 			 int *error_code);
 void ADIOI_NFS_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code);
 void ADIOI_NFS_Resize(ADIO_File fd, ADIO_Offset size, int *error_code);
diff --git a/src/mpi/romio/adio/ad_nfs/ad_nfs_getsh.c b/src/mpi/romio/adio/ad_nfs/ad_nfs_getsh.c
index 3f73a99..974d547 100644
--- a/src/mpi/romio/adio/ad_nfs/ad_nfs_getsh.c
+++ b/src/mpi/romio/adio/ad_nfs/ad_nfs_getsh.c
@@ -12,11 +12,11 @@
    shared_fp by the number of etypes to be accessed (incr) in the read
    or write following this function. */
 
-void ADIOI_NFS_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp, 
+void ADIOI_NFS_Get_shared_fp(ADIO_File fd, ADIO_Offset incr, ADIO_Offset *shared_fp,
 			 int *error_code)
 {
     ADIO_Offset new_fp;
-    int err;
+    ssize_t err;
     MPI_Comm dupcommself;
     static char myname[] = "ADIOI_NFS_GET_SHARED_FP";
 
diff --git a/src/mpi/romio/adio/ad_nfs/ad_nfs_setsh.c b/src/mpi/romio/adio/ad_nfs/ad_nfs_setsh.c
index 34c92ba..42e558c 100644
--- a/src/mpi/romio/adio/ad_nfs/ad_nfs_setsh.c
+++ b/src/mpi/romio/adio/ad_nfs/ad_nfs_setsh.c
@@ -30,7 +30,7 @@ Unlock
 
 void ADIOI_NFS_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code)
 {
-    int err;
+    ssize_t err;
     MPI_Comm dupcommself;
     static char myname[] = "ADIOI_NFS_SET_SHARED_FP";
 
diff --git a/src/mpi/romio/adio/common/ad_get_sh_fp.c b/src/mpi/romio/adio/common/ad_get_sh_fp.c
index 5610915..1252043 100644
--- a/src/mpi/romio/adio/common/ad_get_sh_fp.c
+++ b/src/mpi/romio/adio/common/ad_get_sh_fp.c
@@ -18,10 +18,10 @@ void ADIOI_BG_Get_shared_fp(ADIO_File fd, int size, ADIO_Offset *shared_fp, int
    shared_fp by the number of etypes to be accessed (incr) in the read
    or write following this function. */
 
-void ADIOI_NFS_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp, 
+void ADIOI_NFS_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp,
                              int *error_code);
 
-void ADIO_Get_shared_fp(ADIO_File fd, int incr, ADIO_Offset *shared_fp, 
+void ADIO_Get_shared_fp(ADIO_File fd, ADIO_Offset incr, ADIO_Offset *shared_fp,
 			 int *error_code)
 {
     ADIO_Status status;
diff --git a/src/mpi/romio/adio/common/ad_prealloc.c b/src/mpi/romio/adio/common/ad_prealloc.c
index 0cc8d2b..9462f77 100644
--- a/src/mpi/romio/adio/common/ad_prealloc.c
+++ b/src/mpi/romio/adio/common/ad_prealloc.c
@@ -15,9 +15,9 @@
  */
 void ADIOI_GEN_Prealloc(ADIO_File fd, ADIO_Offset diskspace, int *error_code) 
 {
-	ADIO_Offset curr_fsize, alloc_size, size, len, done;
+	ADIO_Offset curr_fsize, alloc_size, size, len, done, ntimes;
 	ADIO_Status status;
-	int i, ntimes;
+	int i;
 	char *buf;
 	ADIO_Fcntl_t *fcntl_struct;
 	static char myname[] = "ADIOI_GEN_PREALLOC";
@@ -48,7 +48,7 @@ void ADIOI_GEN_Prealloc(ADIO_File fd, ADIO_Offset diskspace, int *error_code)
 	for (i=0; i<ntimes; i++) {
 	    len = ADIOI_MIN(size-done, ADIOI_PREALLOC_BUFSZ);
 	    ADIO_ReadContig(fd, buf, 
-                      len, /* len is ADIO_Offset but is <= ADIOI_PREALLOC_BUFSZ (16M), 
+                      (int)len, /* len is ADIO_Offset but is <= ADIOI_PREALLOC_BUFSZ (16M),
                               so it fits in an int parameter */
                       MPI_BYTE, ADIO_EXPLICIT_OFFSET, done,
 			    &status, error_code);
@@ -62,7 +62,7 @@ void ADIOI_GEN_Prealloc(ADIO_File fd, ADIO_Offset diskspace, int *error_code)
                 return;  
 	    }
 	    ADIO_WriteContig(fd, buf, 
-                       len, /* len is ADIO_Offset but is <= ADIOI_PREALLOC_BUFSZ (16M), 
+                       (int)len, /* len is ADIO_Offset but is <= ADIOI_PREALLOC_BUFSZ (16M),
                                so it fits in an int parameter */
                        MPI_BYTE, ADIO_EXPLICIT_OFFSET, 
                              done, &status, error_code);
@@ -77,7 +77,7 @@ void ADIOI_GEN_Prealloc(ADIO_File fd, ADIO_Offset diskspace, int *error_code)
 	    for (i=0; i<ntimes; i++) {
 		len = ADIOI_MIN(alloc_size-done, ADIOI_PREALLOC_BUFSZ);
 		ADIO_WriteContig(fd, buf, 
-                     len, /* len is ADIO_Offset but is <= ADIOI_PREALLOC_BUFSZ (16M), 
+                     (int)len, /* len is ADIO_Offset but is <= ADIOI_PREALLOC_BUFSZ (16M),
                              so it fits in an int parameter */
                      MPI_BYTE, ADIO_EXPLICIT_OFFSET, 
 				 done, &status, error_code);
diff --git a/src/mpi/romio/adio/common/eof_offset.c b/src/mpi/romio/adio/common/eof_offset.c
index 1b2c9ae..c873ffd 100644
--- a/src/mpi/romio/adio/common/eof_offset.c
+++ b/src/mpi/romio/adio/common/eof_offset.c
@@ -14,8 +14,8 @@
 void ADIOI_Get_eof_offset(ADIO_File fd, ADIO_Offset *eof_offset)
 {
     unsigned filetype_size;
-    int error_code, filetype_is_contig, etype_size;
-    ADIO_Offset fsize, disp, sum=0, size_in_file, n_filetypes, rem;
+    int error_code, filetype_is_contig;
+    ADIO_Offset fsize, disp, sum=0, size_in_file, n_filetypes, rem, etype_size;
     int flag, i;
     ADIO_Fcntl_t *fcntl_struct;
     MPI_Aint filetype_extent;
diff --git a/src/mpi/romio/adio/common/system_hints.c b/src/mpi/romio/adio/common/system_hints.c
index 5b28d4d..507e188 100644
--- a/src/mpi/romio/adio/common/system_hints.c
+++ b/src/mpi/romio/adio/common/system_hints.c
@@ -94,7 +94,8 @@ static int file_to_info(int fd, MPI_Info info)
 {
     char *buffer, *token, *key, *val, *garbage;
     char *pos1=NULL, *pos2=NULL;
-    int flag, ret;
+    int flag;
+    ssize_t ret;
     char dummy;
     struct stat statbuf;
 
diff --git a/src/mpi/romio/adio/include/adio.h b/src/mpi/romio/adio/include/adio.h
index d168ac5..26f1659 100644
--- a/src/mpi/romio/adio/include/adio.h
+++ b/src/mpi/romio/adio/include/adio.h
@@ -397,7 +397,7 @@ void ADIO_Resize(ADIO_File fd, ADIO_Offset size, int *error_code);
 void ADIO_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code);
 void ADIO_ResolveFileType(MPI_Comm comm, const char *filename, int *fstype,
           ADIOI_Fns **ops, int *error_code);
-void ADIO_Get_shared_fp(ADIO_File fd, int size, ADIO_Offset *shared_fp, 
+void ADIO_Get_shared_fp(ADIO_File fd, ADIO_Offset size, ADIO_Offset *shared_fp,
 			 int *error_code);
 void ADIO_Set_shared_fp(ADIO_File fd, ADIO_Offset offset, int *error_code);
 void ADIO_Set_view(ADIO_File fd, ADIO_Offset disp, MPI_Datatype etype, 
diff --git a/src/mpi/romio/mpi-io/iread.c b/src/mpi/romio/mpi-io/iread.c
index 7f4d154..861e7eb 100644
--- a/src/mpi/romio/mpi-io/iread.c
+++ b/src/mpi/romio/mpi-io/iread.c
@@ -73,11 +73,11 @@ int MPI_File_iread(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI
 int MPIOI_File_iread(MPI_File fh, MPI_Offset offset, int file_ptr_type, void *buf, int count,
 		     MPI_Datatype datatype, char *myname, MPI_Request *request)
 {
-    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
+    int error_code, buftype_is_contig, filetype_is_contig;
     MPI_Count datatype_size;
     ADIO_Status status;
     ADIO_File adio_fh;
-    ADIO_Offset off;
+    ADIO_Offset off, bufsize;
     MPI_Offset nbytes=0;
 
     MPIU_THREAD_CS_ENTER(ALLFUNC,);
diff --git a/src/mpi/romio/mpi-io/iread_sh.c b/src/mpi/romio/mpi-io/iread_sh.c
index a218daa..a9564ed 100644
--- a/src/mpi/romio/mpi-io/iread_sh.c
+++ b/src/mpi/romio/mpi-io/iread_sh.c
@@ -43,7 +43,8 @@ Output Parameters:
 int MPI_File_iread_shared(MPI_File fh, void *buf, int count,
                           MPI_Datatype datatype, MPI_Request *request)
 {
-    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
+    int error_code, buftype_is_contig, filetype_is_contig;
+    ADIO_Offset bufsize;
     ADIO_File adio_fh;
     static char myname[] = "MPI_FILE_IREAD_SHARED";
     MPI_Count datatype_size, incr;
diff --git a/src/mpi/romio/mpi-io/iwrite.c b/src/mpi/romio/mpi-io/iwrite.c
index 5bfdd78..e6a2026 100644
--- a/src/mpi/romio/mpi-io/iwrite.c
+++ b/src/mpi/romio/mpi-io/iwrite.c
@@ -80,10 +80,10 @@ int MPIOI_File_iwrite(MPI_File fh,
 		      char *myname,
 		      MPI_Request *request)
 {
-    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
+    int error_code, buftype_is_contig, filetype_is_contig;
     MPI_Count datatype_size;
     ADIO_Status status;
-    ADIO_Offset off;
+    ADIO_Offset off, bufsize;
     ADIO_File adio_fh;
     MPI_Offset nbytes=0;
 
diff --git a/src/mpi/romio/mpi-io/iwrite_sh.c b/src/mpi/romio/mpi-io/iwrite_sh.c
index 49c0d30..8d3c7cd 100644
--- a/src/mpi/romio/mpi-io/iwrite_sh.c
+++ b/src/mpi/romio/mpi-io/iwrite_sh.c
@@ -44,9 +44,9 @@ Output Parameters:
 int MPI_File_iwrite_shared(MPI_File fh, const void *buf, int count,
 			   MPI_Datatype datatype, MPIO_Request *request)
 {
-    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
+    int error_code, buftype_is_contig, filetype_is_contig;
     ADIO_File adio_fh;
-    int incr;
+    ADIO_Offset incr, bufsize;
     MPI_Count datatype_size;
     ADIO_Status status;
     ADIO_Offset off, shared_fp;
diff --git a/src/mpi/romio/mpi-io/read.c b/src/mpi/romio/mpi-io/read.c
index e5b7238..92f11c8 100644
--- a/src/mpi/romio/mpi-io/read.c
+++ b/src/mpi/romio/mpi-io/read.c
@@ -70,10 +70,10 @@ int MPIOI_File_read(MPI_File fh,
 		    char *myname,
 		    MPI_Status *status)
 {
-    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
+    int error_code, buftype_is_contig, filetype_is_contig;
     MPI_Count datatype_size;
     ADIO_File adio_fh;
-    ADIO_Offset off;
+    ADIO_Offset off, bufsize;
     void *xbuf=NULL, *e32_buf=NULL;
 
     MPIU_THREAD_CS_ENTER(ALLFUNC,);
diff --git a/src/mpi/romio/mpi-io/read_ord.c b/src/mpi/romio/mpi-io/read_ord.c
index 19ced81..5dc5abd 100644
--- a/src/mpi/romio/mpi-io/read_ord.c
+++ b/src/mpi/romio/mpi-io/read_ord.c
@@ -42,7 +42,8 @@ Output Parameters:
 int MPI_File_read_ordered(MPI_File fh, void *buf, int count,
                           MPI_Datatype datatype, MPI_Status *status)
 {
-    int error_code, nprocs, myrank, incr;
+    int error_code, nprocs, myrank;
+    ADIO_Offset incr;
     MPI_Count datatype_size;
     int source, dest;
     static char myname[] = "MPI_FILE_READ_ORDERED";
diff --git a/src/mpi/romio/mpi-io/read_ordb.c b/src/mpi/romio/mpi-io/read_ordb.c
index b29488d..5dd9772 100644
--- a/src/mpi/romio/mpi-io/read_ordb.c
+++ b/src/mpi/romio/mpi-io/read_ordb.c
@@ -39,10 +39,10 @@ Output Parameters:
 int MPI_File_read_ordered_begin(MPI_File fh, void *buf, int count,
 				MPI_Datatype datatype)
 {
-    int error_code,  nprocs, myrank, incr;
+    int error_code,  nprocs, myrank;
     MPI_Count datatype_size;
     int source, dest;
-    ADIO_Offset shared_fp;
+    ADIO_Offset shared_fp, incr;
     ADIO_File adio_fh;
     static char myname[] = "MPI_FILE_READ_ORDERED_BEGIN";
     void *xbuf=NULL, *e32_buf=NULL;
diff --git a/src/mpi/romio/mpi-io/read_sh.c b/src/mpi/romio/mpi-io/read_sh.c
index 65dd442..952180e 100644
--- a/src/mpi/romio/mpi-io/read_sh.c
+++ b/src/mpi/romio/mpi-io/read_sh.c
@@ -42,11 +42,10 @@ Output Parameters:
 int MPI_File_read_shared(MPI_File fh, void *buf, int count,
 			 MPI_Datatype datatype, MPI_Status *status)
 {
-    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
+    int error_code, buftype_is_contig, filetype_is_contig;
     static char myname[] = "MPI_FILE_READ_SHARED";
-    int incr;
     MPI_Count datatype_size;
-    ADIO_Offset off, shared_fp;
+    ADIO_Offset off, shared_fp, incr, bufsize;
     ADIO_File adio_fh;
     void *xbuf=NULL, *e32_buf=NULL;
 
diff --git a/src/mpi/romio/mpi-io/write.c b/src/mpi/romio/mpi-io/write.c
index 62d6eb0..ef066a1 100644
--- a/src/mpi/romio/mpi-io/write.c
+++ b/src/mpi/romio/mpi-io/write.c
@@ -70,9 +70,9 @@ int MPIOI_File_write(MPI_File fh,
 		     char *myname,
 		     MPI_Status *status)
 {		      
-    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
+    int error_code, buftype_is_contig, filetype_is_contig;
     MPI_Count datatype_size;
-    ADIO_Offset off;
+    ADIO_Offset off, bufsize;
     ADIO_File adio_fh;
     void *e32buf=NULL;
     const void *xbuf=NULL;
diff --git a/src/mpi/romio/mpi-io/write_ord.c b/src/mpi/romio/mpi-io/write_ord.c
index 22f1f06..fd28480 100644
--- a/src/mpi/romio/mpi-io/write_ord.c
+++ b/src/mpi/romio/mpi-io/write_ord.c
@@ -43,7 +43,8 @@ Output Parameters:
 int MPI_File_write_ordered(MPI_File fh, const void *buf, int count,
 			   MPI_Datatype datatype, MPI_Status *status)
 {
-    int error_code, nprocs, myrank, incr;
+    int error_code, nprocs, myrank;
+    ADIO_Offset incr;
     MPI_Count datatype_size;
     int source, dest;
     static char myname[] = "MPI_FILE_WRITE_ORDERED";
diff --git a/src/mpi/romio/mpi-io/write_ordb.c b/src/mpi/romio/mpi-io/write_ordb.c
index 848de29..968df19 100644
--- a/src/mpi/romio/mpi-io/write_ordb.c
+++ b/src/mpi/romio/mpi-io/write_ordb.c
@@ -39,7 +39,8 @@ Output Parameters:
 int MPI_File_write_ordered_begin(MPI_File fh, const void *buf, int count,
 				 MPI_Datatype datatype)
 {
-    int error_code, nprocs, myrank, incr;
+    int error_code, nprocs, myrank;
+    ADIO_Offset incr;
     MPI_Count datatype_size;
     int source, dest;
     static char myname[] = "MPI_FILE_WRITE_ORDERED_BEGIN";
diff --git a/src/mpi/romio/mpi-io/write_sh.c b/src/mpi/romio/mpi-io/write_sh.c
index 870e901..39b72ce 100644
--- a/src/mpi/romio/mpi-io/write_sh.c
+++ b/src/mpi/romio/mpi-io/write_sh.c
@@ -42,7 +42,8 @@ Output Parameters:
 int MPI_File_write_shared(MPI_File fh, const void *buf, int count,
                           MPI_Datatype datatype, MPI_Status *status)
 {
-    int error_code, bufsize, buftype_is_contig, filetype_is_contig;
+    int error_code, buftype_is_contig, filetype_is_contig;
+    ADIO_Offset bufsize;
     static char myname[] = "MPI_FILE_READ_SHARED";
     MPI_Count datatype_size, incr;
     ADIO_Offset off, shared_fp;

http://git.mpich.org/mpich.git/commitdiff/e192ccc594a0f086c4bb5239d413df0e1f3d4f03

commit e192ccc594a0f086c4bb5239d413df0e1f3d4f03
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Tue Aug 27 13:59:45 2013 -0500

    datatype_size no longer needs to be an integer
    
    MPIO_CHECK_COUNT_SIZE was designed to ensure "count*datatype_size" did
    not overflow integers.  Well, I've done my best to relax that need
    throughout MPICH, so the cast to unsigned is not needed.
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpi/romio/adio/include/adioi_error.h b/src/mpi/romio/adio/include/adioi_error.h
index 88a0408..9045282 100644
--- a/src/mpi/romio/adio/include/adioi_error.h
+++ b/src/mpi/romio/adio/include/adioi_error.h
@@ -48,7 +48,7 @@ if (count < 0) {						\
 }
 
 #define MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code)         \
-if (count*datatype_size != (ADIO_Offset)(unsigned)count*(ADIO_Offset)(unsigned)datatype_size) {	\
+if (count*datatype_size != (ADIO_Offset)(unsigned)count*(ADIO_Offset)datatype_size) {	\
     error_code = MPIO_Err_create_code(MPI_SUCCESS,		\
 				      MPIR_ERR_RECOVERABLE,	\
 				      myname, __LINE__,		\

http://git.mpich.org/mpich.git/commitdiff/615d1acb0578253395f4fb9b00d07f52cb30482a

commit 615d1acb0578253395f4fb9b00d07f52cb30482a
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Mon Jul 29 09:08:58 2013 -0500

    implement MPIU_Assign_trunc without _Generic
    
    The test suite has failures like this:
    
    Assertion failed in file
    /home/robl/work/mpich/src/mpid/ch3/src/ch3u_rma_ops.c at line 552
    : ((dloop_vec[i].iov_len)/type_size) >= expr_inttype_min(count)
    
    Even though dloop_vec[i].iov_len is 4, type_size is 4, and
    expr_inttype_min(count) is -INT_MAX, this assertion is still failing.
    
    while the _Generic-based test was giving strange assertion failures, the
    cast-and-compare version still works and should be used.
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/include/mpiutil.h b/src/include/mpiutil.h
index 266fbe1..f2fbaf0 100644
--- a/src/include/mpiutil.h
+++ b/src/include/mpiutil.h
@@ -223,6 +223,10 @@ int MPIR_Assert_fail_fmt(const char *cond, const char *file_name, int line_num,
  * promotion/truncation/conversion rules in mind.  A discussion of these issues
  * can be found in Chapter 5 of "Secure Coding in C and C++" by Robert Seacord.
  */
+/* this "check for overflow" macro seems buggy in a crazy way that I can't
+ * figure out. Instead of using the clever 'expr_inttype_max' macro, fall back
+ * to simple "cast and check for obvious overflow" */
+#if 0
 #if defined(expr_inttype_max) && defined(expr_inttype_min)
 #  define MPIU_Assign_trunc(dst_,src_,dst_type_)                                       \
     do {                                                                               \
@@ -231,14 +235,14 @@ int MPIR_Assert_fail_fmt(const char *cond, const char *file_name, int line_num,
         MPIU_Assert((src_) >= expr_inttype_min(dst_));                                 \
         dst_ = (dst_type_)(src_);                                                      \
     } while (0)
-#else
-#  define MPIU_Assign_trunc(dst_,src_,dst_type_)                                       \
+#endif
+#endif
+#define MPIU_Assign_trunc(dst_,src_,dst_type_)                                         \
     do {                                                                               \
         dst_ = (dst_type_)(src_);                                                      \
         /* will catch some of the cases if the expr_inttype macros aren't available */ \
         MPIU_Assert((dst_) == (src_));                                                 \
     } while (0)
-#endif
 
 /*
  * Ensure an MPI_Aint value fits into a signed int.

http://git.mpich.org/mpich.git/commitdiff/e6962c162c743eb130e732e1d3ae8a8f6f7c719c

commit e6962c162c743eb130e732e1d3ae8a8f6f7c719c
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Fri Jul 19 10:52:28 2013 -0500

    resized wasn't setting max_contig_count
    
    Not much in MPICH consults the max_contig_count field of the datatypes,
    except ROMIO.  Resized types were reporting "huge negative number" for
    the count of contiguous blocks because datatype code wasn't setting the
    max_contig_count member.  Why 3?  The lower bound and upper bound parts
    of the datatype, while not actually data or blocks, are effectively
    blocks for the purposes of the one client of this code -- the ROMIO
    datatype flattening code.
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpid/common/datatype/mpid_type_create_resized.c b/src/mpid/common/datatype/mpid_type_create_resized.c
index 2120b32..07d753d 100644
--- a/src/mpid/common/datatype/mpid_type_create_resized.c
+++ b/src/mpid/common/datatype/mpid_type_create_resized.c
@@ -60,6 +60,7 @@ int MPID_Type_create_resized(MPI_Datatype oldtype,
 	new_dtp->element_size   = oldsize;
 	new_dtp->is_contig      = (extent == oldsize) ? 1 : 0;
         new_dtp->eltype         = oldtype;
+	new_dtp->max_contig_blocks = 3;  /* lb, data, ub */
     }
     else
     {
@@ -84,6 +85,7 @@ int MPID_Type_create_resized(MPI_Datatype oldtype,
 
 	new_dtp->is_contig      =
 	    (extent == old_dtp->size) ? old_dtp->is_contig : 0;
+	new_dtp->max_contig_blocks = old_dtp->max_contig_blocks;
     }
 
     *newtype_p = new_dtp->handle;

http://git.mpich.org/mpich.git/commitdiff/d4e6334c3ae2ae9925306087051b5a930d9ffde2

commit d4e6334c3ae2ae9925306087051b5a930d9ffde2
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Tue Jul 16 09:14:48 2013 -0500

    More ROMIO updates for large count
    
    When flattening a datatype, be mindful of overflowing integers
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpi/romio/adio/common/flatten.c b/src/mpi/romio/adio/common/flatten.c
index 80fdd4c..c75bce0 100644
--- a/src/mpi/romio/adio/common/flatten.c
+++ b/src/mpi/romio/adio/common/flatten.c
@@ -731,11 +731,11 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
  *
  * ASSUMES THAT TYPE IS NOT A BASIC!!!
  */
-int ADIOI_Count_contiguous_blocks(MPI_Datatype datatype, int *curr_index)
+MPI_Count ADIOI_Count_contiguous_blocks(MPI_Datatype datatype, MPI_Count *curr_index)
 {
 #ifdef HAVE_MPIR_TYPE_GET_CONTIG_BLOCKS
     /* MPICH can get us this value without all the envelope/contents calls */
-    int blks;
+    MPI_Count blks;
     MPIR_Type_get_contig_blocks(datatype, &blks);
     *curr_index = blks;
     return blks;
diff --git a/src/mpi/romio/adio/include/adioi.h b/src/mpi/romio/adio/include/adioi.h
index d138697..4eb926a 100644
--- a/src/mpi/romio/adio/include/adioi.h
+++ b/src/mpi/romio/adio/include/adioi.h
@@ -320,7 +320,7 @@ void ADIOI_Flatten_datatype(MPI_Datatype type);
 void ADIOI_Flatten(MPI_Datatype type, ADIOI_Flatlist_node *flat,
 		  ADIO_Offset st_offset, MPI_Count *curr_index);
 void ADIOI_Delete_flattened(MPI_Datatype datatype);
-int ADIOI_Count_contiguous_blocks(MPI_Datatype type, int *curr_index);
+MPI_Count ADIOI_Count_contiguous_blocks(MPI_Datatype type, MPI_Count *curr_index);
 void ADIOI_Complete_async(int *error_code);
 void *ADIOI_Malloc_fn(size_t size, int lineno, const char *fname);
 void *ADIOI_Calloc_fn(size_t nelem, size_t elsize, int lineno, const char *fname);

http://git.mpich.org/mpich.git/commitdiff/c66f901220b086cda4cdc5d3739abc66a885bee0

commit c66f901220b086cda4cdc5d3739abc66a885bee0
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Fri Jul 12 08:55:26 2013 -0500

    Increase size of internal datatype values
    
    Trying to find all places in the datatype/dataloop code that put size of
    datatype into an integer.  It's easy, even under MPI-2, to describe more
    than an integers worth of data with an MPI datatype.
    
    since Dataloop code calls other dataloop code, just go ahead and make
    everything a DLOOP_Count type
    
    Fixes #1890
    Fixes #1893
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpi/datatype/type_match_size.c b/src/mpi/datatype/type_match_size.c
index 5062849..cebc7e2 100644
--- a/src/mpi/datatype/type_match_size.c
+++ b/src/mpi/datatype/type_match_size.c
@@ -77,7 +77,8 @@ int MPI_Type_match_size(int typeclass, int size, MPI_Datatype *datatype)
 	MPI_C_COMPLEX, MPI_C_DOUBLE_COMPLEX, MPI_C_LONG_DOUBLE_COMPLEX,
     };
     MPI_Datatype matched_datatype = MPI_DATATYPE_NULL;
-    int i, tsize;
+    int i;
+    MPI_Aint tsize;
     MPIU_THREADPRIV_DECL;
     MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_MATCH_SIZE);
 
diff --git a/src/mpid/common/datatype/dataloop/dataloop.c b/src/mpid/common/datatype/dataloop/dataloop.c
index e96b2c5..532c51d 100644
--- a/src/mpid/common/datatype/dataloop/dataloop.c
+++ b/src/mpid/common/datatype/dataloop/dataloop.c
@@ -97,13 +97,13 @@ Input Parameters:
 @*/
 void PREPEND_PREFIX(Dataloop_copy)(void *dest,
 				   void *src,
-				   int size)
+				   DLOOP_Size size)
 {
     DLOOP_Offset ptrdiff;
 
 #ifdef DLOOP_DEBUG_MEMORY
-    DLOOP_dbg_printf("DLOOP_Dataloop_copy: copying from %x to %x (%d bytes).\n",
-		     (int) src, (int) dest, size);
+    DLOOP_dbg_printf("DLOOP_Dataloop_copy: copying from %x to %x (%z bytes).\n",
+		     (int) src, (int) dest, (size_t)size);
 #endif
 
     /* copy region first */
@@ -286,7 +286,7 @@ Input Parameters:
 void PREPEND_PREFIX(Dataloop_alloc)(int kind,
 				    DLOOP_Count count,
 				    DLOOP_Dataloop **new_loop_p,
-				    int *new_loop_sz_p)
+				    MPI_Aint *new_loop_sz_p)
 {
     PREPEND_PREFIX(Dataloop_alloc_and_copy)(kind,
 					    count,
@@ -317,15 +317,15 @@ Input Parameters:
 void PREPEND_PREFIX(Dataloop_alloc_and_copy)(int kind,
 					     DLOOP_Count count,
 					     DLOOP_Dataloop *old_loop,
-					     int old_loop_sz,
+					     DLOOP_Size old_loop_sz,
 					     DLOOP_Dataloop **new_loop_p,
-					     int *new_loop_sz_p)
+					     DLOOP_Size *new_loop_sz_p)
 {
-    int new_loop_sz = 0;
+    DLOOP_Size new_loop_sz = 0;
     int align_sz = 8; /* default aligns everything to 8-byte boundaries */
     int epsilon;
-    int loop_sz = sizeof(DLOOP_Dataloop);
-    int off_sz = 0, blk_sz = 0, ptr_sz = 0, extent_sz = 0;
+    DLOOP_Size loop_sz = sizeof(DLOOP_Dataloop);
+    DLOOP_Size off_sz = 0, blk_sz = 0, ptr_sz = 0, extent_sz = 0;
 
     char *pos;
     DLOOP_Dataloop *new_loop;
@@ -386,7 +386,7 @@ void PREPEND_PREFIX(Dataloop_alloc_and_copy)(int kind,
     }
 
 #ifdef DLOOP_DEBUG_MEMORY
-    DLOOP_dbg_printf("DLOOP_Dataloop_alloc_and_copy: new loop @ %x (tot sz = %d, loop = %d, off = %d, blk = %d, ptr = %d, extent = %d, old = %d)\n",
+    DLOOP_dbg_printf("DLOOP_Dataloop_alloc_and_copy: new loop @ %x (tot sz = %z, loop = %z, off = %z, blk = %z, ptr = %z, extent = %z, old = %z)\n",
 		     (int) new_loop,
 		     new_loop_sz,
 		     loop_sz,
@@ -505,17 +505,17 @@ Input Parameters:
   old_loop_p (count elements).
 @*/
 void PREPEND_PREFIX(Dataloop_struct_alloc)(DLOOP_Count count,
-					   int old_loop_sz,
+					   DLOOP_Size old_loop_sz,
 					   int basic_ct,
 					   DLOOP_Dataloop **old_loop_p,
 					   DLOOP_Dataloop **new_loop_p,
-					   int *new_loop_sz_p)
+					   DLOOP_Size *new_loop_sz_p)
 {
-    int new_loop_sz = 0;
+    DLOOP_Size new_loop_sz = 0;
     int align_sz = 8; /* default aligns everything to 8-byte boundaries */
     int epsilon;
-    int loop_sz = sizeof(DLOOP_Dataloop);
-    int off_sz, blk_sz, ptr_sz, extent_sz, basic_sz;
+    DLOOP_Size loop_sz = sizeof(DLOOP_Dataloop);
+    DLOOP_Size off_sz, blk_sz, ptr_sz, extent_sz, basic_sz;
 
     DLOOP_Dataloop *new_loop;
 
@@ -567,7 +567,7 @@ void PREPEND_PREFIX(Dataloop_struct_alloc)(DLOOP_Count count,
     }
 
 #ifdef DLOOP_DEBUG_MEMORY
-    DLOOP_dbg_printf("DLOOP_Dataloop_struct_alloc: new loop @ %x (tot sz = %d, loop = %d, off = %d, blk = %d, ptr = %d, extent = %d, basics = %d, old = %d)\n",
+    DLOOP_dbg_printf("DLOOP_Dataloop_struct_alloc: new loop @ %x (tot sz = %z, loop = %z, off = %z, blk = %z, ptr = %z, extent = %z, basics = %z, old = %z)\n",
 		     (int) new_loop,
 		     new_loop_sz,
 		     loop_sz,
@@ -603,7 +603,7 @@ void PREPEND_PREFIX(Dataloop_struct_alloc)(DLOOP_Count count,
   Returns 0 on success, -1 on failure.
 @*/
 void PREPEND_PREFIX(Dataloop_dup)(DLOOP_Dataloop *old_loop,
-				  int old_loop_sz,
+				  DLOOP_Count old_loop_sz,
 				  DLOOP_Dataloop **new_loop_p)
 {
     DLOOP_Dataloop *new_loop;
diff --git a/src/mpid/common/datatype/dataloop/dataloop_create.c b/src/mpid/common/datatype/dataloop/dataloop_create.c
index b16b63f..1d9f3d7 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_create.c
+++ b/src/mpid/common/datatype/dataloop/dataloop_create.c
@@ -12,13 +12,13 @@
 
 static void DLOOP_Dataloop_create_named(MPI_Datatype type,
 					DLOOP_Dataloop **dlp_p,
-					int *dlsz_p,
+					MPI_Aint *dlsz_p,
 					int *dldepth_p,
 					int flag);
 
 void PREPEND_PREFIX(Dataloop_create)(MPI_Datatype type,
 				     DLOOP_Dataloop **dlp_p,
-				     int *dlsz_p,
+				     MPI_Aint *dlsz_p,
 				     int *dldepth_p,
 				     int flag)
 {
@@ -31,13 +31,15 @@ void PREPEND_PREFIX(Dataloop_create)(MPI_Datatype type,
     MPI_Aint *aints;
 
     DLOOP_Dataloop *old_dlp;
-    int old_dlsz, old_dldepth;
+    MPI_Aint old_dlsz;
+    int old_dldepth;
 
     int dummy1, dummy2, dummy3, type0_combiner, ndims;
     MPI_Datatype tmptype;
 
     MPI_Aint stride;
     MPI_Aint *disps;
+    DLOOP_Size *blklen;
 
     MPIR_Type_get_envelope_impl(type, &nr_ints, &nr_aints, &nr_types, &combiner);
 
@@ -222,13 +224,17 @@ void PREPEND_PREFIX(Dataloop_create)(MPI_Datatype type,
             DLOOP_Free(disps);
 	    break;
 	case MPI_COMBINER_INDEXED:
+            blklen = (DLOOP_Size *) DLOOP_Malloc(ints[0] * sizeof(DLOOP_Size));
+            for (i = 0; i < ints[0]; i++)
+                blklen[i] = ints[1+i];
 	    PREPEND_PREFIX(Dataloop_create_indexed)(ints[0] /* count */,
-						    &ints[1] /* blklens */,
+						    blklen /* blklens */,
 						    &ints[ints[0]+1] /* disp */,
 						    0 /* disp not in bytes */,
 						    types[0] /* oldtype */,
 						    dlp_p, dlsz_p, dldepth_p,
 						    flag);
+	    DLOOP_Free(blklen);
 	    break;
 	case MPI_COMBINER_HINDEXED_INTEGER:
 	case MPI_COMBINER_HINDEXED:
@@ -243,8 +249,11 @@ void PREPEND_PREFIX(Dataloop_create)(MPI_Datatype type,
 		disps = aints;
 	    }
 
+	    blklen = (DLOOP_Size *) DLOOP_Malloc(ints[0] * sizeof(DLOOP_Size));
+	    for (i=0; i< ints[0]; i++)
+		blklen[i] = (DLOOP_Size) ints[1+i];
 	    PREPEND_PREFIX(Dataloop_create_indexed)(ints[0] /* count */,
-						    &ints[1] /* blklens */,
+						    blklen /* blklens */,
 						    disps,
 						    1 /* disp in bytes */,
 						    types[0] /* oldtype */,
@@ -254,6 +263,7 @@ void PREPEND_PREFIX(Dataloop_create)(MPI_Datatype type,
 	    if (combiner == MPI_COMBINER_HINDEXED_INTEGER) {
 		DLOOP_Free(disps);
 	    }
+	    DLOOP_Free(blklen);
 
 	    break;
 	case MPI_COMBINER_STRUCT_INTEGER:
@@ -372,7 +382,7 @@ void PREPEND_PREFIX(Dataloop_create)(MPI_Datatype type,
 @*/
 static void DLOOP_Dataloop_create_named(MPI_Datatype type,
 					DLOOP_Dataloop **dlp_p,
-					int *dlsz_p,
+					MPI_Aint *dlsz_p,
 					int *dldepth_p,
 					int flag)
 {
diff --git a/src/mpid/common/datatype/dataloop/dataloop_create.h b/src/mpid/common/datatype/dataloop/dataloop_create.h
index 1d28d2d..f054429 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_create.h
+++ b/src/mpid/common/datatype/dataloop/dataloop_create.h
@@ -11,53 +11,56 @@
 /* Dataloop construction functions */
 void PREPEND_PREFIX(Dataloop_create)(MPI_Datatype type,
 				     DLOOP_Dataloop **dlp_p,
-				     int *dlsz_p,
+				     DLOOP_Size *dlsz_p,
 				     int *dldepth_p,
 				     int flag);
-int PREPEND_PREFIX(Dataloop_create_contiguous)(int count,
+int PREPEND_PREFIX(Dataloop_create_contiguous)(DLOOP_Count count,
 					       MPI_Datatype oldtype,
 					       DLOOP_Dataloop **dlp_p,
-					       int *dlsz_p,
+					       DLOOP_Size *dlsz_p,
 					       int *dldepth_p,
 					       int flag);
-int PREPEND_PREFIX(Dataloop_create_vector)(int count,
-					   int blocklength,
+int PREPEND_PREFIX(Dataloop_create_vector)(DLOOP_Count count,
+					   DLOOP_Size blocklength,
 					   MPI_Aint stride,
 					   int strideinbytes,
 					   MPI_Datatype oldtype,
 					   DLOOP_Dataloop **dlp_p,
-					   int *dlsz_p,
+					   DLOOP_Size *dlsz_p,
 					   int *dldepth_p,
 					   int flag);
-int PREPEND_PREFIX(Dataloop_create_blockindexed)(int count,
-						 int blklen,
+int PREPEND_PREFIX(Dataloop_create_blockindexed)(DLOOP_Count count,
+						 DLOOP_Size blklen,
 						 const void *disp_array,
 						 int dispinbytes,
 						 MPI_Datatype oldtype,
 						 DLOOP_Dataloop **dlp_p,
-						 int *dlsz_p,
+						 DLOOP_Size *dlsz_p,
 						 int *dldepth_p,
 						 int flag);
-int PREPEND_PREFIX(Dataloop_create_indexed)(int count,
-					    const int *blocklength_array,
+/* we bump up the size of the blocklength array because create_struct might use
+ * create_indexed in an optimization, and in course of doing so, generate a
+ * request of a large blocklength. */
+int PREPEND_PREFIX(Dataloop_create_indexed)(DLOOP_Count count,
+					    const DLOOP_Size *blocklength_array,
 					    const void *displacement_array,
 					    int dispinbytes,
 					    MPI_Datatype oldtype,
 					    DLOOP_Dataloop **dlp_p,
-					    int *dlsz_p,
+					    DLOOP_Size *dlsz_p,
 					    int *dldepth_p,
 					    int flag);
-int PREPEND_PREFIX(Dataloop_create_struct)(int count,
+int PREPEND_PREFIX(Dataloop_create_struct)(DLOOP_Count count,
 					   const int *blklen_array,
 					   const MPI_Aint *disp_array,
 					   const MPI_Datatype *oldtype_array,
 					   DLOOP_Dataloop **dlp_p,
-					   int *dlsz_p,
+					   DLOOP_Size *dlsz_p,
 					   int *dldepth_p,
 					   int flag);
 int PREPEND_PREFIX(Dataloop_create_pairtype)(MPI_Datatype type,
 					     DLOOP_Dataloop **dlp_p,
-					     int *dlsz_p,
+					     DLOOP_Size *dlsz_p,
 					     int *dldepth_p,
 					     int flag);
 
@@ -81,7 +84,7 @@ int PREPEND_PREFIX(Type_convert_darray)(int size,
 					MPI_Datatype *newtype);
 
 DLOOP_Count PREPEND_PREFIX(Type_indexed_count_contig)(DLOOP_Count count,
-                                                      const int *blocklength_array,
+                                                      const DLOOP_Count *blocklength_array,
                                                       const void *displacement_array,
                                                       int dispinbytes,
                                                       DLOOP_Offset old_extent);
diff --git a/src/mpid/common/datatype/dataloop/dataloop_create_blockindexed.c b/src/mpid/common/datatype/dataloop/dataloop_create_blockindexed.c
index 76f20cc..9e9597b 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_create_blockindexed.c
+++ b/src/mpid/common/datatype/dataloop/dataloop_create_blockindexed.c
@@ -19,7 +19,7 @@ static void DLOOP_Type_blockindexed_array_copy(DLOOP_Count count,
    Dataloop_create_blockindexed - create blockindexed dataloop
 
    Arguments:
-+  int count
++  DLOOP_Count count
 .  void *displacement_array (array of either MPI_Aints or ints)
 .  int displacement_in_bytes (boolean)
 .  MPI_Datatype old_type
@@ -31,18 +31,19 @@ static void DLOOP_Type_blockindexed_array_copy(DLOOP_Count count,
 .N Errors
 .N Returns 0 on success, -1 on failure.
 @*/
-int PREPEND_PREFIX(Dataloop_create_blockindexed)(int icount,
-						 int iblklen,
+int PREPEND_PREFIX(Dataloop_create_blockindexed)(DLOOP_Count icount,
+						 DLOOP_Count iblklen,
 						 const void *disp_array,
 						 int dispinbytes,
 						 DLOOP_Type oldtype,
 						 DLOOP_Dataloop **dlp_p,
-						 int *dlsz_p,
+						 DLOOP_Size *dlsz_p,
 						 int *dldepth_p,
 						 int flag)
 {
     int err, is_builtin, is_vectorizable = 1;
-    int i, new_loop_sz, old_loop_depth;
+    int i, old_loop_depth;
+    DLOOP_Size new_loop_sz;
 
     DLOOP_Count contig_count, count, blklen;
     DLOOP_Offset old_extent, eff_disp0, eff_disp1, last_stride;
@@ -201,7 +202,7 @@ int PREPEND_PREFIX(Dataloop_create_blockindexed)(int icount,
     else
     {
 	DLOOP_Dataloop *old_loop_ptr = NULL;
-	int old_loop_sz = 0;
+	MPI_Aint old_loop_sz = 0;
 
 	DLOOP_Handle_get_loopptr_macro(oldtype, old_loop_ptr, flag);
 	DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
diff --git a/src/mpid/common/datatype/dataloop/dataloop_create_contig.c b/src/mpid/common/datatype/dataloop/dataloop_create_contig.c
index b72b9a2..290bf2a 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_create_contig.c
+++ b/src/mpid/common/datatype/dataloop/dataloop_create_contig.c
@@ -22,20 +22,21 @@
 .N Errors
 .N Returns 0 on success, -1 on failure.
 @*/
-int PREPEND_PREFIX(Dataloop_create_contiguous)(int icount,
+int PREPEND_PREFIX(Dataloop_create_contiguous)(DLOOP_Count icount,
 					       DLOOP_Type oldtype,
 					       DLOOP_Dataloop **dlp_p,
-					       int *dlsz_p,
+					       DLOOP_Size *dlsz_p,
 					       int *dldepth_p,
 					       int flag)
 {
     DLOOP_Count count;
     int is_builtin, apply_contig_coalescing = 0;
-    int new_loop_sz, new_loop_depth;
+    int new_loop_depth;
+    DLOOP_Size new_loop_sz;
 
     DLOOP_Dataloop *new_dlp;
 
-    count = (DLOOP_Count) icount; /* avoid subsequent casting */
+    count = icount;
 
     is_builtin = (DLOOP_Handle_hasloop_macro(oldtype)) ? 0 : 1;
 
@@ -103,7 +104,7 @@ int PREPEND_PREFIX(Dataloop_create_contiguous)(int icount,
     {
 	/* user-defined base type (oldtype) */
 	DLOOP_Dataloop *old_loop_ptr;
-	int old_loop_sz = 0;
+	MPI_Aint old_loop_sz = 0;
 
 	DLOOP_Handle_get_loopptr_macro(oldtype, old_loop_ptr, flag);
 	DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
diff --git a/src/mpid/common/datatype/dataloop/dataloop_create_indexed.c b/src/mpid/common/datatype/dataloop/dataloop_create_indexed.c
index 59fafc6..62dcf63 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_create_indexed.c
+++ b/src/mpid/common/datatype/dataloop/dataloop_create_indexed.c
@@ -11,7 +11,7 @@
 
 static void DLOOP_Type_indexed_array_copy(DLOOP_Count count,
 					  DLOOP_Count contig_count,
-					  const int *input_blocklength_array,
+					  const DLOOP_Size *input_blocklength_array,
 					  const void *input_displacement_array,
 					  DLOOP_Count *output_blocklength_array,
 					  DLOOP_Offset *out_disp_array,
@@ -23,7 +23,7 @@ static void DLOOP_Type_indexed_array_copy(DLOOP_Count count,
 
    Arguments:
 +  int icount
-.  int *iblocklength_array
+.  DLOOP_Size *iblocklength_array
 .  void *displacement_array (either ints or MPI_Aints)
 .  int dispinbytes
 .  MPI_Datatype oldtype
@@ -36,18 +36,20 @@ static void DLOOP_Type_indexed_array_copy(DLOOP_Count count,
 .N Returns 0 on success, -1 on error.
 @*/
 
-int PREPEND_PREFIX(Dataloop_create_indexed)(int icount,
-					    const int *blocklength_array,
+int PREPEND_PREFIX(Dataloop_create_indexed)(DLOOP_Count icount,
+					    const DLOOP_Size *blocklength_array,
 					    const void *displacement_array,
 					    int dispinbytes,
 					    MPI_Datatype oldtype,
 					    DLOOP_Dataloop **dlp_p,
-					    int *dlsz_p,
+					    DLOOP_Size *dlsz_p,
 					    int *dldepth_p,
 					    int flag)
 {
     int err, is_builtin;
-    int i, new_loop_sz, old_loop_depth, blksz;
+    int old_loop_depth;
+    MPI_Aint i;
+    DLOOP_Size new_loop_sz, blksz;
     DLOOP_Count first;
 
     DLOOP_Count old_type_count = 0, contig_count, count;
@@ -120,7 +122,7 @@ int PREPEND_PREFIX(Dataloop_create_indexed)(int icount,
 	((!dispinbytes && ((int *) displacement_array)[first] == 0) ||
 	 (dispinbytes && ((MPI_Aint *) displacement_array)[first] == 0)))
     {
-	err = PREPEND_PREFIX(Dataloop_create_contiguous)((int) old_type_count,
+	err = PREPEND_PREFIX(Dataloop_create_contiguous)(old_type_count,
 							 oldtype,
 							 dlp_p,
 							 dlsz_p,
@@ -143,7 +145,7 @@ int PREPEND_PREFIX(Dataloop_create_indexed)(int icount,
         else
             disp_arr_tmp = &(((const int *)displacement_array)[first]);
 	err = PREPEND_PREFIX(Dataloop_create_blockindexed)(1,
-							   (int) old_type_count,
+							   old_type_count,
 							   disp_arr_tmp,
 							   dispinbytes,
 							   oldtype,
@@ -228,7 +230,7 @@ int PREPEND_PREFIX(Dataloop_create_indexed)(int icount,
     else
     {
 	DLOOP_Dataloop *old_loop_ptr = NULL;
-	int old_loop_sz = 0;
+	MPI_Aint old_loop_sz = 0;
 
 	DLOOP_Handle_get_loopptr_macro(oldtype, old_loop_ptr, flag);
 	DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
@@ -299,7 +301,7 @@ int PREPEND_PREFIX(Dataloop_create_indexed)(int icount,
  */
 static void DLOOP_Type_indexed_array_copy(DLOOP_Count count,
 					  DLOOP_Count contig_count,
-					  const int *in_blklen_array,
+					  const DLOOP_Size *in_blklen_array,
 					  const void *in_disp_array,
 					  DLOOP_Count *out_blklen_array,
 					  DLOOP_Offset *out_disp_array,
@@ -384,7 +386,7 @@ static void DLOOP_Type_indexed_array_copy(DLOOP_Count count,
  * Extent passed in is for the original type.
  */
 DLOOP_Count PREPEND_PREFIX(Type_indexed_count_contig)(DLOOP_Count count,
-                                                      const int *blocklength_array,
+                                                      const DLOOP_Count *blocklength_array,
                                                       const void *displacement_array,
                                                       int dispinbytes,
                                                       DLOOP_Offset old_extent)
diff --git a/src/mpid/common/datatype/dataloop/dataloop_create_pairtype.c b/src/mpid/common/datatype/dataloop/dataloop_create_pairtype.c
index 81644a7..78ec694 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_create_pairtype.c
+++ b/src/mpid/common/datatype/dataloop/dataloop_create_pairtype.c
@@ -38,7 +38,7 @@
 @*/
 int PREPEND_PREFIX(Dataloop_create_pairtype)(MPI_Datatype type,
 					     DLOOP_Dataloop **dlp_p,
-					     int *dlsz_p,
+					     MPI_Aint *dlsz_p,
 					     int *dldepth_p,
 					     int flag)
 {
diff --git a/src/mpid/common/datatype/dataloop/dataloop_create_struct.c b/src/mpid/common/datatype/dataloop/dataloop_create_struct.c
index 3df6328..7d51b7b 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_create_struct.c
+++ b/src/mpid/common/datatype/dataloop/dataloop_create_struct.c
@@ -12,30 +12,30 @@
 #endif
 
 static int DLOOP_Dataloop_create_struct_memory_error(void);
-static int DLOOP_Dataloop_create_unique_type_struct(int count,
+static int DLOOP_Dataloop_create_unique_type_struct(DLOOP_Count count,
 						    const int *blklens,
 						    const MPI_Aint *disps,
 						    const DLOOP_Type *oldtypes,
 						    int type_pos,
 						    DLOOP_Dataloop **dlp_p,
-						    int *dlsz_p,
+						    MPI_Aint *dlsz_p,
 						    int *dldepth_p,
 						    int flag);
 static int DLOOP_Dataloop_create_basic_all_bytes_struct(
-	       int count,
+	       DLOOP_Count count,
 	       const int *blklens,
 	       const MPI_Aint *disps,
 	       const DLOOP_Type *oldtypes,
 	       DLOOP_Dataloop **dlp_p,
-	       int *dlsz_p,
+	       MPI_Aint *dlsz_p,
 	       int *dldepth_p,
 	       int flag);
-static int DLOOP_Dataloop_create_flattened_struct(int count,
+static int DLOOP_Dataloop_create_flattened_struct(DLOOP_Count count,
 						  const int *blklens,
 						  const MPI_Aint *disps,
 						  const DLOOP_Type *oldtypes,
 						  DLOOP_Dataloop **dlp_p,
-						  int *dlsz_p,
+						  MPI_Aint *dlsz_p,
 						  int *dldepth_p,
 						  int flag);
 
@@ -64,12 +64,12 @@ Output Parameters:
   or corrected in this code at this time.
 
 @*/
-int PREPEND_PREFIX(Dataloop_create_struct)(int count,
+int PREPEND_PREFIX(Dataloop_create_struct)(DLOOP_Count count,
 					   const int *blklens,
 					   const MPI_Aint *disps,
 					   const DLOOP_Type *oldtypes,
 					   DLOOP_Dataloop **dlp_p,
-					   int *dlsz_p,
+					   MPI_Aint *dlsz_p,
 					   int *dldepth_p,
 					   int flag)
 {
@@ -79,8 +79,9 @@ int PREPEND_PREFIX(Dataloop_create_struct)(int count,
 	first_derived = MPI_DATATYPE_NULL;
 
     /* variables used in general case only */
-    int loop_idx, new_loop_sz, new_loop_depth;
-    int old_loop_sz = 0, old_loop_depth = 0;
+    int loop_idx, new_loop_depth;
+    int old_loop_depth = 0;
+    MPI_Aint new_loop_sz, old_loop_sz = 0;
 
     DLOOP_Dataloop *new_dlp, *curpos;
 
@@ -259,7 +260,8 @@ int PREPEND_PREFIX(Dataloop_create_struct)(int count,
 
 	if (DLOOP_Handle_hasloop_macro(oldtypes[i]))
 	{
-	    int tmp_loop_depth, tmp_loop_sz;
+	    int tmp_loop_depth;
+	    MPI_Aint tmp_loop_sz;
 
 	    DLOOP_Handle_get_loopdepth_macro(oldtypes[i], tmp_loop_depth, flag);
 	    DLOOP_Handle_get_loopsize_macro(oldtypes[i], tmp_loop_sz, flag);
@@ -326,7 +328,8 @@ int PREPEND_PREFIX(Dataloop_create_struct)(int count,
 	if (is_builtin)
 	{
 	    DLOOP_Dataloop *dummy_dlp;
-	    int dummy_sz, dummy_depth;
+	    int dummy_depth;
+	    MPI_Aint dummy_sz;
 
 	    /* LBs and UBs already taken care of -- skip them */
 	    if (oldtypes[i] == MPI_LB || oldtypes[i] == MPI_UB)
@@ -405,24 +408,25 @@ static int DLOOP_Dataloop_create_struct_memory_error(void)
 }
 /* --END ERROR HANDLING-- */
 
-static int DLOOP_Dataloop_create_unique_type_struct(int count,
+static int DLOOP_Dataloop_create_unique_type_struct(DLOOP_Count count,
 						    const int *blklens,
 						    const MPI_Aint *disps,
 						    const DLOOP_Type *oldtypes,
 						    int type_pos,
 						    DLOOP_Dataloop **dlp_p,
-						    int *dlsz_p,
+						    MPI_Aint *dlsz_p,
 						    int *dldepth_p,
 						    int flag)
 {
     /* the same type used more than once in the array; type_pos
      * indexes to the first of these.
      */
-    int i, err, *tmp_blklens, cur_pos = 0;
+    int i, err, cur_pos = 0;
+    DLOOP_Size *tmp_blklens;
     DLOOP_Offset *tmp_disps;
 
     /* count is an upper bound on number of type instances */
-    tmp_blklens = (int *) DLOOP_Malloc(count * sizeof(int));
+    tmp_blklens = (DLOOP_Size *) DLOOP_Malloc(count * sizeof(DLOOP_Size));
     /* --BEGIN ERROR HANDLING-- */
     if (!tmp_blklens) {
 	/* TODO: ??? */
@@ -468,21 +472,21 @@ static int DLOOP_Dataloop_create_unique_type_struct(int count,
 }
 
 static int DLOOP_Dataloop_create_basic_all_bytes_struct(
-	       int count,
+	       DLOOP_Count count,
 	       const int *blklens,
 	       const MPI_Aint *disps,
 	       const DLOOP_Type *oldtypes,
 	       DLOOP_Dataloop **dlp_p,
-	       int *dlsz_p,
+	       MPI_Aint *dlsz_p,
 	       int *dldepth_p,
 	       int flag)
 {
     int i, err, cur_pos = 0;
-    int *tmp_blklens;
+    DLOOP_Size *tmp_blklens;
     MPI_Aint *tmp_disps;
 
     /* count is an upper bound on number of type instances */
-    tmp_blklens = (int *) DLOOP_Malloc(count * sizeof(int));
+    tmp_blklens = (DLOOP_Size *) DLOOP_Malloc(count * sizeof(DLOOP_Size));
 
     /* --BEGIN ERROR HANDLING-- */
     if (!tmp_blklens)
@@ -529,23 +533,25 @@ static int DLOOP_Dataloop_create_basic_all_bytes_struct(
     return err;
 }
 
-static int DLOOP_Dataloop_create_flattened_struct(int count,
+static int DLOOP_Dataloop_create_flattened_struct(DLOOP_Count count,
 						  const int *blklens,
 						  const MPI_Aint *disps,
 						  const DLOOP_Type *oldtypes,
 						  DLOOP_Dataloop **dlp_p,
-						  int *dlsz_p,
+						  MPI_Aint *dlsz_p,
 						  int *dldepth_p,
 						  int flag)
 {
     /* arbitrary types, convert to bytes and use indexed */
-    int i, err, *tmp_blklens, nr_blks = 0;
+    int i, err, nr_blks = 0;
+    DLOOP_Size *tmp_blklens;
     MPI_Aint *tmp_disps; /* since we're calling another fn that takes
 			    this type as an input parameter */
     DLOOP_Offset bytes;
     DLOOP_Segment *segp;
 
-    int first_ind, last_ind;
+    int first_ind;
+    DLOOP_Size last_ind;
 
     segp = PREPEND_PREFIX(Segment_alloc)();
     /* --BEGIN ERROR HANDLING-- */
@@ -615,7 +621,7 @@ static int DLOOP_Dataloop_create_flattened_struct(int count,
 
     nr_blks += 2; /* safety measure */
 
-    tmp_blklens = (int *) DLOOP_Malloc(nr_blks * sizeof(int));
+    tmp_blklens = (DLOOP_Size *) DLOOP_Malloc(nr_blks * sizeof(DLOOP_Size));
     /* --BEGIN ERROR HANDLING-- */
     if (!tmp_blklens) {
 	PREPEND_PREFIX(Segment_free)(segp);
diff --git a/src/mpid/common/datatype/dataloop/dataloop_create_vector.c b/src/mpid/common/datatype/dataloop/dataloop_create_vector.c
index fc0e069..9f86daf 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_create_vector.c
+++ b/src/mpid/common/datatype/dataloop/dataloop_create_vector.c
@@ -24,18 +24,19 @@
    Returns 0 on success, -1 on failure.
 
 @*/
-int PREPEND_PREFIX(Dataloop_create_vector)(int icount,
-					   int iblocklength,
+int PREPEND_PREFIX(Dataloop_create_vector)(DLOOP_Count icount,
+					   DLOOP_Size iblocklength,
 					   MPI_Aint astride,
 					   int strideinbytes,
 					   DLOOP_Type oldtype,
 					   DLOOP_Dataloop **dlp_p,
-					   int *dlsz_p,
+					   DLOOP_Size *dlsz_p,
 					   int *dldepth_p,
 					   int flag)
 {
     int err, is_builtin;
-    int new_loop_sz, new_loop_depth;
+    DLOOP_Size new_loop_sz;
+    int new_loop_depth;
 
     DLOOP_Count count, blocklength;
     DLOOP_Offset stride;
@@ -81,7 +82,8 @@ int PREPEND_PREFIX(Dataloop_create_vector)(int icount,
 	new_loop_depth = 1;
     }
     else {
-	int old_loop_sz = 0, old_loop_depth = 0;
+	MPI_Aint old_loop_sz = 0;
+	int old_loop_depth = 0;
 
 	DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
 	DLOOP_Handle_get_loopdepth_macro(oldtype, old_loop_depth, flag);
@@ -129,7 +131,7 @@ int PREPEND_PREFIX(Dataloop_create_vector)(int icount,
     }
     else /* user-defined base type (oldtype) */ {
 	DLOOP_Dataloop *old_loop_ptr;
-	int old_loop_sz = 0;
+	MPI_Aint old_loop_sz = 0;
 
 	DLOOP_Handle_get_loopptr_macro(oldtype, old_loop_ptr, flag);
 	DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
diff --git a/src/mpid/common/datatype/dataloop/dataloop_parts.h b/src/mpid/common/datatype/dataloop/dataloop_parts.h
index 6da3517..b4bd636 100644
--- a/src/mpid/common/datatype/dataloop/dataloop_parts.h
+++ b/src/mpid/common/datatype/dataloop/dataloop_parts.h
@@ -33,6 +33,10 @@
 #error "DLOOP_Type must be defined before dataloop_parts.h is included."
 #endif
 
+#ifndef DLOOP_Size
+#error "DLOOP_Size must be defined before dataloop_parts.h is included."
+#endif
+
 /* Redefine all of the internal structures in terms of the prefix */
 #define DLOOP_Dataloop              PREPEND_PREFIX(Dataloop)
 #define DLOOP_Dataloop_contig       PREPEND_PREFIX(Dataloop_contig)
@@ -317,7 +321,7 @@ typedef struct DLOOP_Segment {
 /* Dataloop functions (dataloop.c) */
 void PREPEND_PREFIX(Dataloop_copy)(void *dest,
 				   void *src,
-				   int size);
+				   DLOOP_Size size);
 void PREPEND_PREFIX(Dataloop_update)(DLOOP_Dataloop *dataloop,
 				     DLOOP_Offset ptrdiff);
 DLOOP_Offset
@@ -329,21 +333,21 @@ void PREPEND_PREFIX(Dataloop_print)(DLOOP_Dataloop *dataloop,
 void PREPEND_PREFIX(Dataloop_alloc)(int kind,
 				    DLOOP_Count count,
 				    DLOOP_Dataloop **new_loop_p,
-				    int *new_loop_sz_p);
+				    DLOOP_Size *new_loop_sz_p);
 void PREPEND_PREFIX(Dataloop_alloc_and_copy)(int kind,
 					     DLOOP_Count count,
 					     DLOOP_Dataloop *old_loop,
-					     int old_loop_sz,
+					     DLOOP_Size old_loop_sz,
 					     DLOOP_Dataloop **new_loop_p,
-					     int *new_loop_sz_p);
+					     DLOOP_Size *new_loop_sz_p);
 void PREPEND_PREFIX(Dataloop_struct_alloc)(DLOOP_Count count,
-					   int old_loop_sz,
+					   DLOOP_Size old_loop_sz,
 					   int basic_ct,
 					   DLOOP_Dataloop **old_loop_p,
 					   DLOOP_Dataloop **new_loop_p,
-					   int *new_loop_sz_p);
+					   DLOOP_Size *new_loop_sz_p);
 void PREPEND_PREFIX(Dataloop_dup)(DLOOP_Dataloop *old_loop,
-				  int old_loop_sz,
+				  DLOOP_Size old_loop_sz,
 				  DLOOP_Dataloop **new_loop_p);
 
 void PREPEND_PREFIX(Dataloop_free)(DLOOP_Dataloop **dataloop);
@@ -403,9 +407,9 @@ void PREPEND_PREFIX(Segment_count_contig_blocks)(DLOOP_Segment *segp,
 void PREPEND_PREFIX(Segment_mpi_flatten)(DLOOP_Segment *segp,
 					 DLOOP_Offset first,
 					 DLOOP_Offset *lastp,
-					 int *blklens,
+					 DLOOP_Size *blklens,
 					 MPI_Aint *disps,
-					 int *lengthp);
+					 DLOOP_Size *lengthp);
 
 #define DLOOP_M2M_TO_USERBUF   0
 #define DLOOP_M2M_FROM_USERBUF 1
diff --git a/src/mpid/common/datatype/dataloop/segment.c b/src/mpid/common/datatype/dataloop/segment.c
index 87c0d8a..5408135 100644
--- a/src/mpid/common/datatype/dataloop/segment.c
+++ b/src/mpid/common/datatype/dataloop/segment.c
@@ -593,7 +593,7 @@ void PREPEND_PREFIX(Segment_manipulate)(struct DLOOP_Segment *segp,
 		return;
 	    }
 	    else /* myblocks >= cur_elmp->curblock */ {
-		int count_index = 0;
+		MPI_Aint count_index = 0;
 
 		/* this assumes we're either *just* processing the last parts
 		 * of the current block, or we're processing as many blocks as
@@ -736,7 +736,7 @@ void PREPEND_PREFIX(Segment_manipulate)(struct DLOOP_Segment *segp,
 	}
 	else /* push the stackelm */ {
 	    DLOOP_Dataloop_stackelm *next_elmp;
-	    int count_index, block_index;
+	    MPI_Aint count_index, block_index;
 
 	    count_index = cur_elmp->orig_count - cur_elmp->curcount;
 	    block_index = cur_elmp->orig_block - cur_elmp->curblock;
diff --git a/src/mpid/common/datatype/dataloop/segment_flatten.c b/src/mpid/common/datatype/dataloop/segment_flatten.c
index c8ea1ba..0a035ec 100644
--- a/src/mpid/common/datatype/dataloop/segment_flatten.c
+++ b/src/mpid/common/datatype/dataloop/segment_flatten.c
@@ -45,9 +45,10 @@ static int DLOOP_Leaf_index_mpi_flatten(DLOOP_Offset *blocks_p,
 					void *v_paramp);
 
 struct PREPEND_PREFIX(mpi_flatten_params) {
-    int       index, length;
+    int       index;
+    MPI_Aint  length;
     MPI_Aint  last_end;
-    int      *blklens;
+    MPI_Aint  *blklens;
     MPI_Aint *disps;
 };
 
@@ -72,9 +73,9 @@ struct PREPEND_PREFIX(mpi_flatten_params) {
 void PREPEND_PREFIX(Segment_mpi_flatten)(DLOOP_Segment *segp,
 					 DLOOP_Offset first,
 					 DLOOP_Offset *lastp,
-					 int *blklens,
+					 DLOOP_Size *blklens,
 					 MPI_Aint *disps,
-					 int *lengthp)
+					 DLOOP_Size *lengthp)
 {
     struct PREPEND_PREFIX(mpi_flatten_params) params;
 
@@ -111,7 +112,8 @@ static int DLOOP_Leaf_contig_mpi_flatten(DLOOP_Offset *blocks_p,
 					 void *bufp,
 					 void *v_paramp)
 {
-    int last_idx, size;
+    int last_idx;
+    DLOOP_Offset size;
     DLOOP_Offset el_size;
     char *last_end = NULL;
     struct PREPEND_PREFIX(mpi_flatten_params) *paramp = v_paramp;
@@ -186,24 +188,25 @@ static int DLOOP_Leaf_vector_mpi_flatten(DLOOP_Offset *blocks_p,
 					 void *bufp, /* start of buffer */
 					 void *v_paramp)
 {
-    int i, size, blocks_left;
+    int i;
+    DLOOP_Size size, blocks_left;
     DLOOP_Offset el_size;
     struct PREPEND_PREFIX(mpi_flatten_params) *paramp = v_paramp;
 
     DLOOP_Handle_get_size_macro(el_type, el_size);
-    blocks_left = (int)*blocks_p;
+    blocks_left = *blocks_p;
 
     for (i=0; i < count && blocks_left > 0; i++) {
 	int last_idx;
 	char *last_end = NULL;
 
 	if (blocks_left > blksz) {
-	    size = blksz * (int) el_size;
+	    size = blksz * el_size;
 	    blocks_left -= blksz;
 	}
 	else {
 	    /* last pass */
-	    size = blocks_left * (int) el_size;
+	    size = blocks_left * el_size;
 	    blocks_left = 0;
 	}
 
@@ -231,7 +234,7 @@ static int DLOOP_Leaf_vector_mpi_flatten(DLOOP_Offset *blocks_p,
 	    /* we have used up all our entries, and this one doesn't fit on
 	     * the end of the last one.
 	     */
-	    *blocks_p -= (blocks_left + (size / (int) el_size));
+	    *blocks_p -= (blocks_left + (size / el_size));
 #ifdef MPID_SP_VERBOSE
 	    MPIU_dbg_printf("\t[vector to vec exiting (1): next ind = %d, " DLOOP_OFFSET_FMT_DEC_SPEC " blocks processed.\n",
 			    paramp->u.pack_vector.index,
@@ -280,7 +283,8 @@ static int DLOOP_Leaf_blkidx_mpi_flatten(DLOOP_Offset *blocks_p,
 					 void *bufp,
 					 void *v_paramp)
 {
-    int i, size, blocks_left;
+    int i;
+    DLOOP_Size blocks_left, size;
     DLOOP_Offset el_size;
     struct PREPEND_PREFIX(mpi_flatten_params) *paramp = v_paramp;
 
@@ -292,12 +296,12 @@ static int DLOOP_Leaf_blkidx_mpi_flatten(DLOOP_Offset *blocks_p,
 	char *last_end = NULL;
 
 	if (blocks_left > blksz) {
-	    size = blksz * (int) el_size;
+	    size = blksz * el_size;
 	    blocks_left -= blksz;
 	}
 	else {
 	    /* last pass */
-	    size = blocks_left * (int) el_size;
+	    size = blocks_left * el_size;
 	    blocks_left = 0;
 	}
 
@@ -362,7 +366,8 @@ static int DLOOP_Leaf_index_mpi_flatten(DLOOP_Offset *blocks_p,
 					void *bufp,
 					void *v_paramp)
 {
-    int i, size, blocks_left;
+    int i;
+    DLOOP_Size size, blocks_left;
     DLOOP_Offset el_size;
     struct PREPEND_PREFIX(mpi_flatten_params) *paramp = v_paramp;
 
@@ -374,12 +379,12 @@ static int DLOOP_Leaf_index_mpi_flatten(DLOOP_Offset *blocks_p,
 	char *last_end = NULL;
 
 	if (blocks_left > blockarray[i]) {
-	    size = blockarray[i] * (int) el_size;
+	    size = blockarray[i] * el_size;
 	    blocks_left -= blockarray[i];
 	}
 	else {
 	    /* last pass */
-	    size = blocks_left * (int) el_size;
+	    size = blocks_left *  el_size;
 	    blocks_left = 0;
 	}
 
@@ -407,7 +412,7 @@ static int DLOOP_Leaf_index_mpi_flatten(DLOOP_Offset *blocks_p,
 	    /* we have used up all our entries, and this one doesn't fit on
 	     * the end of the last one.
 	     */
-	    *blocks_p -= (blocks_left + (size / (int) el_size));
+	    *blocks_p -= (blocks_left + (size /  el_size));
 	    return 1;
 	}
         else if (last_idx >= 0 && (last_end == ((char *) bufp + rel_off + offsetarray[i])))
diff --git a/src/mpid/common/datatype/mpid_dataloop.h b/src/mpid/common/datatype/mpid_dataloop.h
index 7cf0290..7469792 100644
--- a/src/mpid/common/datatype/mpid_dataloop.h
+++ b/src/mpid/common/datatype/mpid_dataloop.h
@@ -19,13 +19,14 @@
  * instance:
  */
 #define DLOOP_Offset     MPI_Aint
-#define DLOOP_Count      int
+#define DLOOP_Count      MPI_Aint
 #define DLOOP_Handle     MPI_Datatype
 #define DLOOP_Type       MPI_Datatype
 #define DLOOP_Buffer     void *
 #define DLOOP_VECTOR     MPID_IOV
 #define DLOOP_VECTOR_LEN MPID_IOV_LEN
 #define DLOOP_VECTOR_BUF MPID_IOV_BUF
+#define DLOOP_Size       MPI_Aint
 
 /* The following accessor functions must also be defined:
  *
diff --git a/src/mpid/common/datatype/mpid_datatype.h b/src/mpid/common/datatype/mpid_datatype.h
index 84ad551..9f1e51a 100644
--- a/src/mpid/common/datatype/mpid_datatype.h
+++ b/src/mpid/common/datatype/mpid_datatype.h
@@ -358,11 +358,12 @@ typedef struct MPID_Datatype {
     MPIU_OBJECT_HEADER; /* adds handle and ref_count fields */
 
     /* basic parameters for datatype, accessible via MPI calls */
-    MPI_Aint size;
+    MPI_Aint size;   /* MPI_Count could be 128 bits, so use MPI_Aint */
     MPI_Aint extent, ub, lb, true_ub, true_lb;
 
     /* chars affecting subsequent datatype processing and creation */
-    int alignsize, has_sticky_ub, has_sticky_lb;
+    MPI_Aint alignsize;
+    int has_sticky_ub, has_sticky_lb;
     int is_permanent; /* non-zero if datatype is a predefined type */
     int is_committed;
 
@@ -371,7 +372,8 @@ typedef struct MPID_Datatype {
      * if type is composed of more than one element type, then
      * eltype == MPI_DATATYPE_NULL and element_size == -1
      */
-    int      eltype, n_elements;
+    int      eltype;
+    MPI_Aint n_elements;
     MPI_Aint element_size;
 
     /* information on contiguity of type, for processing shortcuts.
@@ -384,7 +386,7 @@ typedef struct MPID_Datatype {
      * It is not trivial to calculate the *real* number of contig 
      * blocks in the case where old datatype is non-contiguous
      */
-    int max_contig_blocks;
+    MPI_Aint max_contig_blocks;
 
     /* pointer to contents and envelope data for the datatype */
     MPID_Datatype_contents *contents;
@@ -393,11 +395,11 @@ typedef struct MPID_Datatype {
      * and a depth used to verify that we can process it (limited stack depth
      */
     struct MPID_Dataloop *dataloop; /* might be optimized for homogenous */
-    int                   dataloop_size;
+    MPI_Aint              dataloop_size;
     int                   dataloop_depth;
 #if defined(MPID_HAS_HETERO) || 1
     struct MPID_Dataloop *hetero_dloop; /* heterogeneous dataloop */
-    int                   hetero_dloop_size;
+    MPI_Aint              hetero_dloop_size;
     int                   hetero_dloop_depth;
 #endif /* MPID_HAS_HETERO */
     /* MPI-2 attributes and name */
@@ -623,30 +625,30 @@ void MPIDI_Datatype_printf(MPI_Datatype type,
 /* Dataloop functions */
 void MPID_Dataloop_copy(void *dest,
 			void *src,
-			int size);
+			MPI_Aint size);
 
 void MPID_Dataloop_print(struct MPID_Dataloop *dataloop,
 			 int depth);
 
 void MPID_Dataloop_alloc(int kind,
-			 int count,
+			 MPI_Aint count,
 			 DLOOP_Dataloop **new_loop_p,
-			 int *new_loop_sz_p);
+			 MPI_Aint *new_loop_sz_p);
 
 void MPID_Dataloop_alloc_and_copy(int kind,
-				  int count,
+				  MPI_Aint count,
 				  struct DLOOP_Dataloop *old_loop,
-				  int old_loop_sz,
+				  MPI_Aint old_loop_sz,
 				  struct DLOOP_Dataloop **new_loop_p,
-				  int *new_loop_sz_p);
-void MPID_Dataloop_struct_alloc(int count,
-				int old_loop_sz,
+				  MPI_Aint *new_loop_sz_p);
+void MPID_Dataloop_struct_alloc(MPI_Aint count,
+				MPI_Aint old_loop_sz,
 				int basic_ct,
 				DLOOP_Dataloop **old_loop_p,
 				DLOOP_Dataloop **new_loop_p,
-				int *new_loop_sz_p);
+				MPI_Aint *new_loop_sz_p);
 void MPID_Dataloop_dup(DLOOP_Dataloop *old_loop,
-		       int old_loop_sz,
+		       MPI_Aint old_loop_sz,
 		       DLOOP_Dataloop **new_loop_p);
 void MPID_Dataloop_free(struct MPID_Dataloop **dataloop);
 
@@ -667,7 +669,7 @@ void MPID_Segment_flatten(struct DLOOP_Segment *segp,
 			  DLOOP_Offset first,
 			  DLOOP_Offset *lastp,
 			  DLOOP_Offset *offp,
-			  int *sizep,
+			  DLOOP_Size *sizep,
 			  DLOOP_Offset *lengthp);
 
 /* misc */
@@ -693,12 +695,12 @@ void MPID_Datatype_free(struct MPID_Datatype *ptr);
 void MPID_Dataloop_update(struct DLOOP_Dataloop *dataloop,
 			  MPI_Aint ptrdiff);
 
-int MPIR_Type_get_contig_blocks(MPI_Datatype type,
-				int *nr_blocks_p);
+MPI_Count MPIR_Type_get_contig_blocks(MPI_Datatype type,
+				MPI_Count *nr_blocks_p);
 
 int MPIR_Type_flatten(MPI_Datatype type,
 		      MPI_Aint *off_array,
-		      int *size_array,
+		      DLOOP_Size *size_array,
 		      MPI_Aint *array_len_p);
 
 void MPID_Segment_pack_external32(struct DLOOP_Segment *segp,
diff --git a/src/mpid/common/datatype/mpid_segment.c b/src/mpid/common/datatype/mpid_segment.c
index 3cf7ce4..f52a5eb 100644
--- a/src/mpid/common/datatype/mpid_segment.c
+++ b/src/mpid/common/datatype/mpid_segment.c
@@ -35,9 +35,9 @@ struct MPID_Segment_piece_params {
 	} pack_vector;
 	struct {
 	    int64_t *offp;
-	    int *sizep; /* see notes in Segment_flatten header */
+	    DLOOP_Size *sizep; /* see notes in Segment_flatten header */
 	    int index;
-	    int length;
+	    MPI_Aint length;
 	} flatten;
 	struct {
 	    char *last_loc;
@@ -54,8 +54,8 @@ struct MPID_Segment_piece_params {
 
 /* prototypes of internal functions */
 static int MPID_Segment_vector_pack_to_iov(DLOOP_Offset *blocks_p,
-				       int count,
-				       int blksz,
+				       DLOOP_Count count,
+				       DLOOP_Size blksz,
 				       DLOOP_Offset stride,
 				       DLOOP_Type el_type,
 				       DLOOP_Offset rel_off,
@@ -75,8 +75,8 @@ static int MPID_Segment_contig_flatten(DLOOP_Offset *blocks_p,
 				   void *v_paramp);
 
 static int MPID_Segment_vector_flatten(DLOOP_Offset *blocks_p,
-				   int count,
-				   int blksz,
+				   DLOOP_Count count,
+				   DLOOP_Size blksz,
 				   DLOOP_Offset stride,
 				   DLOOP_Type el_type,
 				   DLOOP_Offset rel_off, /* offset into buffer */
@@ -173,7 +173,7 @@ void MPID_Segment_flatten(struct DLOOP_Segment *segp,
 		      DLOOP_Offset first,
 		      DLOOP_Offset *lastp,
 		      DLOOP_Offset *offp,
-		      int *sizep,
+		      DLOOP_Size *sizep,
 		      DLOOP_Offset *lengthp)
 {
 struct MPID_Segment_piece_params packvec_params;
@@ -292,8 +292,8 @@ static int MPID_Segment_contig_pack_to_iov(DLOOP_Offset *blocks_p,
  * of a whole block in a vector type.
  */
 static int MPID_Segment_vector_pack_to_iov(DLOOP_Offset *blocks_p,
-					   int count,
-					   int blksz,
+					   DLOOP_Count count,
+					   DLOOP_Size blksz,
 					   DLOOP_Offset stride,
 					   DLOOP_Type el_type,
 					   DLOOP_Offset rel_off, /* offset into buffer */
@@ -313,7 +313,9 @@ static int MPID_Segment_vector_pack_to_iov(DLOOP_Offset *blocks_p,
     MPIU_DBG_MSG_FMT(DATATYPE,VERBOSE,(MPIU_DBG_FDEST,
              "    vector to vec: do=" MPI_AINT_FMT_DEC_SPEC
              ", dp=%p"
-             ", len=%d, ind=%d, ct=%d, blksz=%d"
+             ", len=" MPI_AINT_FMT_DEC_SPEC
+	     ", ind=%d, ct=" MPI_AINT_FMT_DEC_SPEC
+	     ", blksz=" MPI_AINT_FMT_DEC_SPEC
              ", str=" MPI_AINT_FMT_DEC_SPEC
              ", blks=" MPI_AINT_FMT_DEC_SPEC,
 		    (MPI_Aint) rel_off,
@@ -465,8 +467,8 @@ static int MPID_Segment_contig_flatten(DLOOP_Offset *blocks_p,
  *   blocks_p.
  */
 static int MPID_Segment_vector_flatten(DLOOP_Offset *blocks_p,
-				       int count,
-				       int blksz,
+				       DLOOP_Count count,
+				       DLOOP_Size blksz,
 				       DLOOP_Offset stride,
 				       DLOOP_Type el_type,
 				       DLOOP_Offset rel_off, /* offset into buffer */
diff --git a/src/mpid/common/datatype/mpid_type_blockindexed.c b/src/mpid/common/datatype/mpid_type_blockindexed.c
index 47d4287..f90f81f 100644
--- a/src/mpid/common/datatype/mpid_type_blockindexed.c
+++ b/src/mpid/common/datatype/mpid_type_blockindexed.c
@@ -38,7 +38,8 @@ int MPID_Type_blockindexed(int count,
 			   MPI_Datatype *newtype)
 {
     int mpi_errno = MPI_SUCCESS, i;
-    int is_builtin, contig_count, old_is_contig;
+    int is_builtin, old_is_contig;
+    MPI_Aint contig_count;
     MPI_Aint el_sz;
     MPI_Datatype el_type;
     MPI_Aint old_lb, old_ub, old_extent, old_true_lb, old_true_ub;
diff --git a/src/mpid/common/datatype/mpid_type_contiguous.c b/src/mpid/common/datatype/mpid_type_contiguous.c
index 9efb34a..565eb72 100644
--- a/src/mpid/common/datatype/mpid_type_contiguous.c
+++ b/src/mpid/common/datatype/mpid_type_contiguous.c
@@ -30,7 +30,7 @@ int MPID_Type_contiguous(int count,
 {
     int mpi_errno = MPI_SUCCESS;
     int is_builtin;
-    int el_sz;
+    MPI_Aint el_sz;
     MPI_Datatype el_type;
     MPID_Datatype *new_dtp;
 
diff --git a/src/mpid/common/datatype/mpid_type_debug.c b/src/mpid/common/datatype/mpid_type_debug.c
index 8e895cf..fcece4b 100644
--- a/src/mpid/common/datatype/mpid_type_debug.c
+++ b/src/mpid/common/datatype/mpid_type_debug.c
@@ -234,7 +234,7 @@ void MPIDI_Datatype_printf(MPI_Datatype type,
 			   int header)
 {
     char *string;
-    int size;
+    MPI_Aint size;
     MPI_Aint extent, true_lb, true_ub, lb, ub, sticky_lb, sticky_ub;
 
     if (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN) {
@@ -457,8 +457,8 @@ void MPIDU_Datatype_debug(MPI_Datatype type,
     MPIU_Assert(dtp != NULL);
 
     MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
-      "# Size = %d, Extent = " MPI_AINT_FMT_DEC_SPEC ", LB = " MPI_AINT_FMT_DEC_SPEC "%s, UB = " MPI_AINT_FMT_DEC_SPEC "%s, Extent = " MPI_AINT_FMT_DEC_SPEC ", Element Size = " MPI_AINT_FMT_DEC_SPEC " (%s), %s",
-		    (int) dtp->size,
+      "# Size = " MPI_AINT_FMT_DEC_SPEC ", Extent = " MPI_AINT_FMT_DEC_SPEC ", LB = " MPI_AINT_FMT_DEC_SPEC "%s, UB = " MPI_AINT_FMT_DEC_SPEC "%s, Extent = " MPI_AINT_FMT_DEC_SPEC ", Element Size = " MPI_AINT_FMT_DEC_SPEC " (%s), %s",
+		    (MPI_Aint) dtp->size,
 		    (MPI_Aint) dtp->extent,
 		    (MPI_Aint) dtp->lb,
 		    (dtp->has_sticky_lb) ? "(sticky)" : "",
diff --git a/src/mpid/common/datatype/mpid_type_indexed.c b/src/mpid/common/datatype/mpid_type_indexed.c
index 0e3e259..f64acea 100644
--- a/src/mpid/common/datatype/mpid_type_indexed.c
+++ b/src/mpid/common/datatype/mpid_type_indexed.c
@@ -40,9 +40,9 @@ int MPID_Type_indexed(int count,
 {
     int mpi_errno = MPI_SUCCESS;
     int is_builtin, old_is_contig;
-    int i, contig_count;
-    int el_ct, old_ct;
-    MPI_Aint el_sz, old_sz;
+    int i;
+    MPI_Aint contig_count;
+    MPI_Aint el_sz, el_ct, old_ct, old_sz;
     MPI_Aint old_lb, old_ub, old_extent, old_true_lb, old_true_ub;
     MPI_Aint min_lb = 0, max_ub = 0, eff_disp;
     MPI_Datatype el_type;
@@ -110,7 +110,7 @@ int MPID_Type_indexed(int count,
 	new_dtp->has_sticky_ub = 0;
 	new_dtp->has_sticky_lb = 0;
 
-        MPIU_Assign_trunc(new_dtp->alignsize, el_sz, int);
+        MPIU_Assign_trunc(new_dtp->alignsize, el_sz, MPI_Aint);
 	new_dtp->element_size = el_sz;
 	new_dtp->eltype       = el_type;
 
@@ -216,8 +216,11 @@ int MPID_Type_indexed(int count,
     new_dtp->is_contig = 0;
     if(old_is_contig)
     {
+	MPI_Aint *blklens = MPIU_Malloc(count *sizeof(MPI_Aint));
+	for (i=0; i<count; i++)
+		blklens[i] = blocklength_array[i];
         contig_count = MPID_Type_indexed_count_contig(count,
-						  blocklength_array,
+						  blklens,
 						  displacement_array,
 						  dispinbytes,
 						  old_extent);
@@ -227,6 +230,7 @@ int MPID_Type_indexed(int count,
         {
             new_dtp->is_contig = 1;
         }
+	MPIU_Free(blklens);
     }
 
     *newtype = new_dtp->handle;
diff --git a/src/mpid/common/datatype/mpid_type_struct.c b/src/mpid/common/datatype/mpid_type_struct.c
index 8ba96c6..148958e 100644
--- a/src/mpid/common/datatype/mpid_type_struct.c
+++ b/src/mpid/common/datatype/mpid_type_struct.c
@@ -13,7 +13,7 @@
 #undef MPID_STRUCT_FLATTEN_DEBUG
 #undef MPID_STRUCT_DEBUG
 
-static int MPID_Type_struct_alignsize(int count,
+static MPI_Aint MPID_Type_struct_alignsize(int count,
 				      const MPI_Datatype *oldtype_array,
 				      const MPI_Aint *displacement_array);
 
@@ -39,11 +39,12 @@ static int MPID_Type_struct_alignsize(int count,
  * have different natural alignments).  Linux on X86, however, does not have
  * different rules for this case.
  */
-static int MPID_Type_struct_alignsize(int count,
+static MPI_Aint MPID_Type_struct_alignsize(int count,
 				      const MPI_Datatype *oldtype_array,
 				      const MPI_Aint *displacement_array)
 {
-    int i, max_alignsize = 0, tmp_alignsize, derived_alignsize = 0;
+    int i;
+    MPI_Aint max_alignsize = 0, tmp_alignsize, derived_alignsize = 0;
 
     for (i=0; i < count; i++)
     {
@@ -152,7 +153,7 @@ int MPID_Type_struct(int count,
     int found_sticky_lb = 0, found_sticky_ub = 0, found_true_lb = 0,
 	found_true_ub = 0, found_el_type = 0;
     MPI_Aint el_sz = 0;
-    int size = 0;
+    MPI_Aint size = 0;
     MPI_Datatype el_type = MPI_DATATYPE_NULL;
     MPI_Aint true_lb_disp = 0, true_ub_disp = 0, sticky_lb_disp = 0,
 	sticky_ub_disp = 0;
diff --git a/src/mpid/common/datatype/mpir_type_flatten.c b/src/mpid/common/datatype/mpir_type_flatten.c
index 66ae8fc..8e9b332 100644
--- a/src/mpid/common/datatype/mpir_type_flatten.c
+++ b/src/mpid/common/datatype/mpir_type_flatten.c
@@ -25,7 +25,7 @@ Output Parameters:
 
 int MPIR_Type_flatten(MPI_Datatype type,
 		      MPI_Aint *off_array,
-		      int *size_array,
+		      MPI_Aint *size_array,
 		      MPI_Aint *array_len_p)
 {
     int err;
diff --git a/src/mpid/common/datatype/mpir_type_get_contig_blocks.c b/src/mpid/common/datatype/mpir_type_get_contig_blocks.c
index d718ff1..6b3d9d6 100644
--- a/src/mpid/common/datatype/mpir_type_get_contig_blocks.c
+++ b/src/mpid/common/datatype/mpir_type_get_contig_blocks.c
@@ -23,8 +23,8 @@ Output Parameters:
   0 on success, -1 on failure.
 @*/
 
-int MPIR_Type_get_contig_blocks(MPI_Datatype type,
-				int *nr_blocks_p)
+MPI_Count MPIR_Type_get_contig_blocks(MPI_Datatype type,
+				MPI_Count *nr_blocks_p)
 {
     MPID_Datatype *datatype_ptr;
 

http://git.mpich.org/mpich.git/commitdiff/e527fa1dea458e32f97083d49e8689666e5bb363

commit e527fa1dea458e32f97083d49e8689666e5bb363
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Fri Jun 28 08:40:29 2013 -0500

    ROMIO: improve handling of large datatypes
    
    MPI-3 introduced MPI_Count and MPI_Type_size_x.  Use these new routines
    throughout ROMIO to support large datatypes.
    
    Still to do:
    - update other ADIO drivers
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpi/romio/adio/common/ad_coll_exch_new.c b/src/mpi/romio/adio/common/ad_coll_exch_new.c
index 10a441c..62c9282 100644
--- a/src/mpi/romio/adio/common/ad_coll_exch_new.c
+++ b/src/mpi/romio/adio/common/ad_coll_exch_new.c
@@ -43,7 +43,7 @@ void ADIOI_Print_flatlist_node(ADIOI_Flatlist_node *flatlist_node_p)
 	return;
     }
     fprintf(stderr, "print flatlist node count = %d (idx,blocklen)\n", 
-	    flatlist_node_p->count);
+	    (int)flatlist_node_p->count);
     for (i = 0; i < flatlist_node_p->count; i++)
     {
 	if (i % 5 == 0 && i != 0)
diff --git a/src/mpi/romio/adio/common/ad_read.c b/src/mpi/romio/adio/common/ad_read.c
index 1961b16..13bdb52 100644
--- a/src/mpi/romio/adio/common/ad_read.c
+++ b/src/mpi/romio/adio/common/ad_read.c
@@ -21,7 +21,7 @@ void ADIOI_GEN_ReadContig(ADIO_File fd, void *buf, int count,
 {
     off_t err_lseek = -1;
     ssize_t err = -1;
-    int datatype_size;
+    MPI_Count datatype_size;
     ADIO_Offset len, bytes_xfered=0;
     size_t rd_count;
     static char myname[] = "ADIOI_GEN_READCONTIG";
@@ -30,8 +30,8 @@ void ADIOI_GEN_ReadContig(ADIO_File fd, void *buf, int count,
 #ifdef AGGREGATION_PROFILE
     MPE_Log_event (5034, 0, NULL);
 #endif
-    MPI_Type_size(datatype, &datatype_size);
-    len = (ADIO_Offset)datatype_size * (ADIO_Offset)count;
+    MPI_Type_size_x(datatype, &datatype_size);
+    len = datatype_size * (ADIO_Offset)count;
 
     if (file_ptr_type == ADIO_INDIVIDUAL) {
 	offset = fd->fp_ind;
diff --git a/src/mpi/romio/adio/common/ad_read_coll.c b/src/mpi/romio/adio/common/ad_read_coll.c
index ec849ac..7d8c928 100644
--- a/src/mpi/romio/adio/common/ad_read_coll.c
+++ b/src/mpi/romio/adio/common/ad_read_coll.c
@@ -281,8 +281,8 @@ void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype
 			    ADIO_Offset *end_offset_ptr, int
 			   *contig_access_count_ptr)
 {
-    int filetype_size, etype_size;
-    unsigned buftype_size;
+    MPI_Count filetype_size, etype_size;
+    MPI_Count buftype_size;
     int i, j, k;
     ADIO_Offset i_offset;
     ADIO_Offset frd_size=0, old_frd_size=0;
@@ -306,10 +306,10 @@ void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype
 
     ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
 
-    MPI_Type_size(fd->filetype, &filetype_size);
+    MPI_Type_size_x(fd->filetype, &filetype_size);
     MPI_Type_extent(fd->filetype, &filetype_extent);
     MPI_Type_lb(fd->filetype, &filetype_lb);
-    MPI_Type_size(datatype, (int*)&buftype_size);
+    MPI_Type_size_x(datatype, &buftype_size);
     etype_size = fd->etype_size;
 
     if ( ! filetype_size ) {
@@ -359,7 +359,7 @@ void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype
 #ifdef RDCOLL_DEBUG 
         {
             int ii;
-            DBG_FPRINTF(stderr, "flattened %3d : ", flat_file->count );
+            DBG_FPRINTF(stderr, "flattened %3lld : ", flat_file->count );
             for (ii=0; ii<flat_file->count; ii++) {
                 DBG_FPRINTF(stderr, "%16qd:%-16qd", flat_file->indices[ii], flat_file->blocklens[ii] );
             }
diff --git a/src/mpi/romio/adio/common/ad_read_str.c b/src/mpi/romio/adio/common/ad_read_str.c
index 1491e96..99e32fd 100644
--- a/src/mpi/romio/adio/common/ad_read_str.c
+++ b/src/mpi/romio/adio/common/ad_read_str.c
@@ -55,7 +55,7 @@ void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
     int n_etypes_in_filetype;
     ADIO_Offset n_filetypes, etype_in_filetype, st_n_filetypes, size_in_filetype;
     ADIO_Offset abs_off_in_filetype=0, new_frd_size, frd_size=0, st_frd_size;
-    int filetype_size, etype_size, buftype_size, partial_read;
+    MPI_Count filetype_size, etype_size, buftype_size, partial_read;
     MPI_Aint filetype_extent, buftype_extent; 
     int buf_count, buftype_is_contig, filetype_is_contig;
     ADIO_Offset userbuf_off, req_len, sum;
@@ -85,7 +85,7 @@ void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
     ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
     ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
 
-    MPI_Type_size(fd->filetype, &filetype_size);
+    MPI_Type_size_x(fd->filetype, &filetype_size);
     if ( ! filetype_size ) {
 #ifdef HAVE_STATUS_SET_BYTES
 	MPIR_Status_set_bytes(status, datatype, 0);
@@ -95,7 +95,7 @@ void ADIOI_GEN_ReadStrided(ADIO_File fd, void *buf, int count,
     }
 
     MPI_Type_extent(fd->filetype, &filetype_extent);
-    MPI_Type_size(datatype, &buftype_size);
+    MPI_Type_size_x(datatype, &buftype_size);
     MPI_Type_extent(datatype, &buftype_extent);
     etype_size = fd->etype_size;
 
diff --git a/src/mpi/romio/adio/common/ad_set_view.c b/src/mpi/romio/adio/common/ad_set_view.c
index 71ed7b7..31aa6c6 100644
--- a/src/mpi/romio/adio/common/ad_set_view.c
+++ b/src/mpi/romio/adio/common/ad_set_view.c
@@ -54,7 +54,7 @@ void ADIO_Set_view(ADIO_File fd, ADIO_Offset disp, MPI_Datatype etype,
                to be all contiguous. */
 	}
 
-	MPI_Type_size(fd->etype, &(fd->etype_size));
+	MPI_Type_size_x(fd->etype, &(fd->etype_size));
 	fd->disp = disp;
 
         /* reset MPI-IO file pointer to point to the first byte that can
diff --git a/src/mpi/romio/adio/common/ad_write.c b/src/mpi/romio/adio/common/ad_write.c
index 6f01aff..05b470a 100644
--- a/src/mpi/romio/adio/common/ad_write.c
+++ b/src/mpi/romio/adio/common/ad_write.c
@@ -21,7 +21,7 @@ void ADIOI_GEN_WriteContig(ADIO_File fd, const void *buf, int count,
 {
     off_t err_lseek = -1;
     ssize_t err = -1;
-    int datatype_size;
+    MPI_Count datatype_size;
     ADIO_Offset len, bytes_xfered=0;
     size_t wr_count;
     static char myname[] = "ADIOI_GEN_WRITECONTIG";
@@ -31,7 +31,7 @@ void ADIOI_GEN_WriteContig(ADIO_File fd, const void *buf, int count,
     MPE_Log_event (5036, 0, NULL);
 #endif
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
     len = (ADIO_Offset)datatype_size * (ADIO_Offset)count;
 
     if (file_ptr_type == ADIO_INDIVIDUAL) {
diff --git a/src/mpi/romio/adio/common/ad_write_nolock.c b/src/mpi/romio/adio/common/ad_write_nolock.c
index c84be8e..47a6079 100644
--- a/src/mpi/romio/adio/common/ad_write_nolock.c
+++ b/src/mpi/romio/adio/common/ad_write_nolock.c
@@ -35,7 +35,7 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, const void *buf, int count,
     int n_etypes_in_filetype;
     ADIO_Offset n_filetypes, etype_in_filetype, size, sum;
     ADIO_Offset abs_off_in_filetype=0, size_in_filetype;
-    int filetype_size, etype_size, buftype_size;
+    MPI_Count filetype_size, etype_size, buftype_size;
     MPI_Aint filetype_extent, buftype_extent, indx;
     int buf_count, buftype_is_contig, filetype_is_contig;
     ADIO_Offset off, disp;
@@ -58,7 +58,7 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, const void *buf, int count,
     ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
     ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
 
-    MPI_Type_size(fd->filetype, &filetype_size);
+    MPI_Type_size_x(fd->filetype, &filetype_size);
     if ( ! filetype_size ) {
 #ifdef HAVE_STATUS_SET_BYTES
 	MPIR_Status_set_bytes(status, datatype, 0);
@@ -73,7 +73,7 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, const void *buf, int count,
 #endif
 
     MPI_Type_extent(fd->filetype, &filetype_extent);
-    MPI_Type_size(datatype, &buftype_size);
+    MPI_Type_size_x(datatype, &buftype_size);
     MPI_Type_extent(datatype, &buftype_extent);
     etype_size = fd->etype_size;
     
diff --git a/src/mpi/romio/adio/common/ad_write_str.c b/src/mpi/romio/adio/common/ad_write_str.c
index 5acc300..c095b34 100644
--- a/src/mpi/romio/adio/common/ad_write_str.c
+++ b/src/mpi/romio/adio/common/ad_write_str.c
@@ -122,13 +122,14 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, const void *buf, int count,
     int n_etypes_in_filetype;
     ADIO_Offset num, size, n_filetypes, etype_in_filetype, st_n_filetypes;
     ADIO_Offset abs_off_in_filetype=0;
-    int filetype_size, etype_size, buftype_size;
+    MPI_Count filetype_size, etype_size, buftype_size;
     MPI_Aint filetype_extent, buftype_extent; 
     int buf_count, buftype_is_contig, filetype_is_contig;
     ADIO_Offset userbuf_off;
     ADIO_Offset off, req_off, disp, end_offset=0, writebuf_off, start_off;
     char *writebuf;
-    unsigned bufsize, writebuf_len, max_bufsize, write_sz;
+    unsigned writebuf_len, max_bufsize, write_sz;
+    MPI_Aint bufsize;
     ADIO_Status status1;
     ADIO_Offset new_bwr_size, new_fwr_size, st_fwr_size, fwr_size=0, bwr_size, req_len;
     static char myname[] = "ADIOI_GEN_WriteStrided";
@@ -155,7 +156,7 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, const void *buf, int count,
     ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
     ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
 
-    MPI_Type_size(fd->filetype, &filetype_size);
+    MPI_Type_size_x(fd->filetype, &filetype_size);
     if ( ! filetype_size ) {
 #ifdef HAVE_STATUS_SET_BYTES
 	MPIR_Status_set_bytes(status, datatype, 0);
@@ -165,11 +166,11 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, const void *buf, int count,
     }
 
     MPI_Type_extent(fd->filetype, &filetype_extent);
-    MPI_Type_size(datatype, &buftype_size);
+    MPI_Type_size_x(datatype, &buftype_size);
     MPI_Type_extent(datatype, &buftype_extent);
     etype_size = fd->etype_size;
 
-    ADIOI_Assert((buftype_size * count) == ((ADIO_Offset)(unsigned)buftype_size * (ADIO_Offset)count));
+    ADIOI_Assert((buftype_size * count) == ((ADIO_Offset)buftype_size * (ADIO_Offset)count));
     bufsize = buftype_size * count;
 
 /* get max_bufsize from the info object. */
@@ -285,6 +286,10 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, const void *buf, int count,
 	/* this could happen, for example, with subarray types that are
 	 * actually fairly contiguous */
         if (buftype_is_contig && bufsize <= fwr_size) {
+	    /* though MPI api has an integer 'count' parameter, derived
+	     * datatypes might describe more bytes than can fit into an integer.
+	     * Other WriteContig calls in this path are operating on data
+	     * sieving buffer */
             ADIO_WriteContig(fd, buf, bufsize, MPI_BYTE, ADIO_EXPLICIT_OFFSET,
                              offset, status, error_code);
 
@@ -475,6 +480,7 @@ void ADIOI_GEN_WriteStrided(ADIO_File fd, const void *buf, int count,
     fd->fp_sys_posn = -1;   /* set it to null. */
 
 #ifdef HAVE_STATUS_SET_BYTES
+    /* datatypes returning negagive values, probably related to tt 1893 */
     MPIR_Status_set_bytes(status, datatype, bufsize);
 /* This is a temporary way of filling in status. The right way is to 
    keep track of how much data was actually written by ADIOI_BUFFERED_WRITE. */
diff --git a/src/mpi/romio/adio/common/ad_write_str_naive.c b/src/mpi/romio/adio/common/ad_write_str_naive.c
index 4fb4b35..c37e3a1 100644
--- a/src/mpi/romio/adio/common/ad_write_str_naive.c
+++ b/src/mpi/romio/adio/common/ad_write_str_naive.c
@@ -23,7 +23,7 @@ void ADIOI_GEN_WriteStrided_naive(ADIO_File fd, const void *buf, int count,
     int n_etypes_in_filetype;
     ADIO_Offset size, n_filetypes, etype_in_filetype;
     ADIO_Offset abs_off_in_filetype=0, req_len;
-    int filetype_size, etype_size, buftype_size;
+    MPI_Count filetype_size, etype_size, buftype_size;
     MPI_Aint filetype_extent, buftype_extent; 
     int buf_count, buftype_is_contig, filetype_is_contig;
     ADIO_Offset userbuf_off;
@@ -35,7 +35,7 @@ void ADIOI_GEN_WriteStrided_naive(ADIO_File fd, const void *buf, int count,
     ADIOI_Datatype_iscontig(buftype, &buftype_is_contig);
     ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
 
-    MPI_Type_size(fd->filetype, &filetype_size);
+    MPI_Type_size_x(fd->filetype, &filetype_size);
     if ( ! filetype_size ) {
 #ifdef HAVE_STATUS_SET_BYTES
 	MPIR_Status_set_bytes(status, buftype, 0);
@@ -45,7 +45,7 @@ void ADIOI_GEN_WriteStrided_naive(ADIO_File fd, const void *buf, int count,
     }
 
     MPI_Type_extent(fd->filetype, &filetype_extent);
-    MPI_Type_size(buftype, &buftype_size);
+    MPI_Type_size_x(buftype, &buftype_size);
     MPI_Type_extent(buftype, &buftype_extent);
     etype_size = fd->etype_size;
 
diff --git a/src/mpi/romio/adio/common/byte_offset.c b/src/mpi/romio/adio/common/byte_offset.c
index df16e2e..df0a240 100644
--- a/src/mpi/romio/adio/common/byte_offset.c
+++ b/src/mpi/romio/adio/common/byte_offset.c
@@ -16,7 +16,7 @@ void ADIOI_Get_byte_offset(ADIO_File fd, ADIO_Offset offset, ADIO_Offset *disp)
     ADIOI_Flatlist_node *flat_file;
     int i;
     ADIO_Offset n_filetypes, etype_in_filetype, sum, abs_off_in_filetype=0, size_in_filetype;
-    unsigned n_etypes_in_filetype, filetype_size, etype_size;
+    MPI_Count n_etypes_in_filetype, filetype_size, etype_size;
     int filetype_is_contig;
     MPI_Aint filetype_extent;
 
@@ -29,7 +29,7 @@ void ADIOI_Get_byte_offset(ADIO_File fd, ADIO_Offset offset, ADIO_Offset *disp)
         flat_file = ADIOI_Flatlist;
         while (flat_file->type != fd->filetype) flat_file = flat_file->next;
 
-	MPI_Type_size(fd->filetype, (int*)&filetype_size);
+	MPI_Type_size_x(fd->filetype, &filetype_size);
 	n_etypes_in_filetype = filetype_size/etype_size;
 	n_filetypes = offset / n_etypes_in_filetype;
 	etype_in_filetype = offset % n_etypes_in_filetype;
diff --git a/src/mpi/romio/adio/common/flatten.c b/src/mpi/romio/adio/common/flatten.c
index 6ed7f06..80fdd4c 100644
--- a/src/mpi/romio/adio/common/flatten.c
+++ b/src/mpi/romio/adio/common/flatten.c
@@ -21,7 +21,8 @@ void ADIOI_Flatten_datatype(MPI_Datatype datatype)
 #ifdef HAVE_MPIR_TYPE_FLATTEN
     MPI_Aint flatten_idx;
 #endif
-    int curr_index=0, is_contig;
+    MPI_Count curr_index=0;
+    int is_contig;
     ADIOI_Flatlist_node *flat, *prev=0;
 
     /* check if necessary to flatten. */
@@ -60,7 +61,7 @@ void ADIOI_Flatten_datatype(MPI_Datatype datatype)
 
     flat->count = ADIOI_Count_contiguous_blocks(datatype, &curr_index);
 #ifdef FLATTEN_DEBUG 
-    DBG_FPRINTF(stderr,"ADIOI_Flatten_datatype:: count %#X, cur_idx = %#X\n",flat->count,curr_index);
+    DBG_FPRINTF(stderr,"ADIOI_Flatten_datatype:: count %#z, cur_idx = %#X\n",flat->count,curr_index);
 #endif
 /*    DBG_FPRINTF(stderr, "%d\n", flat->count);*/
 
@@ -104,7 +105,7 @@ void ADIOI_Flatten_datatype(MPI_Datatype datatype)
  * Assumption: input datatype is not a basic!!!!
  */
 void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat, 
-		  ADIO_Offset st_offset, int *curr_index)  
+		  ADIO_Offset st_offset, MPI_Count *curr_index)
 {
     int i, j, k, m, n, num, basic_num, prev_index;
     int combiner, old_combiner, old_is_contig;
@@ -112,8 +113,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
     /* By using ADIO_Offset we preserve +/- sign and 
          avoid >2G integer arithmetic problems */
     ADIO_Offset top_count;
-    /* By using unsigned we avoid >2G integer arithmetic problems */
-    unsigned old_size;
+    MPI_Count old_size;
     MPI_Aint old_extent;/* Assume extents are non-negative */
     int *ints;
     MPI_Aint *adds; /* Make no assumptions about +/- sign on these */
@@ -223,7 +223,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 /* simplest case, made up of basic or contiguous types */
 	    j = *curr_index;
 	    flat->indices[j] = st_offset;
-	    MPI_Type_size(types[0], (int*)&old_size);
+	    MPI_Type_size_x(types[0], &old_size);
 	    flat->blocklens[j] = top_count * old_size;
       #ifdef FLATTEN_DEBUG 
       DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",j, flat->indices[j], j, flat->blocklens[j]);
@@ -271,7 +271,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
     ADIO_Offset blocklength = ints[1], stride = ints[2];
 	    j = *curr_index;
 	    flat->indices[j] = st_offset;
-	    MPI_Type_size(types[0], (int*)&old_size);
+	    MPI_Type_size_x(types[0], &old_size);
 	    flat->blocklens[j] = blocklength * old_size;
 	    for (i=j+1; i<j+top_count; i++) {
 		flat->indices[i] = flat->indices[i-1] + stride * old_size;
@@ -334,7 +334,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
     ADIO_Offset blocklength = ints[1];
 	    j = *curr_index;
 	    flat->indices[j] = st_offset;
-	    MPI_Type_size(types[0], (int*)&old_size);
+	    MPI_Type_size_x(types[0], &old_size);
 	    flat->blocklens[j] = blocklength * old_size;
 	    for (i=j+1; i<j+top_count; i++) {
 		flat->indices[i] = flat->indices[i-1] + adds[0];
@@ -539,7 +539,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
 	if (prev_index == *curr_index) {
 /* simplest case, indexed type made up of basic or contiguous types */
 	    j = *curr_index;
-	    MPI_Type_size(types[0], (int*)&old_size);
+	    MPI_Type_size_x(types[0], &old_size);
 	    for (i=j; i<j+top_count; i++) {
         /* By using ADIO_Offset we preserve +/- sign and 
            avoid >2G integer arithmetic problems */
@@ -612,7 +612,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
         ADIO_Offset blocklength = ints[1+n];
 		j = *curr_index;
 		flat->indices[j] = st_offset + adds[n];
-		MPI_Type_size(types[n], (int*)&old_size);
+		MPI_Type_size_x(types[n], &old_size);
 		flat->blocklens[j] = blocklength * old_size;
         #ifdef FLATTEN_DEBUG 
         DBG_FPRINTF(stderr,"ADIOI_Flatten:: simple adds[%#X] "MPI_AINT_FMT_HEX_SPEC", flat->indices[%#X] %#llX, flat->blocklens[%#X] %#llX\n",n,adds[n],j, flat->indices[j], j, flat->blocklens[j]);
@@ -673,7 +673,7 @@ void ADIOI_Flatten(MPI_Datatype datatype, ADIOI_Flatlist_node *flat,
             /* current type is basic or contiguous */
 	    j = *curr_index;
 	    flat->indices[j] = st_offset;
-	    MPI_Type_size(types[0], (int*)&old_size);
+	    MPI_Type_size_x(types[0], &old_size);
 	    flat->blocklens[j] = old_size;
 
             #ifdef FLATTEN_DEBUG 
@@ -740,7 +740,8 @@ int ADIOI_Count_contiguous_blocks(MPI_Datatype datatype, int *curr_index)
     *curr_index = blks;
     return blks;
 #else
-    int count=0, i, n, num, basic_num, prev_index;
+    int i, n, num, basic_num, prev_index;
+    MPI_Count count=0;
     int top_count, combiner, old_combiner, old_is_contig;
     int nints, nadds, ntypes, old_nints, old_nadds, old_ntypes;
     int *ints;
diff --git a/src/mpi/romio/adio/common/get_fp_posn.c b/src/mpi/romio/adio/common/get_fp_posn.c
index 0421a8d..8f5b907 100644
--- a/src/mpi/romio/adio/common/get_fp_posn.c
+++ b/src/mpi/romio/adio/common/get_fp_posn.c
@@ -16,7 +16,7 @@ void ADIOI_Get_position(ADIO_File fd, ADIO_Offset *offset)
 {
     ADIOI_Flatlist_node *flat_file;
     int i, flag;
-    unsigned filetype_size;
+    MPI_Count filetype_size;
     int etype_size, filetype_is_contig;
     MPI_Aint filetype_extent;
     ADIO_Offset disp, byte_offset, sum=0, size_in_file, n_filetypes, frd_size;
@@ -30,7 +30,7 @@ void ADIOI_Get_position(ADIO_File fd, ADIO_Offset *offset)
         flat_file = ADIOI_Flatlist;
         while (flat_file->type != fd->filetype) flat_file = flat_file->next;
 
-	MPI_Type_size(fd->filetype, (int*)&filetype_size);
+	MPI_Type_size_x(fd->filetype, &filetype_size);
 	MPI_Type_extent(fd->filetype, &filetype_extent);
 
 	disp = fd->disp;
diff --git a/src/mpi/romio/adio/common/status_setb.c b/src/mpi/romio/adio/common/status_setb.c
index 7e46fbd..ec1e4ff 100644
--- a/src/mpi/romio/adio/common/status_setb.c
+++ b/src/mpi/romio/adio/common/status_setb.c
@@ -14,18 +14,18 @@
  * implementation fills status with something other than bytes (globus2 might
  * do this) */
 int MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype datatype, 
-			  int nbytes)
+			  MPI_Count nbytes)
 {
     ADIOI_UNREFERENCED_ARG(datatype);
     /* it's ok that ROMIO stores number-of-bytes in status, not 
      * count-of-copies, as long as MPI_GET_COUNT knows what to do */
     if (status != MPI_STATUS_IGNORE)
-        MPI_Status_set_elements(status, MPI_BYTE, nbytes);
+        MPI_Status_set_elements_x(status, MPI_BYTE, nbytes);
     return MPI_SUCCESS;
 }
 #elif defined(MPILAM) || defined(MPISGI)
 int MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype datatype,
-		int nbytes)
+		MPI_Count nbytes)
 {
   /* Bogusness to silence compiler warnings */
   if (datatype == MPI_DATATYPE_NULL);
diff --git a/src/mpi/romio/adio/include/adio.h b/src/mpi/romio/adio/include/adio.h
index 067641f..d168ac5 100644
--- a/src/mpi/romio/adio/include/adio.h
+++ b/src/mpi/romio/adio/include/adio.h
@@ -209,7 +209,7 @@ typedef struct ADIOI_FileD {
     ADIO_Offset disp;        /* reqd. for MPI-IO */
     MPI_Datatype etype;      /* reqd. for MPI-IO */
     MPI_Datatype filetype;   /* reqd. for MPI-IO */
-    int etype_size;          /* in bytes */
+    MPI_Count etype_size;          /* in bytes */
     ADIOI_Hints *hints;      /* structure containing fs-indep. info values */
     MPI_Info info;
 
diff --git a/src/mpi/romio/adio/include/adioi.h b/src/mpi/romio/adio/include/adioi.h
index 063b39c..d138697 100644
--- a/src/mpi/romio/adio/include/adioi.h
+++ b/src/mpi/romio/adio/include/adioi.h
@@ -104,7 +104,7 @@ enum {
 
 typedef struct ADIOI_Fl_node {  
     MPI_Datatype type;
-    int count;                   /* no. of contiguous blocks */
+    MPI_Count count;                   /* no. of contiguous blocks */
     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 */
@@ -318,7 +318,7 @@ typedef struct {
 void ADIOI_SetFunctions(ADIO_File fd);
 void ADIOI_Flatten_datatype(MPI_Datatype type);
 void ADIOI_Flatten(MPI_Datatype type, ADIOI_Flatlist_node *flat,
-		  ADIO_Offset st_offset, int *curr_index);  
+		  ADIO_Offset st_offset, MPI_Count *curr_index);
 void ADIOI_Delete_flattened(MPI_Datatype datatype);
 int ADIOI_Count_contiguous_blocks(MPI_Datatype type, int *curr_index);
 void ADIOI_Complete_async(int *error_code);
@@ -558,7 +558,10 @@ void ADIOI_GEN_Prealloc(ADIO_File fd, ADIO_Offset size, int *error_code);
 int ADIOI_Error(ADIO_File fd, int error_code, char *string);
 int MPIR_Err_setmsg( int, int, const char *, const char *, const char *, ... );
 int ADIOI_End_call(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state);
-int MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype datatype, int nbytes);
+int MPIR_Status_set_bytes(MPI_Status *status, MPI_Datatype datatype, MPI_Count nbytes);
+#ifdef HAVE_MPIR_TYPE_GET_CONTIG_BLOCKS
+MPI_Count MPIR_Type_get_contig_blocks(MPI_Datatype datatype, MPI_Count *nr_blocks_p);
+#endif
 int ADIOI_Uses_generic_read(ADIO_File fd);
 int ADIOI_Uses_generic_write(ADIO_File fd);
 int ADIOI_Err_create_code(const char *myname, const char *filename, int my_errno);
diff --git a/src/mpi/romio/mpi-io/iread.c b/src/mpi/romio/mpi-io/iread.c
index fb07e70..7f4d154 100644
--- a/src/mpi/romio/mpi-io/iread.c
+++ b/src/mpi/romio/mpi-io/iread.c
@@ -74,7 +74,7 @@ int MPIOI_File_iread(MPI_File fh, MPI_Offset offset, int file_ptr_type, void *bu
 		     MPI_Datatype datatype, char *myname, MPI_Request *request)
 {
     int error_code, bufsize, buftype_is_contig, filetype_is_contig;
-    int datatype_size;
+    MPI_Count datatype_size;
     ADIO_Status status;
     ADIO_File adio_fh;
     ADIO_Offset off;
@@ -98,7 +98,7 @@ int MPIOI_File_iread(MPI_File fh, MPI_Offset offset, int file_ptr_type, void *bu
     }
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/iread_sh.c b/src/mpi/romio/mpi-io/iread_sh.c
index 548e6c5..a218daa 100644
--- a/src/mpi/romio/mpi-io/iread_sh.c
+++ b/src/mpi/romio/mpi-io/iread_sh.c
@@ -46,7 +46,7 @@ int MPI_File_iread_shared(MPI_File fh, void *buf, int count,
     int error_code, bufsize, buftype_is_contig, filetype_is_contig;
     ADIO_File adio_fh;
     static char myname[] = "MPI_FILE_IREAD_SHARED";
-    int datatype_size, incr;
+    MPI_Count datatype_size, incr;
     MPI_Status status;
     ADIO_Offset off, shared_fp;
     MPI_Offset nbytes=0;
@@ -61,7 +61,7 @@ int MPI_File_iread_shared(MPI_File fh, void *buf, int count,
     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/iwrite.c b/src/mpi/romio/mpi-io/iwrite.c
index 54872e4..5bfdd78 100644
--- a/src/mpi/romio/mpi-io/iwrite.c
+++ b/src/mpi/romio/mpi-io/iwrite.c
@@ -81,7 +81,7 @@ int MPIOI_File_iwrite(MPI_File fh,
 		      MPI_Request *request)
 {
     int error_code, bufsize, buftype_is_contig, filetype_is_contig;
-    int datatype_size;
+    MPI_Count datatype_size;
     ADIO_Status status;
     ADIO_Offset off;
     ADIO_File adio_fh;
@@ -104,7 +104,7 @@ int MPIOI_File_iwrite(MPI_File fh,
     }
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/iwrite_sh.c b/src/mpi/romio/mpi-io/iwrite_sh.c
index e0e2b0b..49c0d30 100644
--- a/src/mpi/romio/mpi-io/iwrite_sh.c
+++ b/src/mpi/romio/mpi-io/iwrite_sh.c
@@ -46,7 +46,8 @@ int MPI_File_iwrite_shared(MPI_File fh, const void *buf, int count,
 {
     int error_code, bufsize, buftype_is_contig, filetype_is_contig;
     ADIO_File adio_fh;
-    int datatype_size, incr;
+    int incr;
+    MPI_Count datatype_size;
     ADIO_Status status;
     ADIO_Offset off, shared_fp;
     static char myname[] = "MPI_FILE_IWRITE_SHARED";
@@ -61,7 +62,7 @@ int MPI_File_iwrite_shared(MPI_File fh, const void *buf, int count,
     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/read.c b/src/mpi/romio/mpi-io/read.c
index 029db3b..e5b7238 100644
--- a/src/mpi/romio/mpi-io/read.c
+++ b/src/mpi/romio/mpi-io/read.c
@@ -71,7 +71,7 @@ int MPIOI_File_read(MPI_File fh,
 		    MPI_Status *status)
 {
     int error_code, bufsize, buftype_is_contig, filetype_is_contig;
-    int datatype_size;
+    MPI_Count datatype_size;
     ADIO_File adio_fh;
     ADIO_Offset off;
     void *xbuf=NULL, *e32_buf=NULL;
@@ -95,7 +95,7 @@ int MPIOI_File_read(MPI_File fh,
     }
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/read_all.c b/src/mpi/romio/mpi-io/read_all.c
index b387fe9..641d58d 100644
--- a/src/mpi/romio/mpi-io/read_all.c
+++ b/src/mpi/romio/mpi-io/read_all.c
@@ -72,7 +72,8 @@ int MPIOI_File_read_all(MPI_File fh,
 			char *myname,
 			MPI_Status *status)
 {
-    int error_code, datatype_size;
+    int error_code;
+    MPI_Count datatype_size;
     ADIO_File adio_fh;
     void *xbuf=NULL, *e32_buf=NULL;
 
@@ -95,7 +96,7 @@ int MPIOI_File_read_all(MPI_File fh,
     }
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/read_allb.c b/src/mpi/romio/mpi-io/read_allb.c
index ecc9088..743424d 100644
--- a/src/mpi/romio/mpi-io/read_allb.c
+++ b/src/mpi/romio/mpi-io/read_allb.c
@@ -59,7 +59,8 @@ int MPIOI_File_read_all_begin(MPI_File fh,
 			      MPI_Datatype datatype,
 			      char *myname)
 {
-    int error_code, datatype_size;
+    int error_code;
+    MPI_Count datatype_size;
     ADIO_File adio_fh;
     void *xbuf=NULL, *e32_buf=NULL;
 
@@ -82,7 +83,7 @@ int MPIOI_File_read_all_begin(MPI_File fh,
     }
     /* --END ERROR HANDLING-- */
     
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/read_ord.c b/src/mpi/romio/mpi-io/read_ord.c
index dc2573b..19ced81 100644
--- a/src/mpi/romio/mpi-io/read_ord.c
+++ b/src/mpi/romio/mpi-io/read_ord.c
@@ -42,7 +42,8 @@ Output Parameters:
 int MPI_File_read_ordered(MPI_File fh, void *buf, int count,
                           MPI_Datatype datatype, MPI_Status *status)
 {
-    int error_code, datatype_size, nprocs, myrank, incr;
+    int error_code, nprocs, myrank, incr;
+    MPI_Count datatype_size;
     int source, dest;
     static char myname[] = "MPI_FILE_READ_ORDERED";
     ADIO_Offset shared_fp=0;
@@ -58,7 +59,7 @@ int MPI_File_read_ordered(MPI_File fh, void *buf, int count,
     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/read_ordb.c b/src/mpi/romio/mpi-io/read_ordb.c
index 324fa7f..b29488d 100644
--- a/src/mpi/romio/mpi-io/read_ordb.c
+++ b/src/mpi/romio/mpi-io/read_ordb.c
@@ -39,7 +39,8 @@ Output Parameters:
 int MPI_File_read_ordered_begin(MPI_File fh, void *buf, int count,
 				MPI_Datatype datatype)
 {
-    int error_code, datatype_size, nprocs, myrank, incr;
+    int error_code,  nprocs, myrank, incr;
+    MPI_Count datatype_size;
     int source, dest;
     ADIO_Offset shared_fp;
     ADIO_File adio_fh;
@@ -68,7 +69,7 @@ int MPI_File_read_ordered_begin(MPI_File fh, void *buf, int count,
     adio_fh->split_coll_count = 1;
 
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
     MPIO_CHECK_FS_SUPPORTS_SHARED(adio_fh, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/read_sh.c b/src/mpi/romio/mpi-io/read_sh.c
index 1536838..65dd442 100644
--- a/src/mpi/romio/mpi-io/read_sh.c
+++ b/src/mpi/romio/mpi-io/read_sh.c
@@ -44,7 +44,8 @@ int MPI_File_read_shared(MPI_File fh, void *buf, int count,
 {
     int error_code, bufsize, buftype_is_contig, filetype_is_contig;
     static char myname[] = "MPI_FILE_READ_SHARED";
-    int datatype_size, incr;
+    int incr;
+    MPI_Count datatype_size;
     ADIO_Offset off, shared_fp;
     ADIO_File adio_fh;
     void *xbuf=NULL, *e32_buf=NULL;
@@ -59,7 +60,7 @@ int MPI_File_read_shared(MPI_File fh, void *buf, int count,
     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/set_view.c b/src/mpi/romio/mpi-io/set_view.c
index 77a7756..89762b5 100644
--- a/src/mpi/romio/mpi-io/set_view.c
+++ b/src/mpi/romio/mpi-io/set_view.c
@@ -39,7 +39,8 @@ Input Parameters:
 int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
 		      MPI_Datatype filetype, const char *datarep, MPI_Info info)
 {
-    int filetype_size, etype_size, error_code;
+    int error_code;
+    MPI_Count filetype_size, etype_size;
     static char myname[] = "MPI_FILE_SET_VIEW";
     ADIO_Offset shared_fp, byte_off;
     ADIO_File adio_fh;
@@ -109,8 +110,8 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
     MPIO_CHECK_INFO_ALL(info, error_code, adio_fh->comm);
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(filetype, &filetype_size);
-    MPI_Type_size(etype, &etype_size);
+    MPI_Type_size_x(filetype, &filetype_size);
+    MPI_Type_size_x(etype, &etype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     if (etype_size != 0 && filetype_size % etype_size != 0)
diff --git a/src/mpi/romio/mpi-io/write.c b/src/mpi/romio/mpi-io/write.c
index 02867c2..62d6eb0 100644
--- a/src/mpi/romio/mpi-io/write.c
+++ b/src/mpi/romio/mpi-io/write.c
@@ -71,7 +71,7 @@ int MPIOI_File_write(MPI_File fh,
 		     MPI_Status *status)
 {		      
     int error_code, bufsize, buftype_is_contig, filetype_is_contig;
-    int datatype_size;
+    MPI_Count datatype_size;
     ADIO_Offset off;
     ADIO_File adio_fh;
     void *e32buf=NULL;
@@ -96,7 +96,7 @@ int MPIOI_File_write(MPI_File fh,
     }
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/write_all.c b/src/mpi/romio/mpi-io/write_all.c
index 2e1533c..822330a 100644
--- a/src/mpi/romio/mpi-io/write_all.c
+++ b/src/mpi/romio/mpi-io/write_all.c
@@ -72,7 +72,8 @@ int MPIOI_File_write_all(MPI_File fh,
 			 char *myname,
 			 MPI_Status *status)
 {
-    int error_code, datatype_size;
+    int error_code;
+    MPI_Count datatype_size;
     ADIO_File adio_fh;
     void *e32buf=NULL;
     const void *xbuf=NULL;
@@ -96,7 +97,7 @@ int MPIOI_File_write_all(MPI_File fh,
     }
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/write_allb.c b/src/mpi/romio/mpi-io/write_allb.c
index 21e928e..e7e2fc2 100644
--- a/src/mpi/romio/mpi-io/write_allb.c
+++ b/src/mpi/romio/mpi-io/write_allb.c
@@ -58,7 +58,8 @@ int MPIOI_File_write_all_begin(MPI_File fh,
 			       MPI_Datatype datatype,
 			       char *myname)
 {
-    int error_code, datatype_size;
+    int error_code;
+    MPI_Count datatype_size;
     ADIO_File adio_fh;
     void *e32buf=NULL;
     const void *xbuf=NULL;
@@ -94,7 +95,7 @@ int MPIOI_File_write_all_begin(MPI_File fh,
 
     adio_fh->split_coll_count = 1;
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
     MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/write_ord.c b/src/mpi/romio/mpi-io/write_ord.c
index d0fe63f..22f1f06 100644
--- a/src/mpi/romio/mpi-io/write_ord.c
+++ b/src/mpi/romio/mpi-io/write_ord.c
@@ -43,7 +43,8 @@ Output Parameters:
 int MPI_File_write_ordered(MPI_File fh, const void *buf, int count,
 			   MPI_Datatype datatype, MPI_Status *status)
 {
-    int error_code, datatype_size, nprocs, myrank, incr;
+    int error_code, nprocs, myrank, incr;
+    MPI_Count datatype_size;
     int source, dest;
     static char myname[] = "MPI_FILE_WRITE_ORDERED";
     ADIO_Offset shared_fp;
@@ -61,7 +62,7 @@ int MPI_File_write_ordered(MPI_File fh, const void *buf, int count,
     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/write_ordb.c b/src/mpi/romio/mpi-io/write_ordb.c
index 87ee213..848de29 100644
--- a/src/mpi/romio/mpi-io/write_ordb.c
+++ b/src/mpi/romio/mpi-io/write_ordb.c
@@ -39,7 +39,8 @@ Output Parameters:
 int MPI_File_write_ordered_begin(MPI_File fh, const void *buf, int count,
 				 MPI_Datatype datatype)
 {
-    int error_code, datatype_size, nprocs, myrank, incr;
+    int error_code, nprocs, myrank, incr;
+    MPI_Count datatype_size;
     int source, dest;
     static char myname[] = "MPI_FILE_WRITE_ORDERED_BEGIN";
     ADIO_Offset shared_fp;
@@ -68,7 +69,7 @@ int MPI_File_write_ordered_begin(MPI_File fh, const void *buf, int count,
 
     adio_fh->split_coll_count = 1;
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
     MPIO_CHECK_FS_SUPPORTS_SHARED(adio_fh, myname, error_code);
diff --git a/src/mpi/romio/mpi-io/write_sh.c b/src/mpi/romio/mpi-io/write_sh.c
index de7d21d..870e901 100644
--- a/src/mpi/romio/mpi-io/write_sh.c
+++ b/src/mpi/romio/mpi-io/write_sh.c
@@ -44,7 +44,7 @@ int MPI_File_write_shared(MPI_File fh, const void *buf, int count,
 {
     int error_code, bufsize, buftype_is_contig, filetype_is_contig;
     static char myname[] = "MPI_FILE_READ_SHARED";
-    int datatype_size, incr;
+    MPI_Count datatype_size, incr;
     ADIO_Offset off, shared_fp;
     ADIO_File adio_fh;
     void *e32buf = NULL;
@@ -60,7 +60,7 @@ int MPI_File_write_shared(MPI_File fh, const void *buf, int count,
     MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
     /* --END ERROR HANDLING-- */
 
-    MPI_Type_size(datatype, &datatype_size);
+    MPI_Type_size_x(datatype, &datatype_size);
 
     /* --BEGIN ERROR HANDLING-- */
     MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);

http://git.mpich.org/mpich.git/commitdiff/e518cb4c0c80bf14b5eb828fc32397991a8d38e8

commit e518cb4c0c80bf14b5eb828fc32397991a8d38e8
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Tue Sep 24 16:02:30 2013 -0500

    Configure check for (need for) header padding
    
    Dancing around with various schemes to detect/deal-with compiler padding
    in structs so the 'payload' field ends up double-aligned.  The new
    "large type , large count" work introduced a pointer into the nemisis
    packet, so we have to be a bit more dynamic about how or if we pad out
    the structure.
    
    - put the members of MPID_nem_pkt_header inside a struct, so subsequent
      payload does not "fall into" compiler-introduced padding
    - use this updated datatype to determine the size, and if we need to pad
      or not.
    - use the result of the configure test to introduce padding, or omit the
      padding from the definition if the amount of padding is '0'
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/mpid/ch3/channels/nemesis/include/mpid_nem_datatypes.h b/src/mpid/ch3/channels/nemesis/include/mpid_nem_datatypes.h
index bbc7b98..13a3940 100644
--- a/src/mpid/ch3/channels/nemesis/include/mpid_nem_datatypes.h
+++ b/src/mpid/ch3/channels/nemesis/include/mpid_nem_datatypes.h
@@ -144,20 +144,14 @@
 #define MPID_NEM_MPICH_HEAD_LEN sizeof(MPID_nem_pkt_header_t)
 #define MPID_NEM_MPICH_DATA_LEN (MPID_NEM_CELL_PAYLOAD_LEN - MPID_NEM_MPICH_HEAD_LEN)
 
-#define MPID_NEM_PKT_HEADER_FIELDS		\
-    int source;					\
-    int dest;					\
-    MPIDI_msg_sz_t datalen;                     \
-    unsigned short seqno;                       \
-    unsigned short type /* currently used only with checkpointing */
-typedef struct MPID_nem_pkt_header
-{
-    MPID_NEM_PKT_HEADER_FIELDS;
-} MPID_nem_pkt_header_t;
+#include "mpid_nem_pkt_header.h"
 
 typedef struct MPID_nem_pkt_mpich
 {
     MPID_NEM_PKT_HEADER_FIELDS;
+#if (MPID_NEM_PKT_HEADER_PADDING > 0)
+    char padding[MPID_NEM_PKT_HEADER_PADDING];
+#endif
     char payload[MPID_NEM_MPICH_DATA_LEN];
 } MPID_nem_pkt_mpich_t;
 
diff --git a/src/mpid/ch3/channels/nemesis/include/mpid_nem_pkt_header.h b/src/mpid/ch3/channels/nemesis/include/mpid_nem_pkt_header.h
new file mode 100644
index 0000000..5888cf3
--- /dev/null
+++ b/src/mpid/ch3/channels/nemesis/include/mpid_nem_pkt_header.h
@@ -0,0 +1,25 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *  (C) 2013 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+#ifndef MPID_NEM_PKT_HEADER_H
+#define MPID_NEM_PKT_HEADER_H
+
+#define MPID_NEM_PKT_HEADER_FIELDS		\
+    struct {                                    \
+        int source;                             \
+        int dest;                               \
+        MPIR_Pint datalen;                      \
+        unsigned short seqno;                   \
+        unsigned short type; /* currently used only with checkpointing */ \
+    };
+
+typedef struct MPID_nem_pkt_header
+{
+    MPID_NEM_PKT_HEADER_FIELDS;
+} MPID_nem_pkt_header_t;
+
+
+#endif /* MPID_NEM_DATATYPES_H */
diff --git a/src/mpid/ch3/channels/nemesis/subconfigure.m4 b/src/mpid/ch3/channels/nemesis/subconfigure.m4
index c53932f..fab8504 100644
--- a/src/mpid/ch3/channels/nemesis/subconfigure.m4
+++ b/src/mpid/ch3/channels/nemesis/subconfigure.m4
@@ -319,6 +319,23 @@ if test "$enable_nemesis_lock_free_queues" = "yes" ; then
     AC_DEFINE(MPID_NEM_USE_LOCK_FREE_QUEUES, 1, [Define to enable lock-free communication queues])
 fi
 
+# for nemisis header alignment, will need to know how this structure laid out:
+AC_CHECK_SIZEOF(MPID_nem_pkt_header_t, 0, [
+typedef $MPI_PINT MPIR_Pint;
+#include "${master_top_srcdir}/src/mpid/ch3/channels/nemesis/include/mpid_nem_pkt_header.h"])
+
+AC_CHECK_ALIGNOF(MPID_nem_pkt_header_t, [
+typedef $MPI_PINT MPIR_Pint;
+#include "${master_top_srcdir}/src/mpid/ch3/channels/nemesis/include/mpid_nem_pkt_header.h"])
+
+# We're trying to get 'payload' to live at a double-aligned memory address
+AS_VAR_ARITH([mpid_pkt_header_padding],
+	     [ $ac_cv_alignof_MPID_nem_pkt_header_t % $ac_cv_sizeof_double])
+AC_DEFINE_UNQUOTED(MPID_NEM_PKT_HEADER_PADDING, [$mpid_pkt_header_padding], [Amount of padding needed in the MPID_nem_pkt_header_t structure])
+
+
+
+
 AC_SUBST(device_name)
 AC_SUBST(channel_name)
 AC_SUBST(nemesis_networks)

http://git.mpich.org/mpich.git/commitdiff/d1bf416117ccff40533f9c3007ba2859b944fb47

commit d1bf416117ccff40533f9c3007ba2859b944fb47
Author: Dave Goodell <goodell at mcs.anl.gov>
Date:   Thu Apr 4 13:02:16 2013 -0500

    large count work: use MPI_Aint for dtype size and collectives
    
    Also includes random fixes to `-Wshorten-64-to-32` warnings which might
    need to be teased out.
    
    Signed-off-by: Pavan Balaji <balaji at mcs.anl.gov>

diff --git a/src/include/mpierrs.h b/src/include/mpierrs.h
index ee592e2..e9c69e3 100644
--- a/src/include/mpierrs.h
+++ b/src/include/mpierrs.h
@@ -298,7 +298,7 @@
         int ferr = 0;							\
         if (HANDLE_GET_KIND(dtype) == HANDLE_KIND_BUILTIN) { ferr=1; }	\
         else {								\
-            int errsize;                                                \
+            MPI_Aint errsize;                                           \
             MPID_Datatype *errdtypeptr;					\
             MPID_Datatype_get_ptr(dtype,errdtypeptr);			\
             MPID_Datatype_get_size_macro(dtype,errsize);                \
diff --git a/src/include/mpiutil.h b/src/include/mpiutil.h
index 9cd5d66..266fbe1 100644
--- a/src/include/mpiutil.h
+++ b/src/include/mpiutil.h
@@ -195,7 +195,10 @@ int MPIR_Assert_fail_fmt(const char *cond, const char *file_name, int line_num,
              unsigned short:     USHRT_MAX,  \
              unsigned int:       UINT_MAX,   \
              unsigned long:      ULONG_MAX,  \
-             unsigned long long: ULLONG_MAX)
+             unsigned long long: ULLONG_MAX,\
+             /* _Generic cares about cv-qualifiers */ \
+             volatile signed int:   INT_MAX,          \
+             volatile unsigned int: UINT_MAX)
 #define expr_inttype_min(expr_)             \
     _Generic(expr_,                         \
              signed char:        SCHAR_MIN, \
@@ -207,7 +210,10 @@ int MPIR_Assert_fail_fmt(const char *cond, const char *file_name, int line_num,
              unsigned short:     0,         \
              unsigned int:       0,         \
              unsigned long:      0,         \
-             unsigned long long: 0)
+             unsigned long long: 0,         \
+             /* _Generic cares about cv-qualifiers */ \
+             volatile signed int:   INT_MIN,          \
+             volatile unsigned int: 0)
 #endif
 
 /* Assigns (src_) to (dst_), checking that (src_) fits in (dst_) without
@@ -218,18 +224,19 @@ int MPIR_Assert_fail_fmt(const char *cond, const char *file_name, int line_num,
  * can be found in Chapter 5 of "Secure Coding in C and C++" by Robert Seacord.
  */
 #if defined(expr_inttype_max) && defined(expr_inttype_min)
-#  define MPIU_Assign_trunc(dst_,src_) \
-    do { \
-        MPIU_Assert((src_) <= expr_inttype_max(dst_)); \
-        MPIU_Assert((src_) >= expr_inttype_min(dst_)); \
-        dst_ = (src_); \
+#  define MPIU_Assign_trunc(dst_,src_,dst_type_)                                       \
+    do {                                                                               \
+        MPIU_Assert_has_type((dst_), dst_type_);                                       \
+        MPIU_Assert((src_) <= expr_inttype_max(dst_));                                 \
+        MPIU_Assert((src_) >= expr_inttype_min(dst_));                                 \
+        dst_ = (dst_type_)(src_);                                                      \
     } while (0)
 #else
-#  define MPIU_Assign_trunc(dst_,src_) \
-    do { \
-        dst_ = (src_); \
+#  define MPIU_Assign_trunc(dst_,src_,dst_type_)                                       \
+    do {                                                                               \
+        dst_ = (dst_type_)(src_);                                                      \
         /* will catch some of the cases if the expr_inttype macros aren't available */ \
-        MPIU_Assert((dst_) == (src_)); \
+        MPIU_Assert((dst_) == (src_));                                                 \
     } while (0)
 #endif
 
diff --git a/src/mpi/coll/allred_group.c b/src/mpi/coll/allred_group.c
index a493bc1..396fb76 100644
--- a/src/mpi/coll/allred_group.c
+++ b/src/mpi/coll/allred_group.c
@@ -29,7 +29,7 @@ int MPIR_Allreduce_group_intra(void *sendbuf, void *recvbuf, int count,
                                MPI_Datatype datatype, MPI_Op op, MPID_Comm *comm_ptr,
                                MPID_Group *group_ptr, int tag, int *errflag)
 {
-    int type_size;
+    MPI_Aint type_size;
     int mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
     /* newrank is a rank in group_ptr */
diff --git a/src/mpi/coll/allreduce.c b/src/mpi/coll/allreduce.c
index 766caa8..e0b014b 100644
--- a/src/mpi/coll/allreduce.c
+++ b/src/mpi/coll/allreduce.c
@@ -136,7 +136,8 @@ int MPIR_Allreduce_intra (
     int is_homogeneous;
     int rc;
 #endif
-    int        comm_size, rank, type_size;
+    int comm_size, rank;
+    MPI_Aint type_size;
     int mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
     int nbytes = 0;
diff --git a/src/mpi/coll/bcast.c b/src/mpi/coll/bcast.c
index aa3ec5e..f644bfd 100644
--- a/src/mpi/coll/bcast.c
+++ b/src/mpi/coll/bcast.c
@@ -45,7 +45,8 @@ static int MPIR_Bcast_binomial(
     int nbytes=0;
     int recvd_size;
     MPI_Status status;
-    int type_size, is_contig, is_homogeneous;
+    int is_contig, is_homogeneous;
+    MPI_Aint type_size;
     int position;
     void *tmp_buf=NULL;
     MPI_Comm comm;
@@ -399,8 +400,9 @@ static int MPIR_Bcast_scatter_doubling_allgather(
     int relative_rank, mask;
     int mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
-    int scatter_size, nbytes=0, curr_size, recv_size = 0;
-    int type_size, j, k, i, tmp_mask, is_contig, is_homogeneous;
+    int scatter_size, curr_size, recv_size = 0;
+    int j, k, i, tmp_mask, is_contig, is_homogeneous;
+    MPI_Aint type_size, nbytes = 0;
     int relative_dst, dst_tree_root, my_tree_root, send_offset;
     int recv_offset, tree_root, nprocs_completed, offset, position;
     MPIU_CHKLMEM_DECL(1);
@@ -706,7 +708,8 @@ static int MPIR_Bcast_scatter_ring_allgather(
     int mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
     int scatter_size, nbytes;
-    int type_size, j, i, is_contig, is_homogeneous;
+    int j, i, is_contig, is_homogeneous;
+    MPI_Aint type_size;
     int position;
     int left, right, jnext;
     int curr_size = 0;
@@ -912,8 +915,8 @@ static int MPIR_SMP_Bcast(
 {
     int mpi_errno = MPI_SUCCESS;
     int mpi_errno_ret = MPI_SUCCESS;
-    int type_size, is_homogeneous;
-    int nbytes=0;
+    int is_homogeneous;
+    MPI_Aint type_size, nbytes=0;
     MPI_Status status;
     int recvd_size;
 
diff --git a/src/mpi_t/mpit.c b/src/mpi_t/mpit.c
index 9ca5f0f..8636b80 100644
--- a/src/mpi_t/mpit.c
+++ b/src/mpi_t/mpit.c
@@ -455,7 +455,7 @@ void MPIR_T_strncpy(char *dst, const char *src, int *len)
             MPIU_Assert(*len > 0);
             if (src != NULL) {
                 MPL_strncpy(dst, src, *len);
-                *len = strlen(dst) + 1;
+                *len = (int)strlen(dst) + 1;
             } else {
                 /* As if an empty string is copied */
                 *dst = '\0';
diff --git a/src/mpid/ch3/channels/nemesis/include/mpid_nem_datatypes.h b/src/mpid/ch3/channels/nemesis/include/mpid_nem_datatypes.h
index 04b3c56..bbc7b98 100644
--- a/src/mpid/ch3/channels/nemesis/include/mpid_nem_datatypes.h
+++ b/src/mpid/ch3/channels/nemesis/include/mpid_nem_datatypes.h
@@ -147,7 +147,7 @@
 #define MPID_NEM_PKT_HEADER_FIELDS		\
     int source;					\
     int dest;					\
-    int datalen;				\
+    MPIDI_msg_sz_t datalen;                     \
     unsigned short seqno;                       \
     unsigned short type /* currently used only with checkpointing */
 typedef struct MPID_nem_pkt_header
diff --git a/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h b/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
index 32eb82d..2e3f299 100644
--- a/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
+++ b/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
@@ -217,7 +217,7 @@ MPID_nem_mpich_sendv (MPID_IOV **iov, int *n_iov, MPIDI_VC_t *vc, int *again)
     
     while (*n_iov && payload_len >= (*iov)->MPID_IOV_LEN)
     {
-	int _iov_len = (*iov)->MPID_IOV_LEN;
+	size_t _iov_len = (*iov)->MPID_IOV_LEN;
 	MPIU_Memcpy (cell_buf, (*iov)->MPID_IOV_BUF, _iov_len);
 	payload_len -= _iov_len;
 	cell_buf += _iov_len;
@@ -352,7 +352,7 @@ MPID_nem_mpich_sendv_header (MPID_IOV **iov, int *n_iov, MPIDI_VC_t *vc, int *ag
     payload_len = MPID_NEM_MPICH_DATA_LEN - sizeof(MPIDI_CH3_Pkt_t);
     while (*n_iov && payload_len >= (*iov)->MPID_IOV_LEN)
     {
-	int _iov_len = (*iov)->MPID_IOV_LEN;
+	size_t _iov_len = (*iov)->MPID_IOV_LEN;
 	MPIU_Memcpy (cell_buf, (*iov)->MPID_IOV_BUF, _iov_len);
 	payload_len -= _iov_len;
 	cell_buf += _iov_len;
diff --git a/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c b/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c
index a26cfb2..d27a525 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c
@@ -459,7 +459,9 @@ static int send_id_info(const sockconn_t *const sc)
     MPIDI_nem_tcp_idinfo_t id_info;
     MPIDI_nem_tcp_header_t hdr;
     struct iovec iov[3];
-    int pg_id_len = 0, offset, buf_size, iov_cnt = 2;
+    int buf_size, iov_cnt = 2;
+    ssize_t offset;
+    size_t pg_id_len = 0;
     MPIDI_STATE_DECL(MPID_STATE_SEND_ID_INFO);
 
     MPIDI_FUNC_ENTER(MPID_STATE_SEND_ID_INFO);
@@ -503,7 +505,7 @@ static int send_id_info(const sockconn_t *const sc)
     MPIDI_FUNC_EXIT(MPID_STATE_SEND_ID_INFO);
     return mpi_errno;
  fn_fail:
-    MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "failure. mpi_errno = %d, offset=%d, errno=%d %s", mpi_errno, offset, errno, MPIU_Strerror(errno)));
+    MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "failure. mpi_errno = %d, offset=%lld, errno=%d %s", mpi_errno, (long long)offset, errno, MPIU_Strerror(errno)));
     goto fn_exit;    
 }
 
@@ -518,7 +520,8 @@ static int send_tmpvc_info(const sockconn_t *const sc)
     MPIDI_nem_tcp_portinfo_t port_info;
     MPIDI_nem_tcp_header_t hdr;
     struct iovec iov[3];
-    int offset, buf_size, iov_cnt = 2;
+    int buf_size, iov_cnt = 2;
+    ssize_t offset;
     MPIDI_STATE_DECL(MPID_STATE_SEND_TMPVC_INFO);
 
     MPIDI_FUNC_ENTER(MPID_STATE_SEND_TMPVC_INFO);
@@ -552,7 +555,7 @@ static int send_tmpvc_info(const sockconn_t *const sc)
     MPIDI_FUNC_EXIT(MPID_STATE_SEND_TMPVC_INFO);
     return mpi_errno;
  fn_fail:
-    MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "failure. mpi_errno = %d, offset=%d, errno=%d %s", mpi_errno, offset, errno, MPIU_Strerror(errno)));
+    MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "failure. mpi_errno = %d, offset=%lld, errno=%d %s", mpi_errno, (long long)offset, errno, MPIU_Strerror(errno)));
     goto fn_exit;    
 }
 
@@ -564,7 +567,9 @@ static int recv_id_or_tmpvc_info(sockconn_t *const sc, int *got_sc_eof)
 {
     int mpi_errno = MPI_SUCCESS;
     MPIDI_nem_tcp_header_t hdr;
-    int pg_id_len = 0, nread, iov_cnt = 1;
+    int iov_cnt = 1;
+    size_t pg_id_len = 0;
+    ssize_t nread;
     int hdr_len = sizeof(MPIDI_nem_tcp_header_t);
     struct iovec iov[2];
     char *pg_id = NULL;
@@ -695,7 +700,8 @@ static int recv_id_or_tmpvc_info(sockconn_t *const sc, int *got_sc_eof)
 #define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int send_cmd_pkt(int fd, MPIDI_nem_tcp_socksm_pkt_type_t pkt_type)
 {
-    int mpi_errno = MPI_SUCCESS, offset;
+    int mpi_errno = MPI_SUCCESS;
+    ssize_t offset;
     MPIDI_nem_tcp_header_t pkt;
     int pkt_len = sizeof(MPIDI_nem_tcp_header_t);
 
@@ -729,7 +735,8 @@ static int send_cmd_pkt(int fd, MPIDI_nem_tcp_socksm_pkt_type_t pkt_type)
 #define FCNAME MPIDI_QUOTE(FUNCNAME)
 static int recv_cmd_pkt(int fd, MPIDI_nem_tcp_socksm_pkt_type_t *pkt_type)
 {
-    int mpi_errno = MPI_SUCCESS, nread;
+    int mpi_errno = MPI_SUCCESS;
+    ssize_t nread;
     MPIDI_nem_tcp_header_t pkt;
     int pkt_len = sizeof(MPIDI_nem_tcp_header_t);
     MPIDI_STATE_DECL(MPID_STATE_RECV_CMD_PKT);
@@ -1597,11 +1604,11 @@ static int MPID_nem_tcp_recv_handler(sockconn_t *const sc)
             {
                 iov->MPID_IOV_BUF = (char *)iov->MPID_IOV_BUF + bytes_recvd;
                 iov->MPID_IOV_LEN -= bytes_recvd;
-                rreq->dev.iov_count = &rreq->dev.iov[rreq->dev.iov_offset + rreq->dev.iov_count] - iov;
+                rreq->dev.iov_count = (int)(&rreq->dev.iov[rreq->dev.iov_offset + rreq->dev.iov_count] - iov);
                 rreq->dev.iov_offset = iov - rreq->dev.iov;
                 MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "bytes_recvd = %ld", (long int)bytes_recvd);
                 MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "iov len = %ld", (long int)iov->MPID_IOV_LEN);
-                MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "iov_offset = %d", rreq->dev.iov_offset);
+                MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "iov_offset = %lld", (long long)rreq->dev.iov_offset);
                 goto fn_exit;
             }
             bytes_recvd -= iov->MPID_IOV_LEN;
@@ -1811,7 +1818,7 @@ int MPID_nem_tcp_connpoll(int in_blocking_poll)
              * on many platforms, including modern Linux. */
             if (it_plfd->revents & POLLERR || it_plfd->revents & POLLNVAL) {
                 int req_errno = MPI_SUCCESS;
-                int rc;
+                ssize_t rc;
                 char dummy;
                 const char *err_str = "UNKNOWN";
 
diff --git a/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.h b/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.h
index ea3e02e..270de1a 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.h
+++ b/src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.h
@@ -162,7 +162,7 @@ typedef enum MPIDI_nem_tcp_socksm_pkt_type {
     
 typedef struct MPIDI_nem_tcp_header {
     MPIDI_nem_tcp_socksm_pkt_type_t pkt_type;
-    int datalen;
+    MPIDI_msg_sz_t datalen;
 } MPIDI_nem_tcp_header_t;
 
 typedef struct MPIDI_nem_tcp_idinfo {
diff --git a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_utility.c b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_utility.c
index b4bca79..fbc9d2c 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_utility.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_utility.c
@@ -179,7 +179,8 @@ int MPID_nem_tcp_is_sock_connected(int fd)
 {
     int rc = FALSE;
     char buf[1];
-    int buf_len = sizeof(buf)/sizeof(buf[0]), ret_recv, error=0;
+    int buf_len = sizeof(buf)/sizeof(buf[0]), error=0;
+    size_t ret_recv;
     socklen_t n = sizeof(error);
 
     n = sizeof(error);
diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_isend.c b/src/mpid/ch3/channels/nemesis/src/ch3_isend.c
index 1b15039..da5141a 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_isend.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_isend.c
@@ -51,8 +51,9 @@ int MPIDI_CH3_iSend (MPIDI_VC_t *vc, MPID_Request *sreq, void * hdr, MPIDI_msg_s
 
     if (MPIDI_CH3I_Sendq_empty(MPIDI_CH3I_shm_sendq))
     {
+        MPIU_Assert(hdr_sz <= INT_MAX);
 	MPIU_DBG_MSG_D (CH3_CHANNEL, VERBOSE, "iSend %d", (int) hdr_sz);
-	mpi_errno = MPID_nem_mpich_send_header (hdr, hdr_sz, vc, &again);
+	mpi_errno = MPID_nem_mpich_send_header (hdr, (int)hdr_sz, vc, &again);
         if (mpi_errno) MPIU_ERR_POP (mpi_errno);
 	if (again)
 	{
diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_istartmsg.c b/src/mpid/ch3/channels/nemesis/src/ch3_istartmsg.c
index a21219e..4e97a0a 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_istartmsg.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_istartmsg.c
@@ -55,8 +55,9 @@ int MPIDI_CH3_iStartMsg (MPIDI_VC_t *vc, void *hdr, MPIDI_msg_sz_t hdr_sz, MPID_
     if (MPIDI_CH3I_Sendq_empty(MPIDI_CH3I_shm_sendq))
        /* MT */
     {
+        MPIU_Assert(hdr_sz <= INT_MAX);
 	MPIU_DBG_MSG_D (CH3_CHANNEL, VERBOSE, "iStartMsg %d", (int) hdr_sz);
-	mpi_errno = MPID_nem_mpich_send_header (hdr, hdr_sz, vc, &again);
+	mpi_errno = MPID_nem_mpich_send_header (hdr, (int)hdr_sz, vc, &again);
         if (mpi_errno) MPIU_ERR_POP (mpi_errno);
 	if (again)
 	{
diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
index e26658a..0b4657e 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
@@ -723,8 +723,8 @@ int MPID_nem_handle_pkt(MPIDI_VC_t *vc, char *buf, MPIDI_msg_sz_t buflen)
 		
             while (n_iov && buflen >= iov->MPID_IOV_LEN)
             {
-                int iov_len = iov->MPID_IOV_LEN;
-		MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "        %d", iov_len);
+                size_t iov_len = iov->MPID_IOV_LEN;
+		MPIU_DBG_MSG_D(CH3_CHANNEL, VERBOSE, "        %d", (int)iov_len);
                 MPIU_Memcpy (iov->MPID_IOV_BUF, buf, iov_len);
 
                 buflen -= iov_len;
diff --git a/src/mpid/ch3/channels/nemesis/src/mpid_nem_debug.c b/src/mpid/ch3/channels/nemesis/src/mpid_nem_debug.c
index 1ab1fe1..44dfd0b 100644
--- a/src/mpid/ch3/channels/nemesis/src/mpid_nem_debug.c
+++ b/src/mpid/ch3/channels/nemesis/src/mpid_nem_debug.c
@@ -20,7 +20,7 @@ void MPID_nem_dbg_dump_cell (volatile struct MPID_nem_cell *cell)
 
     MPIU_DBG_MSG_D (ALL, TERSE, "  src = %6d", cell->pkt.mpich.source);
     MPIU_DBG_MSG_D (ALL, TERSE, "  dst = %6d", cell->pkt.mpich.dest);
-    MPIU_DBG_MSG_D (ALL, TERSE, "  len = %6d", cell->pkt.mpich.datalen);
+    MPIU_DBG_MSG_D (ALL, TERSE, "  len = %6d", (int)cell->pkt.mpich.datalen);
     MPIU_DBG_MSG_D (ALL, TERSE, "  sqn = %6d", cell->pkt.mpich.seqno);
     MPIU_DBG_MSG_D (ALL, TERSE, "  typ = %6d", cell->pkt.mpich.type);
 
diff --git a/src/mpid/ch3/channels/nemesis/src/mpid_nem_init.c b/src/mpid/ch3/channels/nemesis/src/mpid_nem_init.c
index 5674e8d..34243cd 100644
--- a/src/mpid/ch3/channels/nemesis/src/mpid_nem_init.c
+++ b/src/mpid/ch3/channels/nemesis/src/mpid_nem_init.c
@@ -4,7 +4,7 @@
  *      See COPYRIGHT in top-level directory.
  */
 
-#include "mpid_nem_pre.h"
+#include "mpiimpl.h"
 #include "mpid_nem_impl.h"
 #include "mpid_nem_nets.h"
 #include <errno.h>
diff --git a/src/mpid/ch3/channels/nemesis/src/mpid_nem_lmt_shm.c b/src/mpid/ch3/channels/nemesis/src/mpid_nem_lmt_shm.c
index 489de5c..e8ccc6d 100644
--- a/src/mpid/ch3/channels/nemesis/src/mpid_nem_lmt_shm.c
+++ b/src/mpid/ch3/channels/nemesis/src/mpid_nem_lmt_shm.c
@@ -494,7 +494,7 @@ static int lmt_shm_send_progress(MPIDI_VC_t *vc, MPID_Request *req, int *done)
         last = (data_sz - first <= copy_limit) ? data_sz : first + copy_limit;
 	MPID_Segment_pack(req->dev.segment_ptr, first, &last, (void *)copy_buf->buf[buf_num]); /* cast away volatile */
         OPA_write_barrier();
-        copy_buf->len[buf_num].val = last - first;
+        MPIU_Assign_trunc(copy_buf->len[buf_num].val, (last - first), volatile int);
 
         first = last;
         buf_num = (buf_num+1) % NUM_BUFS;
diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 3e0935d..4d93ae4 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -340,7 +340,7 @@ typedef struct MPIDI_Request {
        iov_offset points to the current head element in the IOV */
     MPID_IOV iov[MPID_IOV_LIMIT];
     int iov_count;
-    int iov_offset;
+    size_t iov_offset;
 
     /* OnDataAvail is the action to take when data is now available.
        For example, when an operation described by an iov has 
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 54b8d7f..4eb6206 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -47,7 +47,7 @@ enum MPID_Lock_state {
 typedef struct MPIDI_RMA_dtype_info { /* for derived datatypes */
     int           is_contig; 
     int           max_contig_blocks;
-    int           size;     
+    MPI_Aint      size;
     MPI_Aint      extent;   
     int           dataloop_size; /* not needed because this info is sent in 
 				    packet header. remove it after lock/unlock 
@@ -707,7 +707,8 @@ static inline int MPIDI_CH3I_Shm_acc_op(const void *origin_addr, int origin_coun
             if (shm_op) MPIDI_CH3I_SHM_MUTEX_LOCK(win_ptr);
             for (i=0; i<vec_len; i++)
             {
-                count = (dloop_vec[i].DLOOP_VECTOR_LEN)/type_size;
+		MPIU_Assign_trunc(count, (dloop_vec[i].DLOOP_VECTOR_LEN)/type_size, int);
+
                 (*uop)((char *)source_buf + MPIU_PtrToAint(dloop_vec[i].DLOOP_VECTOR_BUF),
                        (char *)target_buf + MPIU_PtrToAint(dloop_vec[i].DLOOP_VECTOR_BUF),
                        &count, &type);
@@ -866,7 +867,7 @@ static inline int MPIDI_CH3I_Shm_get_acc_op(const void *origin_addr, int origin_
             type_size = MPID_Datatype_get_basic_size(type);
 
             for (i=0; i<vec_len; i++) {
-                count = (dloop_vec[i].DLOOP_VECTOR_LEN)/type_size;
+		MPIU_Assign_trunc(count, (dloop_vec[i].DLOOP_VECTOR_LEN)/type_size, int);
                 (*uop)((char *)source_buf + MPIU_PtrToAint(dloop_vec[i].DLOOP_VECTOR_BUF),
                        (char *)target_buf + MPIU_PtrToAint(dloop_vec[i].DLOOP_VECTOR_BUF),
                        &count, &type);
@@ -943,7 +944,8 @@ static inline int MPIDI_CH3I_Shm_cas_op(const void *origin_addr, const void *com
 {
     void *base = NULL, *dest_addr = NULL;
     int disp_unit;
-    int len, shm_locked = 0;
+    MPI_Aint len;
+    int shm_locked = 0;
     int mpi_errno = MPI_SUCCESS;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_CAS_OP);
 
@@ -999,7 +1001,8 @@ static inline int MPIDI_CH3I_Shm_fop_op(const void *origin_addr, void *result_ad
     void *base = NULL, *dest_addr = NULL;
     MPI_User_function *uop = NULL;
     int disp_unit;
-    int len, one, shm_locked = 0;
+    MPI_Aint len;
+    int one, shm_locked = 0;
     int mpi_errno = MPI_SUCCESS;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SHM_FOP_OP);
 
diff --git a/src/mpid/ch3/src/ch3u_handle_connection.c b/src/mpid/ch3/src/ch3u_handle_connection.c
index fbbe3cb..cc34eb9 100644
--- a/src/mpid/ch3/src/ch3u_handle_connection.c
+++ b/src/mpid/ch3/src/ch3u_handle_connection.c
@@ -424,7 +424,7 @@ static int terminate_failed_VCs(MPID_Group *new_failed_group)
         while (isspace(*c)) /* skip spaces */                                                   \
             ++c;                                                                                \
         MPIU_ERR_CHKINTERNAL(!isdigit(*c), mpi_errno, "error parsing failed process list");     \
-        *(r_p) = strtol(c, &c, 0);                                                              \
+        *(r_p) = (int)strtol(c, &c, 0);                                                         \
         while (isspace(*c)) /* skip spaces */                                                   \
             ++c;                                                                                \
     } while (0)
diff --git a/src/mpid/ch3/src/ch3u_handle_recv_req.c b/src/mpid/ch3/src/ch3u_handle_recv_req.c
index 1ea9b52..0b9be5d 100644
--- a/src/mpid/ch3/src/ch3u_handle_recv_req.c
+++ b/src/mpid/ch3/src/ch3u_handle_recv_req.c
@@ -90,7 +90,7 @@ int MPIDI_CH3_ReqHandler_PutAccumRespComplete( MPIDI_VC_t *vc,
 
     /* Perform get in get-accumulate */
     if (rreq->dev.resp_request_handle != MPI_REQUEST_NULL) {
-        int type_size;
+        MPI_Aint type_size;
         MPIDI_CH3_Pkt_t upkt;
         MPIDI_CH3_Pkt_get_accum_resp_t *get_accum_resp_pkt = &upkt.get_accum_resp;
         MPID_Request *resp_req;
@@ -493,7 +493,8 @@ int MPIDI_CH3_ReqHandler_FOPComplete( MPIDI_VC_t *vc,
     MPID_Request *resp_req;
     MPID_Win *win_ptr;
     MPI_User_function *uop;
-    int len, one;
+    MPI_Aint len;
+    int one;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_REQHANDLER_FOPCOMPLETE);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_REQHANDLER_FOPCOMPLETE);
@@ -822,7 +823,8 @@ static int do_accumulate_op(MPID_Request *rreq)
         MPID_Segment *segp;
         DLOOP_VECTOR *dloop_vec;
         MPI_Aint first, last;
-        int vec_len, i, type_size, count;
+        int vec_len, i, count;
+        MPI_Aint type_size;
         MPI_Datatype type;
         MPID_Datatype *dtp;
         
@@ -860,7 +862,7 @@ static int do_accumulate_op(MPID_Request *rreq)
         MPID_Datatype_get_size_macro(type, type_size);
         for (i=0; i<vec_len; i++)
 	{
-            count = (dloop_vec[i].DLOOP_VECTOR_LEN)/type_size;
+            MPIU_Assign_trunc(count, (dloop_vec[i].DLOOP_VECTOR_LEN)/type_size, int);
             (*uop)((char *)rreq->dev.user_buf + MPIU_PtrToAint(dloop_vec[i].DLOOP_VECTOR_BUF),
                    (char *)rreq->dev.real_user_buf + MPIU_PtrToAint(dloop_vec[i].DLOOP_VECTOR_BUF),
                    &count, &type);
@@ -1171,7 +1173,8 @@ static int do_simple_get(MPID_Win *win_ptr, MPIDI_Win_lock_queue *lock_queue)
     MPIDI_CH3_Pkt_get_resp_t * get_resp_pkt = &upkt.get_resp;
     MPID_Request *req;
     MPID_IOV iov[MPID_IOV_LIMIT];
-    int type_size, mpi_errno=MPI_SUCCESS;
+    int mpi_errno=MPI_SUCCESS;
+    MPI_Aint type_size;
     MPIDI_STATE_DECL(MPID_STATE_DO_SIMPLE_GET);
     
     MPIDI_FUNC_ENTER(MPID_STATE_DO_SIMPLE_GET);
diff --git a/src/mpid/ch3/src/ch3u_request.c b/src/mpid/ch3/src/ch3u_request.c
index 86dff27..ef1779a 100644
--- a/src/mpid/ch3/src/ch3u_request.c
+++ b/src/mpid/ch3/src/ch3u_request.c
@@ -366,8 +366,8 @@ int MPIDI_CH3U_Request_load_recv_iov(MPID_Request * const rreq)
 				   rreq->dev.segment_first,
 				   &last, &rreq->dev.iov[0], &rreq->dev.iov_count);
 	MPIU_DBG_MSG_FMT(CH3_CHANNEL,VERBOSE,(MPIU_DBG_FDEST,
-   "post-upv: first=" MPIDI_MSG_SZ_FMT ", last=" MPIDI_MSG_SZ_FMT ", iov_n=%d, iov_offset=%d",
-			  rreq->dev.segment_first, last, rreq->dev.iov_count, rreq->dev.iov_offset));
+   "post-upv: first=" MPIDI_MSG_SZ_FMT ", last=" MPIDI_MSG_SZ_FMT ", iov_n=%d, iov_offset=%lld",
+			  rreq->dev.segment_first, last, rreq->dev.iov_count, (long long)rreq->dev.iov_offset));
 	MPIU_Assert(rreq->dev.iov_count >= 0 && rreq->dev.iov_count <= 
 		    MPID_IOV_LIMIT);
 
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index 0d51fc1..beb5a6c 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -488,7 +488,7 @@ static int create_datatype(const MPIDI_RMA_dtype_info *dtype_info,
     datatypes[0] = MPI_BYTE;
     
     displaces[1] = MPIU_PtrToAint(dataloop);
-    blocklens[1] = dataloop_sz;
+    MPIU_Assign_trunc(blocklens[1], dataloop_sz, int);
     datatypes[1] = MPI_BYTE;
     
     displaces[2] = MPIU_PtrToAint(o_addr);
@@ -554,7 +554,8 @@ static int MPIDI_CH3I_Send_rma_msg(MPIDI_RMA_Op_t *rma_op, MPID_Win *win_ptr,
     MPIDI_CH3_Pkt_accum_t *accum_pkt = &upkt.accum;
     MPID_IOV iov[MPID_IOV_LIMIT];
     int mpi_errno=MPI_SUCCESS;
-    int origin_dt_derived, target_dt_derived, origin_type_size, iovcnt; 
+    int origin_dt_derived, target_dt_derived, iovcnt;
+    MPI_Aint origin_type_size;
     MPIDI_VC_t * vc;
     MPID_Comm *comm_ptr;
     MPID_Datatype *target_dtp=NULL, *origin_dtp=NULL;
@@ -866,10 +867,11 @@ static int MPIDI_CH3I_Send_contig_acc_msg(MPIDI_RMA_Op_t *rma_op,
     MPIDI_CH3_Pkt_accum_t *accum_pkt = &upkt.accum;
     MPID_IOV iov[MPID_IOV_LIMIT];
     int mpi_errno=MPI_SUCCESS;
-    int origin_type_size, iovcnt; 
+    int iovcnt;
+    MPI_Aint origin_type_size;
     MPIDI_VC_t * vc;
     MPID_Comm *comm_ptr;
-    int len;
+    size_t len;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SEND_CONTIG_ACC_MSG);
 
     MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_SEND_CONTIG_ACC_MSG);
@@ -878,7 +880,7 @@ static int MPIDI_CH3I_Send_contig_acc_msg(MPIDI_RMA_Op_t *rma_op,
 
     MPID_Datatype_get_size_macro(rma_op->origin_datatype, origin_type_size);
     /* FIXME: Make this size check efficient and match the packet type */
-    len = rma_op->origin_count * origin_type_size;
+    MPIU_Assign_trunc(len, rma_op->origin_count * origin_type_size, size_t);
     if (MPIR_CVAR_CH3_RMA_ACC_IMMED && len <= MPIDI_RMA_IMMED_INTS*sizeof(int)) {
 	MPIDI_CH3_Pkt_accum_immed_t * accumi_pkt = &upkt.accum_immed;
 	void *dest = accumi_pkt->data, *src = rma_op->origin_addr;
@@ -981,7 +983,7 @@ static int MPIDI_CH3I_Send_immed_rmw_msg(MPIDI_RMA_Op_t *rma_op,
     MPID_Request *rmw_req = NULL, *resp_req = NULL;
     MPIDI_VC_t *vc;
     MPID_Comm *comm_ptr;
-    int len;
+    MPI_Aint len;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_SEND_IMMED_RMW_MSG);
 
     MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_SEND_IMMED_RMW_MSG);
@@ -2041,7 +2043,7 @@ int MPIDI_Win_unlock(int dest, MPID_Win *win_ptr)
 	 * do an optimization where the lock and the RMA operation are
 	 * sent in a single packet. Otherwise, we send a separate lock
 	 * request first. */
-        int type_size;
+        MPI_Aint type_size;
         MPIDI_VC_t *vc;
         MPIDI_RMA_Op_t *curr_op = rma_op;
 
@@ -2969,7 +2971,7 @@ static int MPIDI_CH3I_Send_lock_put_or_acc(MPID_Win *win_ptr, int target_rank)
     MPID_IOV iov[MPID_IOV_LIMIT];
     MPID_Comm *comm_ptr;
     MPID_Datatype *origin_dtp=NULL;
-    int origin_type_size;
+    MPI_Aint origin_type_size;
     MPIDI_CH3_Pkt_t upkt;
     MPIDI_CH3_Pkt_lock_put_unlock_t *lock_put_unlock_pkt = 
 	&upkt.lock_put_unlock;
@@ -3344,7 +3346,7 @@ int MPIDI_CH3_PktHandler_Put( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
 {
     MPIDI_CH3_Pkt_put_t * put_pkt = &pkt->put;
     MPID_Request *req = NULL;
-    int type_size;
+    MPI_Aint type_size;
     int complete = 0;
     char *data_buf = NULL;
     MPIDI_msg_sz_t data_len;
@@ -3514,7 +3516,7 @@ int MPIDI_CH3_PktHandler_Get( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
     MPIDI_msg_sz_t data_len;
     MPID_Win *win_ptr;
     int mpi_errno = MPI_SUCCESS;
-    int type_size;
+    MPI_Aint type_size;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_GET);
     
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_PKTHANDLER_GET);
@@ -3647,7 +3649,7 @@ int MPIDI_CH3_PktHandler_Accumulate( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
     MPIDI_msg_sz_t data_len;
     MPID_Win *win_ptr;
     int mpi_errno = MPI_SUCCESS;
-    int type_size;
+    MPI_Aint type_size;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_ACCUMULATE);
     
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_PKTHANDLER_ACCUMULATE);
@@ -3841,7 +3843,8 @@ int MPIDI_CH3_PktHandler_Accumulate_Immed( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
 	/* Data is already present */
 	if (accum_pkt->op == MPI_REPLACE) {
 	    /* no datatypes required */
-	    int len = accum_pkt->count * extent;
+            int len;
+            MPIU_Assign_trunc(len, (accum_pkt->count * extent), int);
 	    /* FIXME: use immediate copy because this is short */
 	    MPIUI_Memcpy( accum_pkt->addr, accum_pkt->data, len );
 	}
@@ -3899,7 +3902,7 @@ int MPIDI_CH3_PktHandler_CAS( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
     MPIDI_CH3_Pkt_cas_t *cas_pkt = &pkt->cas;
     MPID_Win *win_ptr;
     MPID_Request *req;
-    int len;
+    MPI_Aint len;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_CAS);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_PKTHANDLER_CAS);
@@ -3977,7 +3980,7 @@ int MPIDI_CH3_PktHandler_CASResp( MPIDI_VC_t *vc ATTRIBUTE((unused)),
     int mpi_errno = MPI_SUCCESS;
     MPIDI_CH3_Pkt_cas_resp_t *cas_resp_pkt = &pkt->cas_resp;
     MPID_Request *req;
-    int len;
+    MPI_Aint len;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_CASRESP);
     
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_PKTHANDLER_CASRESP);
@@ -4012,7 +4015,8 @@ int MPIDI_CH3_PktHandler_FOP( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
     MPIDI_CH3_Pkt_fop_t *fop_pkt = &pkt->fop;
     MPID_Request *req;
     MPID_Win *win_ptr;
-    int len, data_complete = 0;
+    int data_complete = 0;
+    MPI_Aint len;
     MPIU_CHKPMEM_DECL(1);
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_FOP);
 
@@ -4104,7 +4108,8 @@ int MPIDI_CH3_PktHandler_FOPResp( MPIDI_VC_t *vc ATTRIBUTE((unused)),
     int mpi_errno = MPI_SUCCESS;
     MPIDI_CH3_Pkt_fop_resp_t *fop_resp_pkt = &pkt->fop_resp;
     MPID_Request *req;
-    int len, complete = 0;
+    int complete = 0;
+    MPI_Aint len;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_FOPRESP);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_PKTHANDLER_FOPRESP);
@@ -4167,7 +4172,7 @@ int MPIDI_CH3_PktHandler_Get_AccumResp( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
     char *data_buf = NULL;
     MPIDI_msg_sz_t data_len;
     int mpi_errno = MPI_SUCCESS;
-    int type_size;
+    MPI_Aint type_size;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_GET_ACCUM_RESP);
 
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_PKTHANDLER_GET_ACCUM_RESP);
@@ -4295,7 +4300,7 @@ int MPIDI_CH3_PktHandler_LockPutUnlock( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
 	&pkt->lock_put_unlock;
     MPID_Win *win_ptr = NULL;
     MPID_Request *req = NULL;
-    int type_size;
+    MPI_Aint type_size;
     int complete;
     char *data_buf = NULL;
     MPIDI_msg_sz_t data_len;
@@ -4442,7 +4447,7 @@ int MPIDI_CH3_PktHandler_LockGetUnlock( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
     MPIDI_CH3_Pkt_lock_get_unlock_t * lock_get_unlock_pkt = 
 	&pkt->lock_get_unlock;
     MPID_Win *win_ptr = NULL;
-    int type_size;
+    MPI_Aint type_size;
     int mpi_errno = MPI_SUCCESS;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_LOCKGETUNLOCK);
     
@@ -4561,7 +4566,7 @@ int MPIDI_CH3_PktHandler_LockAccumUnlock( MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt,
     MPID_Request *req = NULL;
     MPID_Win *win_ptr = NULL;
     MPIDI_Win_lock_queue *curr_ptr = NULL, *prev_ptr = NULL, *new_ptr = NULL;
-    int type_size;
+    MPI_Aint type_size;
     int complete;
     char *data_buf = NULL;
     MPIDI_msg_sz_t data_len;
@@ -4695,7 +4700,7 @@ int MPIDI_CH3_PktHandler_GetResp( MPIDI_VC_t *vc ATTRIBUTE((unused)),
     char *data_buf = NULL;
     MPIDI_msg_sz_t data_len;
     int mpi_errno = MPI_SUCCESS;
-    int type_size;
+    MPI_Aint type_size;
     MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_PKTHANDLER_GETRESP);
     
     MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_PKTHANDLER_GETRESP);
diff --git a/src/mpid/ch3/src/mpid_vc.c b/src/mpid/ch3/src/mpid_vc.c
index 73b4796..5640966 100644
--- a/src/mpid/ch3/src/mpid_vc.c
+++ b/src/mpid/ch3/src/mpid_vc.c
@@ -919,7 +919,7 @@ static int parse_mapping(char *map_str, mapping_type_t *type, map_block_t **map,
 
         if (!isdigit(*c))
             parse_error();
-        (*map)[i].start_id = strtol(c, &c, 0);
+        (*map)[i].start_id = (int)strtol(c, &c, 0);
         skip_space(c);
 
         expect_and_skip_c(c, ',');
@@ -927,7 +927,7 @@ static int parse_mapping(char *map_str, mapping_type_t *type, map_block_t **map,
 
         if (!isdigit(*c))
             parse_error();
-        (*map)[i].count = strtol(c, &c, 0);
+        (*map)[i].count = (int)strtol(c, &c, 0);
         skip_space(c);
 
         expect_and_skip_c(c, ',');
@@ -935,7 +935,7 @@ static int parse_mapping(char *map_str, mapping_type_t *type, map_block_t **map,
 
         if (!isdigit(*c))
             parse_error();
-        (*map)[i].size = strtol(c, &c, 0);
+        (*map)[i].size = (int)strtol(c, &c, 0);
 
         expect_and_skip_c(c, ')');
         skip_space(c);
diff --git a/src/mpid/ch3/src/mpidi_isend_self.c b/src/mpid/ch3/src/mpidi_isend_self.c
index 9460c8e..0658630 100644
--- a/src/mpid/ch3/src/mpidi_isend_self.c
+++ b/src/mpid/ch3/src/mpidi_isend_self.c
@@ -85,7 +85,7 @@ int MPIDI_Isend_self(const void * buf, int count, MPI_Datatype datatype, int ran
     {
 	if (type != MPIDI_REQUEST_TYPE_RSEND)
 	{
-	    int dt_sz;
+	    MPI_Aint dt_sz;
 	
 	    /* FIXME: Insert code here to buffer small sends in a temporary buffer? */
 
diff --git a/src/mpid/common/datatype/dataloop/segment_packunpack.c b/src/mpid/common/datatype/dataloop/segment_packunpack.c
index 32c4689..7446b59 100644
--- a/src/mpid/common/datatype/dataloop/segment_packunpack.c
+++ b/src/mpid/common/datatype/dataloop/segment_packunpack.c
@@ -166,8 +166,8 @@ int PREPEND_PREFIX(Segment_vector_m2m)(DLOOP_Offset *blocks_p,
     cbufp = (char*) paramp->userbuf + rel_off;
     DLOOP_Handle_get_size_macro(el_type, el_size);
 
-    whole_count = (blksz > 0) ? (*blocks_p / (DLOOP_Offset) blksz) : 0;
-    blocks_left = (blksz > 0) ? (*blocks_p % (DLOOP_Offset) blksz) : 0;
+    whole_count = (DLOOP_Count)((blksz > 0) ? (*blocks_p / (DLOOP_Offset) blksz) : 0);
+    blocks_left = (DLOOP_Count)((blksz > 0) ? (*blocks_p % (DLOOP_Offset) blksz) : 0);
 
     if (paramp->direction == DLOOP_M2M_TO_USERBUF) {
 	if (el_size == 8
diff --git a/src/mpid/common/datatype/dataloop/veccpy.h b/src/mpid/common/datatype/dataloop/veccpy.h
index 687320c..7ee6592 100644
--- a/src/mpid/common/datatype/dataloop/veccpy.h
+++ b/src/mpid/common/datatype/dataloop/veccpy.h
@@ -57,23 +57,26 @@
     register int k;                                             \
     register unsigned long _i, j;                               \
     unsigned long total_count = count * nelms;                  \
-    const DLOOP_Offset l_stride = stride;				\
+    const DLOOP_Offset l_stride = stride;                       \
                                                                 \
+    DLOOP_Assert(stride <= INT_MAX);                            \
+    DLOOP_Assert(total_count <= INT_MAX);                       \
+    DLOOP_Assert(nelms <= INT_MAX);                             \
     if (nelms == 1) {                                           \
-        for (_i = total_count; _i; _i--) {			        \
+        for (_i = (int)total_count; _i; _i--) {                 \
             *l_dest++ = *l_src;				        \
             l_src += l_stride;                                  \
         }							\
     }                                                           \
     else if (nelms == 2) {                                      \
-        for (_i = total_count; _i; _i -= 2) {			\
+        for (_i = (int)total_count; _i; _i -= 2) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             l_src += l_stride;                                  \
         }							\
     }                                                           \
     else if (nelms == 3) {                                      \
-        for (_i = total_count; _i; _i -= 3) {			\
+        for (_i = (int)total_count; _i; _i -= 3) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -81,7 +84,7 @@
         }							\
     }                                                           \
     else if (nelms == 4) {                                      \
-        for (_i = total_count; _i; _i -= 4) {			\
+        for (_i = (int)total_count; _i; _i -= 4) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -90,7 +93,7 @@
         }							\
     }                                                           \
     else if (nelms == 5) {                                      \
-        for (_i = total_count; _i; _i -= 5) {			\
+        for (_i = (int)total_count; _i; _i -= 5) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -100,7 +103,7 @@
         }							\
     }                                                           \
     else if (nelms == 6) {                                      \
-        for (_i = total_count; _i; _i -= 6) {			\
+        for (_i = (int)total_count; _i; _i -= 6) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -111,7 +114,7 @@
         }							\
     }                                                           \
     else if (nelms == 7) {                                      \
-        for (_i = total_count; _i; _i -= 7) {			\
+        for (_i = (int)total_count; _i; _i -= 7) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -123,7 +126,7 @@
         }							\
     }                                                           \
     else if (nelms == 8) {                                      \
-        for (_i = total_count; _i; _i -= 8) {			\
+        for (_i = (int)total_count; _i; _i -= 8) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -136,10 +139,10 @@
         }							\
     }                                                           \
     else {                                                      \
-        _i = total_count;                                        \
+        _i = (int)total_count;                                  \
         while (_i) {                                             \
             tmp_src = l_src;                                    \
-            j = nelms;                                          \
+            j = (int)nelms;                                     \
             while (j >= 8) {                                    \
                 *l_dest++ = tmp_src[0];				\
                 *l_dest++ = tmp_src[1];				\
@@ -171,21 +174,24 @@
     register unsigned long _i, j, total_count = count * nelms;          \
     const DLOOP_Offset l_stride = stride;				\
                                                                 \
+    DLOOP_Assert(stride <= INT_MAX);                            \
+    DLOOP_Assert(total_count <= INT_MAX);                       \
+    DLOOP_Assert(nelms <= INT_MAX);                             \
     if (nelms == 1) {                                           \
-        for (_i = total_count; _i; _i--) {			        \
+        for (_i = (int)total_count; _i; _i--) {                 \
             *l_dest++ = *l_src;				        \
             l_src = (type *) ((char *) l_src + l_stride);	\
         }							\
     }                                                           \
     else if (nelms == 2) {                                      \
-        for (_i = total_count; _i; _i -= 2) {			\
+        for (_i = (int)total_count; _i; _i -= 2) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             l_src = (type *) ((char *) l_src + l_stride);	\
         }							\
     }                                                           \
     else if (nelms == 3) {                                      \
-        for (_i = total_count; _i; _i -= 3) {			\
+        for (_i = (int)total_count; _i; _i -= 3) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -193,7 +199,7 @@
         }							\
     }                                                           \
     else if (nelms == 4) {                                      \
-        for (_i = total_count; _i; _i -= 4) {			\
+        for (_i = (int)total_count; _i; _i -= 4) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -202,7 +208,7 @@
         }							\
     }                                                           \
     else if (nelms == 5) {                                      \
-        for (_i = total_count; _i; _i -= 5) {			\
+        for (_i = (int)total_count; _i; _i -= 5) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -212,7 +218,7 @@
         }							\
     }                                                           \
     else if (nelms == 6) {                                      \
-        for (_i = total_count; _i; _i -= 6) {			\
+        for (_i = (int)total_count; _i; _i -= 6) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -223,7 +229,7 @@
         }							\
     }                                                           \
     else if (nelms == 7) {                                      \
-        for (_i = total_count; _i; _i -= 7) {			\
+        for (_i = (int)total_count; _i; _i -= 7) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -235,7 +241,7 @@
         }							\
     }                                                           \
     else if (nelms == 8) {                                      \
-        for (_i = total_count; _i; _i -= 8) {			\
+        for (_i = (int)total_count; _i; _i -= 8) {              \
             *l_dest++ = l_src[0];				\
             *l_dest++ = l_src[1];				\
             *l_dest++ = l_src[2];				\
@@ -248,10 +254,10 @@
         }							\
     }                                                           \
     else {                                                      \
-        _i = total_count;                                        \
+        _i = (int)total_count;                                  \
         while (_i) {                                             \
             tmp_src = l_src;                                    \
-            j = nelms;                                          \
+            j = (int)nelms;                                     \
             while (j >= 8) {                                    \
                 *l_dest++ = tmp_src[0];				\
                 *l_dest++ = tmp_src[1];				\
@@ -284,21 +290,24 @@
     unsigned long total_count = count * nelms;                  \
     const DLOOP_Offset l_stride = stride;				\
                                                                 \
+    DLOOP_Assert(stride <= INT_MAX);                            \
+    DLOOP_Assert(total_count <= INT_MAX);                       \
+    DLOOP_Assert(nelms <= INT_MAX);                             \
     if (nelms == 1) {                                           \
-        for (_i = total_count; _i; _i--) {			        \
+        for (_i = (int)total_count; _i; _i--) {                 \
             *l_dest = *l_src++;				        \
             l_dest += l_stride;                                 \
         }							\
     }                                                           \
     else if (nelms == 2) {                                      \
-        for (_i = total_count; _i; _i -= 2) {			\
+        for (_i = (int)total_count; _i; _i -= 2) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest += l_stride;                                 \
         }							\
     }                                                           \
     else if (nelms == 3) {                                      \
-        for (_i = total_count; _i; _i -= 3) {			\
+        for (_i = (int)total_count; _i; _i -= 3) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -306,7 +315,7 @@
         }							\
     }                                                           \
     else if (nelms == 4) {                                      \
-        for (_i = total_count; _i; _i -= 4) {			\
+        for (_i = (int)total_count; _i; _i -= 4) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -315,7 +324,7 @@
         }							\
     }                                                           \
     else if (nelms == 5) {                                      \
-        for (_i = total_count; _i; _i -= 5) {			\
+        for (_i = (int)total_count; _i; _i -= 5) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -325,7 +334,7 @@
         }							\
     }                                                           \
     else if (nelms == 6) {                                      \
-        for (_i = total_count; _i; _i -= 6) {			\
+        for (_i = (int)total_count; _i; _i -= 6) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -336,7 +345,7 @@
         }							\
     }                                                           \
     else if (nelms == 7) {                                      \
-        for (_i = total_count; _i; _i -= 7) {			\
+        for (_i = (int)total_count; _i; _i -= 7) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -348,7 +357,7 @@
         }							\
     }                                                           \
     else if (nelms == 8) {                                      \
-        for (_i = total_count; _i; _i -= 8) {			\
+        for (_i = (int)total_count; _i; _i -= 8) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -361,10 +370,10 @@
         }							\
     }                                                           \
     else {                                                      \
-        _i = total_count;                                        \
+        _i = (int)total_count;                                  \
         while (_i) {                                             \
             tmp_dest = l_dest;                                  \
-            j = nelms;                                          \
+            j = (int)nelms;                                     \
             while (j >= 8) {                                    \
                 tmp_dest[0] = *l_src++;				\
                 tmp_dest[1] = *l_src++;				\
@@ -395,23 +404,26 @@
     register int k;                                             \
     register unsigned long _i, j;                               \
     unsigned long total_count = count * nelms;                  \
-    const DLOOP_Offset l_stride = stride;				\
+    const DLOOP_Offset l_stride = stride;                       \
                                                                 \
+    DLOOP_Assert(stride <= INT_MAX);                            \
+    DLOOP_Assert(total_count <= INT_MAX);                       \
+    DLOOP_Assert(nelms <= INT_MAX);                             \
     if (nelms == 1) {                                           \
-        for (_i = total_count; _i; _i--) {			        \
+        for (_i = (int)total_count; _i; _i--) {                 \
             *l_dest = *l_src++;				        \
             l_dest = (type *) ((char *) l_dest + l_stride);	\
         }							\
     }                                                           \
     else if (nelms == 2) {                                      \
-        for (_i = total_count; _i; _i -= 2) {			\
+        for (_i = (int)total_count; _i; _i -= 2) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest = (type *) ((char *) l_dest + l_stride);	\
         }							\
     }                                                           \
     else if (nelms == 3) {                                      \
-        for (_i = total_count; _i; _i -= 3) {			\
+        for (_i = (int)total_count; _i; _i -= 3) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -419,7 +431,7 @@
         }							\
     }                                                           \
     else if (nelms == 4) {                                      \
-        for (_i = total_count; _i; _i -= 4) {			\
+        for (_i = (int)total_count; _i; _i -= 4) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -428,7 +440,7 @@
         }							\
     }                                                           \
     else if (nelms == 5) {                                      \
-        for (_i = total_count; _i; _i -= 5) {			\
+        for (_i = (int)total_count; _i; _i -= 5) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -438,7 +450,7 @@
         }							\
     }                                                           \
     else if (nelms == 6) {                                      \
-        for (_i = total_count; _i; _i -= 6) {			\
+        for (_i = (int)total_count; _i; _i -= 6) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -449,7 +461,7 @@
         }							\
     }                                                           \
     else if (nelms == 7) {                                      \
-        for (_i = total_count; _i; _i -= 7) {			\
+        for (_i = (int)total_count; _i; _i -= 7) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -461,7 +473,7 @@
         }							\
     }                                                           \
     else if (nelms == 8) {                                      \
-        for (_i = total_count; _i; _i -= 8) {			\
+        for (_i = (int)total_count; _i; _i -= 8) {              \
             l_dest[0] = *l_src++;				\
             l_dest[1] = *l_src++;				\
             l_dest[2] = *l_src++;				\
@@ -474,10 +486,10 @@
         }							\
     }                                                           \
     else {                                                      \
-        _i = total_count;                                        \
+        _i = (int)total_count;                                  \
         while (_i) {                                             \
             tmp_dest = l_dest;                                  \
-            j = nelms;                                          \
+            j = (int)nelms;                                     \
             while (j >= 8) {                                    \
                 tmp_dest[0] = *l_src++;				\
                 tmp_dest[1] = *l_src++;				\
diff --git a/src/mpid/common/datatype/mpid_datatype.h b/src/mpid/common/datatype/mpid_datatype.h
index 22041b2..84ad551 100644
--- a/src/mpid/common/datatype/mpid_datatype.h
+++ b/src/mpid/common/datatype/mpid_datatype.h
@@ -358,7 +358,7 @@ typedef struct MPID_Datatype {
     MPIU_OBJECT_HEADER; /* adds handle and ref_count fields */
 
     /* basic parameters for datatype, accessible via MPI calls */
-    int      size;
+    MPI_Aint size;
     MPI_Aint extent, ub, lb, true_ub, true_lb;
 
     /* chars affecting subsequent datatype processing and creation */
diff --git a/src/mpid/common/datatype/mpid_type_indexed.c b/src/mpid/common/datatype/mpid_type_indexed.c
index 48d4642..0e3e259 100644
--- a/src/mpid/common/datatype/mpid_type_indexed.c
+++ b/src/mpid/common/datatype/mpid_type_indexed.c
@@ -41,7 +41,8 @@ int MPID_Type_indexed(int count,
     int mpi_errno = MPI_SUCCESS;
     int is_builtin, old_is_contig;
     int i, contig_count;
-    int el_sz, el_ct, old_ct, old_sz;
+    int el_ct, old_ct;
+    MPI_Aint el_sz, old_sz;
     MPI_Aint old_lb, old_ub, old_extent, old_true_lb, old_true_ub;
     MPI_Aint min_lb = 0, max_ub = 0, eff_disp;
     MPI_Datatype el_type;
@@ -109,8 +110,8 @@ int MPID_Type_indexed(int count,
 	new_dtp->has_sticky_ub = 0;
 	new_dtp->has_sticky_lb = 0;
 
-	new_dtp->alignsize    = el_sz; /* ??? */
-	new_dtp->element_size = (MPI_Aint) el_sz;
+        MPIU_Assign_trunc(new_dtp->alignsize, el_sz, int);
+	new_dtp->element_size = el_sz;
 	new_dtp->eltype       = el_type;
 
 	new_dtp->max_contig_blocks = count;
diff --git a/src/mpid/common/sched/mpid_sched.c b/src/mpid/common/sched/mpid_sched.c
index a07e8e1..d44412a 100644
--- a/src/mpid/common/sched/mpid_sched.c
+++ b/src/mpid/common/sched/mpid_sched.c
@@ -122,7 +122,7 @@ fn_fail:
 /* initiates the schedule entry "e" in the NBC described by "s", where
  * "e" is at "idx" in "s".  This means posting nonblocking sends/recvs,
  * performing reductions, calling callbacks, etc. */
-static int MPIDU_Sched_start_entry(struct MPIDU_Sched *s, int idx, struct MPIDU_Sched_entry *e)
+static int MPIDU_Sched_start_entry(struct MPIDU_Sched *s, size_t idx, struct MPIDU_Sched_entry *e)
 {
     int mpi_errno = MPI_SUCCESS;
     int context_offset;
@@ -237,7 +237,7 @@ fn_fail:
 static int MPIDU_Sched_continue(struct MPIDU_Sched *s)
 {
     int mpi_errno = MPI_SUCCESS;
-    int i;
+    size_t i;
 
     for (i = s->idx; i < s->num_entries; ++i) {
         struct MPIDU_Sched_entry *e = &s->entries[i];
@@ -680,12 +680,12 @@ int MPID_Sched_copy(const void *inbuf,  int incount,  MPI_Datatype intype,
     /* some sanity checking up front */
 #if defined(HAVE_ERROR_CHECKING) && !defined(NDEBUG)
     {
-        int intype_size, outtype_size;
+        MPI_Aint intype_size, outtype_size;
         MPID_Datatype_get_size_macro(intype, intype_size);
         MPID_Datatype_get_size_macro(outtype, outtype_size);
         if (incount * intype_size > outcount * outtype_size) {
-            MPIU_Error_printf("truncation: intype=%#x, intype_size=%d, incount=%d, outtype=%#x, outtype_size=%d outcount=%d\n",
-                              intype, intype_size, incount, outtype, outtype_size, outcount);
+            MPIU_Error_printf("truncation: intype=%#x, intype_size=%lld, incount=%d, outtype=%#x, outtype_size=%lld outcount=%d\n",
+                              intype, (long long)intype_size, incount, outtype, (long long)outtype_size, outcount);
         }
     }
 #endif
@@ -787,7 +787,7 @@ fn_fail:
 static int MPIDU_Sched_progress_state(struct MPIDU_Sched_state *state, int *made_progress)
 {
     int mpi_errno = MPI_SUCCESS;
-    int i;
+    size_t i;
     struct MPIDU_Sched *s;
     struct MPIDU_Sched *tmp;
 
diff --git a/src/util/dbg/dbg_printf.c b/src/util/dbg/dbg_printf.c
index 0810ca0..dc674ee 100644
--- a/src/util/dbg/dbg_printf.c
+++ b/src/util/dbg/dbg_printf.c
@@ -625,7 +625,7 @@ static int MPIU_DBG_ProcessArgs( int *argc_p, char ***argv_p )
 		    if (*p == '=' && p[1] != 0) {
 			char *sOut;
 			p++;
-			whichRank = strtol( p, &sOut, 10 );
+			whichRank = (int)strtol( p, &sOut, 10 );
 			if (p == sOut) {
 			    MPIU_DBG_Usage( "-mpich-dbg-rank", 0 );
 			    whichRank = -1;
@@ -678,7 +678,7 @@ static int MPIU_DBG_ProcessEnv( void )
     s = getenv( "MPICH_DBG_RANK" );
     if (s) {
 	char *sOut;
-	whichRank = strtol( s, &sOut, 10 );
+	whichRank = (int)strtol( s, &sOut, 10 );
 	if (s == sOut) {
 	    MPIU_DBG_Usage( "MPICH_DBG_RANK", 0 );
 	    whichRank = -1;
@@ -1129,17 +1129,17 @@ static int MPIU_DBG_OpenFile(FILE **dbg_fp)
 static int setDBGClass( const char *s )
 {
     int i;
-    int slen = 0;
-    int len = 0;
-	    
+    size_t slen = 0;
+    size_t len = 0;
+
     if (s && *s) slen = strlen(s);
 
     while (s && *s) {
 	for (i=0; MPIU_Classnames[i].LCName; i++) {
 	    /* The LCLen and UCLen *should* be the same, but
 	       just in case, we separate them */
-	    int LClen = strlen(MPIU_Classnames[i].LCName);
-	    int UClen = strlen(MPIU_Classnames[i].UCName);
+	    size_t LClen = strlen(MPIU_Classnames[i].LCName);
+	    size_t UClen = strlen(MPIU_Classnames[i].UCName);
 	    int matchClass = 0;
 
 	    /* Allow the upper case and lower case in all cases */
diff --git a/src/util/instrm/instr.c b/src/util/instrm/instr.c
index cf94ed4..340cc3a 100644
--- a/src/util/instrm/instr.c
+++ b/src/util/instrm/instr.c
@@ -116,7 +116,7 @@ int MPIU_INSTR_ToStr_Duration_Count( char *buf, size_t maxBuf, void *ptr )
     snprintf( buf, maxBuf, "%-40s:\t%d\t%e", dPtr->desc, dPtr->count, ttime );
     if (dPtr->nitems) {
 	char *p;
-	int  len = strlen(buf);
+	size_t  len = strlen(buf);
 	int  i;
 	/* Add each integer value, separated by a tab. */
 	maxBuf -= len;
diff --git a/src/util/wrappers/mpiu_shm_wrappers.h b/src/util/wrappers/mpiu_shm_wrappers.h
index 5e6335b..0e132c0 100644
--- a/src/util/wrappers/mpiu_shm_wrappers.h
+++ b/src/util/wrappers/mpiu_shm_wrappers.h
@@ -301,7 +301,7 @@ fn_fail:
 #undef FCNAME
 #define FCNAME MPIU_QUOTE(FUNCNAME)
 static inline int MPIU_SHMW_Hnd_deserialize(
-    MPIU_SHMW_Hnd_t hnd, const char *str_hnd, int str_hnd_len)
+    MPIU_SHMW_Hnd_t hnd, const char *str_hnd, size_t str_hnd_len)
 {
     int mpi_errno = MPI_SUCCESS;
     int rc = -1;
@@ -615,7 +615,7 @@ static inline int MPIU_SHMW_Seg_create_attach_templ(
             MPI_ERR_OTHER, "**lseek", "**lseek %s",
             MPIU_OSW_Strerror(MPIU_OSW_Get_errno()));
 
-        MPIU_OSW_RETRYON_INTR((rc == -1), (rc = write(lhnd, "", 1)));
+        MPIU_OSW_RETRYON_INTR((rc == -1), (rc = (int)write(lhnd, "", 1)));
         MPIU_ERR_CHKANDJUMP((rc == -1), mpi_errno, MPI_ERR_OTHER,
             "**write");
 

-----------------------------------------------------------------------

Summary of changes:
 configure.ac                                       |   48 +++++-----
 src/include/mpibsend.h                             |    2 +-
 src/include/mpierrs.h                              |    2 +-
 src/include/mpiimpl.h                              |    6 +-
 src/include/mpiutil.h                              |   37 +++++---
 src/mpi/coll/allred_group.c                        |    2 +-
 src/mpi/coll/allreduce.c                           |    3 +-
 src/mpi/coll/alltoall.c                            |    3 +-
 src/mpi/coll/bcast.c                               |   26 +++---
 src/mpi/coll/helper_fns.c                          |    4 +-
 src/mpi/coll/ibcast.c                              |   10 ++-
 src/mpi/datatype/pack.c                            |    9 ++-
 src/mpi/datatype/pack_size.c                       |   10 ++-
 src/mpi/datatype/type_match_size.c                 |    3 +-
 src/mpi/datatype/unpack.c                          |    7 +-
 src/mpi/pt2pt/bsendutil.c                          |    7 +-
 src/mpi/pt2pt/sendrecv_rep.c                       |    4 +-
 src/mpi/romio/adio/ad_bg/ad_bg.h                   |    2 +-
 src/mpi/romio/adio/ad_bg/ad_bg_getsh.c             |    2 +-
 src/mpi/romio/adio/ad_bgl/ad_bgl.h                 |    2 +-
 src/mpi/romio/adio/ad_bgl/ad_bgl_getsh.c           |    2 +-
 src/mpi/romio/adio/ad_nfs/ad_nfs.h                 |    2 +-
 src/mpi/romio/adio/ad_nfs/ad_nfs_getsh.c           |    4 +-
 src/mpi/romio/adio/ad_nfs/ad_nfs_setsh.c           |    2 +-
 src/mpi/romio/adio/ad_testfs/ad_testfs_seek.c      |    4 +-
 src/mpi/romio/adio/common/ad_coll_exch_new.c       |    6 +-
 src/mpi/romio/adio/common/ad_fstype.c              |    2 +-
 src/mpi/romio/adio/common/ad_get_sh_fp.c           |    4 +-
 src/mpi/romio/adio/common/ad_io_coll.c             |    4 +-
 src/mpi/romio/adio/common/ad_iwrite.c              |    7 +-
 src/mpi/romio/adio/common/ad_prealloc.c            |   10 +-
 src/mpi/romio/adio/common/ad_read.c                |    6 +-
 src/mpi/romio/adio/common/ad_read_coll.c           |   10 +-
 src/mpi/romio/adio/common/ad_read_str.c            |    6 +-
 src/mpi/romio/adio/common/ad_read_str_naive.c      |    2 +-
 src/mpi/romio/adio/common/ad_set_view.c            |    2 +-
 src/mpi/romio/adio/common/ad_write.c               |    4 +-
 src/mpi/romio/adio/common/ad_write_coll.c          |    9 ++-
 src/mpi/romio/adio/common/ad_write_nolock.c        |    9 +-
 src/mpi/romio/adio/common/ad_write_str.c           |   19 +++--
 src/mpi/romio/adio/common/ad_write_str_naive.c     |    8 +-
 src/mpi/romio/adio/common/byte_offset.c            |    4 +-
 src/mpi/romio/adio/common/cb_config_list.c         |    2 +-
 src/mpi/romio/adio/common/eof_offset.c             |    4 +-
 src/mpi/romio/adio/common/flatten.c                |   59 ++++++-------
 src/mpi/romio/adio/common/get_fp_posn.c            |    6 +-
 src/mpi/romio/adio/common/hint_fns.c               |    3 +-
 src/mpi/romio/adio/common/shfp_fname.c             |    6 +-
 src/mpi/romio/adio/common/status_setb.c            |    6 +-
 src/mpi/romio/adio/common/system_hints.c           |    3 +-
 src/mpi/romio/adio/include/adio.h                  |    4 +-
 src/mpi/romio/adio/include/adioi.h                 |    8 +-
 src/mpi/romio/adio/include/adioi_error.h           |    2 +-
 src/mpi/romio/mpi-io/iread.c                       |    8 +-
 src/mpi/romio/mpi-io/iread_sh.c                    |    7 +-
 src/mpi/romio/mpi-io/iwrite.c                      |    8 +-
 src/mpi/romio/mpi-io/iwrite_sh.c                   |    7 +-
 src/mpi/romio/mpi-io/read.c                        |    8 +-
 src/mpi/romio/mpi-io/read_all.c                    |    5 +-
 src/mpi/romio/mpi-io/read_allb.c                   |    5 +-
 src/mpi/romio/mpi-io/read_ord.c                    |    6 +-
 src/mpi/romio/mpi-io/read_ordb.c                   |    7 +-
 src/mpi/romio/mpi-io/read_sh.c                     |    8 +-
 src/mpi/romio/mpi-io/set_view.c                    |    7 +-
 src/mpi/romio/mpi-io/write.c                       |    8 +-
 src/mpi/romio/mpi-io/write_all.c                   |    5 +-
 src/mpi/romio/mpi-io/write_allb.c                  |    5 +-
 src/mpi/romio/mpi-io/write_ord.c                   |    6 +-
 src/mpi/romio/mpi-io/write_ordb.c                  |    6 +-
 src/mpi/romio/mpi-io/write_sh.c                    |    7 +-
 src/mpi_t/mpit.c                                   |    2 +-
 .../channels/nemesis/include/mpid_nem_datatypes.h  |   14 +--
 .../ch3/channels/nemesis/include/mpid_nem_inline.h |    4 +-
 .../channels/nemesis/include/mpid_nem_pkt_header.h |   25 +++++
 src/mpid/ch3/channels/nemesis/netmod/mx/mx_poll.c  |    2 +-
 .../channels/nemesis/netmod/newmad/newmad_poll.c   |    2 +-
 src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.c  |   27 ++++--
 src/mpid/ch3/channels/nemesis/netmod/tcp/socksm.h  |    2 +-
 .../ch3/channels/nemesis/netmod/tcp/tcp_utility.c  |    3 +-
 src/mpid/ch3/channels/nemesis/src/ch3_isend.c      |    3 +-
 src/mpid/ch3/channels/nemesis/src/ch3_istartmsg.c  |    3 +-
 src/mpid/ch3/channels/nemesis/src/ch3_progress.c   |    4 +-
 src/mpid/ch3/channels/nemesis/src/ch3_win_fns.c    |    2 +-
 src/mpid/ch3/channels/nemesis/src/mpid_nem_debug.c |    2 +-
 src/mpid/ch3/channels/nemesis/src/mpid_nem_init.c  |    2 +-
 .../ch3/channels/nemesis/src/mpid_nem_lmt_shm.c    |    2 +-
 src/mpid/ch3/channels/nemesis/subconfigure.m4      |   17 ++++
 src/mpid/ch3/include/mpidpre.h                     |    2 +-
 src/mpid/ch3/include/mpidrma.h                     |   13 ++-
 src/mpid/ch3/src/ch3u_buffer.c                     |    2 +-
 src/mpid/ch3/src/ch3u_eager.c                      |    2 +-
 src/mpid/ch3/src/ch3u_handle_connection.c          |    2 +-
 src/mpid/ch3/src/ch3u_handle_recv_pkt.c            |    2 +-
 src/mpid/ch3/src/ch3u_handle_recv_req.c            |   13 ++-
 src/mpid/ch3/src/ch3u_request.c                    |   14 ++--
 src/mpid/ch3/src/ch3u_rma_sync.c                   |   47 ++++++-----
 src/mpid/ch3/src/mpid_vc.c                         |    6 +-
 src/mpid/ch3/src/mpidi_isend_self.c                |    4 +-
 src/mpid/common/datatype/Makefile.mk               |    3 +-
 src/mpid/common/datatype/dataloop/dataloop.c       |   34 ++++----
 .../common/datatype/dataloop/dataloop_create.c     |   22 ++++--
 .../common/datatype/dataloop/dataloop_create.h     |   35 ++++----
 .../dataloop/dataloop_create_blockindexed.c        |   13 ++--
 .../datatype/dataloop/dataloop_create_contig.c     |   11 ++-
 .../datatype/dataloop/dataloop_create_indexed.c    |   24 +++---
 .../datatype/dataloop/dataloop_create_pairtype.c   |    2 +-
 .../datatype/dataloop/dataloop_create_struct.c     |   56 +++++++-----
 .../datatype/dataloop/dataloop_create_vector.c     |   14 ++--
 src/mpid/common/datatype/dataloop/dataloop_parts.h |   22 +++--
 src/mpid/common/datatype/dataloop/segment.c        |    4 +-
 .../common/datatype/dataloop/segment_flatten.c     |   39 +++++----
 .../common/datatype/dataloop/segment_packunpack.c  |    4 +-
 src/mpid/common/datatype/dataloop/veccpy.h         |   96 +++++++++++---------
 src/mpid/common/datatype/mpid_dataloop.h           |    3 +-
 src/mpid/common/datatype/mpid_datatype.h           |   42 +++++----
 src/mpid/common/datatype/mpid_segment.c            |   31 ++++---
 src/mpid/common/datatype/mpid_type_blockindexed.c  |    3 +-
 src/mpid/common/datatype/mpid_type_contiguous.c    |    2 +-
 .../common/datatype/mpid_type_create_resized.c     |    2 +
 src/mpid/common/datatype/mpid_type_debug.c         |    6 +-
 src/mpid/common/datatype/mpid_type_indexed.c       |   15 ++-
 src/mpid/common/datatype/mpid_type_struct.c        |    9 +-
 src/mpid/common/datatype/mpir_type_flatten.c       |    2 +-
 .../common/datatype/mpir_type_get_contig_blocks.c  |   41 ---------
 src/mpid/common/sched/mpid_sched.c                 |   12 ++--
 src/mpl/src/mplstr.c                               |    6 +-
 src/pm/hydra/ui/mpich/utils.c                      |    7 +-
 src/util/dbg/dbg_printf.c                          |   14 ++--
 src/util/instrm/instr.c                            |    2 +-
 src/util/wrappers/mpiu_shm_wrappers.h              |    4 +-
 130 files changed, 730 insertions(+), 604 deletions(-)
 create mode 100644 src/mpid/ch3/channels/nemesis/include/mpid_nem_pkt_header.h
 delete mode 100644 src/mpid/common/datatype/mpir_type_get_contig_blocks.c


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list