[mpich2-dev] [PATCH 1/1] Issue 4120: Always treat MPI_Aint as signed
Jeff Parker
jjparker at us.ibm.com
Wed Mar 26 12:45:50 CDT 2008
Remove casts to (unsigned long) when casting to MPI_Aint. These (unsigned long)
casts were added under the assumption that certain variables (sizes, lengths)
would be positive, but that is not necessarily the case. Better to just let
the sign extension happen.
Signed-off-by: Jeff Parker <jjparker at us.ibm.com>
---
lib/mpi/mpich2/src/include/mpiutil.h | 4 +-
lib/mpi/mpich2/src/mpi/attr/attr_get.c | 9 +++--
lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c | 9 +++--
lib/mpi/mpich2/src/mpi/attr/type_get_attr.c | 9 +++--
lib/mpi/mpich2/src/mpi/attr/win_get_attr.c | 9 +++--
lib/mpi/mpich2/src/mpi/datatype/pack.c | 4 +-
.../mpich2/src/mpi/datatype/type_create_darray.c | 26 ++++++++--------
.../mpich2/src/mpi/datatype/type_create_subarray.c | 26 ++++++++--------
lib/mpi/mpich2/src/mpi/datatype/unpack.c | 4 +-
.../src/mpid/common/datatype/dataloop/dataloop.c | 14 ++++----
.../mpich2/src/mpid/common/datatype/mpid_segment.c | 30 ++++++++++----------
.../mpid/common/datatype/mpid_type_blockindexed.c | 20 ++++++------
.../mpid/common/datatype/mpid_type_contiguous.c | 2 +-
.../common/datatype/mpid_type_create_pairtype.c | 4 +-
.../src/mpid/common/datatype/mpid_type_indexed.c | 22 +++++++-------
.../src/mpid/common/datatype/mpid_type_struct.c | 14 ++++----
.../src/mpid/common/datatype/mpid_type_vector.c | 14 ++++----
17 files changed, 112 insertions(+), 108 deletions(-)
diff --git a/lib/mpi/mpich2/src/include/mpiutil.h b/lib/mpi/mpich2/src/include/mpiutil.h
index 0c20f99..9df215c 100644
--- a/lib/mpi/mpich2/src/include/mpiutil.h
+++ b/lib/mpi/mpich2/src/include/mpiutil.h
@@ -80,12 +80,12 @@ int MPID_Abort( struct MPID_Comm *comm, int mpi_errno, int exit_code, const char
}
/*
- * Ensure an MPI_Aint value fits into a positive int.
+ * Ensure an MPI_Aint value fits into a signed int.
* Useful for detecting overflow when MPI_Aint is larger than an int.
*
* \param[in] aint Variable of type MPI_Aint
*/
-#define MPID_Ensure_Aint_fits_in_positive_int( aint ) \
+#define MPID_Ensure_Aint_fits_in_int( aint ) \
MPIU_Assert( (aint) == (MPI_Aint)(int)(aint) );
/*
diff --git a/lib/mpi/mpich2/src/mpi/attr/attr_get.c b/lib/mpi/mpich2/src/mpi/attr/attr_get.c
index 4527ba0..81ca2c4 100644
--- a/lib/mpi/mpich2/src/mpi/attr/attr_get.c
+++ b/lib/mpi/mpich2/src/mpi/attr/attr_get.c
@@ -92,12 +92,13 @@ int MPI_Attr_get(MPI_Comm comm, int keyval, void *attr_value, int *flag)
/* A common user error is to pass the address of a 4-byte
int when the address of a pointer (or an address-sized int)
should have been used. We can test for this specific
- case. Note that this code assumes sizeof(MPI_Aint) is
+ case. Note that this code assumes sizeof(void*) is
a power of 2. Note that this formerly used MPI_Aint for the
address sized int, but since this is configurable and could
- be larger than a pointer, we use long for the check, since
- long is expected to be the size of a pointer.*/
- if ( (unsigned long) attr_value & (sizeof(unsigned long)-1)) {
+ be larger than a pointer, we use sizeof(void*). We also
+ cast attr_value to an arbitrary sized numeric value since
+ we are only interested in the low-order few bits. */
+ if ( (unsigned long) attr_value & (sizeof(void*)-1)) {
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
}
# endif
diff --git a/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c b/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c
index 8e6a88d..36cdf86 100644
--- a/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c
+++ b/lib/mpi/mpich2/src/mpi/attr/comm_get_attr.c
@@ -84,12 +84,13 @@ int MPI_Comm_get_attr(MPI_Comm comm, int comm_keyval, void *attribute_val, int *
/* A common user error is to pass the address of a 4-byte
int when the address of a pointer (or an address-sized int)
should have been used. We can test for this specific
- case. Note that this code assumes sizeof(MPI_Aint) is
+ case. Note that this code assumes sizeof(void*) is
a power of 2. Note that this formerly used MPI_Aint for the
address sized int, but since this is configurable and could
- be larger than a pointer, we use long for the check, since
- long is expected to be the size of a pointer. */
- if ( (unsigned long) attribute_val & (sizeof(unsigned long)-1)) {
+ be larger than a pointer, we use sizeof(void*). We also
+ cast attribute_val to an arbitrary sized numeric value since
+ we are only interested in the low-order few bits. */
+ if ( (unsigned long) attribute_val & (sizeof(void*)-1)) {
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
}
# endif
diff --git a/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c b/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c
index fabfe6a..b51ecf2 100644
--- a/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c
+++ b/lib/mpi/mpich2/src/mpi/attr/type_get_attr.c
@@ -86,12 +86,13 @@ int MPI_Type_get_attr(MPI_Datatype type, int type_keyval, void *attribute_val,
/* A common user error is to pass the address of a 4-byte
int when the address of a pointer (or an address-sized int)
should have been used. We can test for this specific
- case. Note that this code assumes sizeof(MPI_Aint) is
+ case. Note that this code assumes sizeof(void*) is
a power of 2. Note that this formerly used MPI_Aint for the
address sized int, but since this is configurable and could
- be larger than a pointer, we use long for the check, since
- long is expected to be the size of a pointer. */
- if ( (unsigned long) attribute_val & (sizeof(unsigned long)-1)) {
+ be larger than a pointer, we use sizeof(void*). We also
+ cast attribute_val to an arbitrary sized numeric value since
+ we are only interested in the low-order few bits. */
+ if ( (unsigned long) attribute_val & (sizeof(void*)-1)) {
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
}
# endif
diff --git a/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c b/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c
index 4e09a44..b862716 100644
--- a/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c
+++ b/lib/mpi/mpich2/src/mpi/attr/win_get_attr.c
@@ -82,12 +82,13 @@ int MPI_Win_get_attr(MPI_Win win, int win_keyval, void *attribute_val,
/* A common user error is to pass the address of a 4-byte
int when the address of a pointer (or an address-sized int)
should have been used. We can test for this specific
- case. Note that this code assumes sizeof(long) is
+ case. Note that this code assumes sizeof(void*) is
a power of 2. Note that this formerly used MPI_Aint for the
address sized int, but since this is configurable and could
- be larger than a pointer, we use long for the check, since
- long is expected to be the size of a pointer. */
- if ( (unsigned long) attribute_val & (sizeof(unsigned long)-1)) {
+ be larger than a pointer, we use sizeof(void*). We also
+ cast attribute_val to an arbitrary sized numeric value since
+ we are only interested in the low-order few bits. */
+ if ( (unsigned long) attribute_val & (sizeof(void*)-1)) {
MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
}
# endif
diff --git a/lib/mpi/mpich2/src/mpi/datatype/pack.c b/lib/mpi/mpich2/src/mpi/datatype/pack.c
index 88b593b..7f64e80 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/pack.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/pack.c
@@ -195,8 +195,8 @@ int MPI_Pack(void *inbuf,
&last,
(void *) ((char *) outbuf + *position));
- /* Ensure that "last" fits into an int datatype and is positive. */
- MPID_Ensure_Aint_fits_in_positive_int( last );
+ /* Ensure that "last" fits into an int datatype. */
+ MPID_Ensure_Aint_fits_in_int( last );
*position += (int) last;
diff --git a/lib/mpi/mpich2/src/mpi/datatype/type_create_darray.c b/lib/mpi/mpich2/src/mpi/datatype/type_create_darray.c
index ae98321..1ae7290 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/type_create_darray.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/type_create_darray.c
@@ -123,7 +123,7 @@ PMPI_LOCAL int MPIR_Type_block(int *array_of_gsizes,
/* --END ERROR HANDLING-- */
}
else {
- for (i=0; i<dim; i++) stride *= (MPI_Aint)(unsigned long)(array_of_gsizes[i]);
+ for (i=0; i<dim; i++) stride *= (MPI_Aint)(array_of_gsizes[i]);
mpi_errno = MPID_Type_vector(mysize,
1,
stride,
@@ -153,7 +153,7 @@ PMPI_LOCAL int MPIR_Type_block(int *array_of_gsizes,
/* --END ERROR HANDLING-- */
}
else {
- for (i=ndims-1; i>dim; i--) stride *= (MPI_Aint)(unsigned long)(array_of_gsizes[i]);
+ for (i=ndims-1; i>dim; i--) stride *= (MPI_Aint)(array_of_gsizes[i]);
mpi_errno = MPID_Type_vector(mysize,
1,
stride,
@@ -170,7 +170,7 @@ PMPI_LOCAL int MPIR_Type_block(int *array_of_gsizes,
}
}
- *st_offset = (MPI_Aint)(unsigned long)blksize * (MPI_Aint)(unsigned long)rank;
+ *st_offset = (MPI_Aint)blksize * (MPI_Aint)rank;
/* in terms of no. of elements of type oldtype in this dimension */
if (mysize == 0) *st_offset = 0;
@@ -231,10 +231,10 @@ PMPI_LOCAL int MPIR_Type_cyclic(int *array_of_gsizes,
count = local_size/blksize;
rem = local_size % blksize;
- stride = (MPI_Aint)(unsigned long)nprocs * (MPI_Aint)(unsigned long)blksize * orig_extent;
+ stride = (MPI_Aint)nprocs * (MPI_Aint)blksize * orig_extent;
if (order == MPI_ORDER_FORTRAN)
- for (i=0; i<dim; i++) stride *= (MPI_Aint)(unsigned long)(array_of_gsizes[i]);
- else for (i=ndims-1; i>dim; i--) stride *= (MPI_Aint)(unsigned long)(array_of_gsizes[i]);
+ for (i=0; i<dim; i++) stride *= (MPI_Aint)(array_of_gsizes[i]);
+ else for (i=ndims-1; i>dim; i--) stride *= (MPI_Aint)(array_of_gsizes[i]);
mpi_errno = MPID_Type_vector(count,
blksize,
@@ -257,7 +257,7 @@ PMPI_LOCAL int MPIR_Type_cyclic(int *array_of_gsizes,
types[0] = *type_new;
types[1] = type_old;
disps[0] = 0;
- disps[1] = (MPI_Aint)(unsigned long)count * stride;
+ disps[1] = (MPI_Aint)count * stride;
blklens[0] = 1;
blklens[1] = rem;
@@ -288,9 +288,9 @@ PMPI_LOCAL int MPIR_Type_cyclic(int *array_of_gsizes,
types[0] = MPI_LB;
disps[0] = 0;
types[1] = *type_new;
- disps[1] = (MPI_Aint)(unsigned long)rank * (MPI_Aint)(unsigned long)blksize * orig_extent;
+ disps[1] = (MPI_Aint)rank * (MPI_Aint)blksize * orig_extent;
types[2] = MPI_UB;
- disps[2] = orig_extent * (MPI_Aint)(unsigned long)(array_of_gsizes[dim]);
+ disps[2] = orig_extent * (MPI_Aint)(array_of_gsizes[dim]);
blklens[0] = blklens[1] = blklens[2] = 1;
mpi_errno = MPID_Type_struct(3,
blklens,
@@ -314,7 +314,7 @@ PMPI_LOCAL int MPIR_Type_cyclic(int *array_of_gsizes,
the struct above */
}
else {
- *st_offset = (MPI_Aint)(unsigned long)rank * (MPI_Aint)(unsigned long)blksize;
+ *st_offset = (MPI_Aint)rank * (MPI_Aint)blksize;
/* st_offset is in terms of no. of elements of type oldtype in
* this dimension */
}
@@ -591,7 +591,7 @@ int MPI_Type_create_darray(int size,
tmp_size = 1;
for (i=1; i<ndims; i++) {
tmp_size *= array_of_gsizes[i-1];
- disps[1] += (MPI_Aint)(unsigned long)tmp_size * st_offsets[i];
+ disps[1] += (MPI_Aint)tmp_size * st_offsets[i];
}
/* rest done below for both Fortran and C order */
}
@@ -659,14 +659,14 @@ int MPI_Type_create_darray(int size,
tmp_size = 1;
for (i=ndims-2; i>=0; i--) {
tmp_size *= array_of_gsizes[i+1];
- disps[1] += (MPI_Aint)(unsigned long)tmp_size * st_offsets[i];
+ disps[1] += (MPI_Aint)tmp_size * st_offsets[i];
}
}
disps[1] *= orig_extent;
disps[2] = orig_extent;
- for (i=0; i<ndims; i++) disps[2] *= (MPI_Aint)(unsigned long)(array_of_gsizes[i]);
+ for (i=0; i<ndims; i++) disps[2] *= (MPI_Aint)(array_of_gsizes[i]);
disps[0] = 0;
blklens[0] = blklens[1] = blklens[2] = 1;
diff --git a/lib/mpi/mpich2/src/mpi/datatype/type_create_subarray.c b/lib/mpi/mpich2/src/mpi/datatype/type_create_subarray.c
index 1c3efc0..9728030 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/type_create_subarray.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/type_create_subarray.c
@@ -194,14 +194,14 @@ int MPI_Type_create_subarray(int ndims,
else {
mpi_errno = MPID_Type_vector(array_of_subsizes[1],
array_of_subsizes[0],
- (MPI_Aint)(unsigned long)(array_of_sizes[0]),
+ (MPI_Aint)(array_of_sizes[0]),
0, /* stride in types */
oldtype,
&tmp1);
- size = ((MPI_Aint)(unsigned long)array_of_sizes[0]) * extent;
+ size = ((MPI_Aint)(array_of_sizes[0])) * extent;
for (i=2; i<ndims; i++) {
- size *= (MPI_Aint)(unsigned long)(array_of_sizes[i-1]);
+ size *= (MPI_Aint)(array_of_sizes[i-1]);
mpi_errno = MPID_Type_vector(array_of_subsizes[i],
1,
size,
@@ -215,11 +215,11 @@ int MPI_Type_create_subarray(int ndims,
/* add displacement and UB */
- disps[1] = (MPI_Aint)(unsigned long)(array_of_starts[0]);
+ disps[1] = (MPI_Aint)(array_of_starts[0]);
size = 1;
for (i=1; i<ndims; i++) {
- size *= (MPI_Aint)(unsigned long)(array_of_sizes[i-1]);
- disps[1] += size * (MPI_Aint)(unsigned long)(array_of_starts[i]);
+ size *= (MPI_Aint)(array_of_sizes[i-1]);
+ disps[1] += size * (MPI_Aint)(array_of_starts[i]);
}
/* rest done below for both Fortran and C order */
}
@@ -234,15 +234,15 @@ int MPI_Type_create_subarray(int ndims,
else {
mpi_errno = MPID_Type_vector(array_of_subsizes[ndims-2],
array_of_subsizes[ndims-1],
- (MPI_Aint)(unsigned long)(array_of_sizes[ndims-1]),
+ (MPI_Aint)(array_of_sizes[ndims-1]),
0, /* stride in types */
oldtype,
&tmp1);
- size = (MPI_Aint)(unsigned long)(array_of_sizes[ndims-1]) * extent;
+ size = (MPI_Aint)(array_of_sizes[ndims-1]) * extent;
for (i=ndims-3; i>=0; i--) {
- size *= (MPI_Aint)(unsigned long)(array_of_sizes[i+1]);
+ size *= (MPI_Aint)(array_of_sizes[i+1]);
mpi_errno = MPID_Type_vector(array_of_subsizes[i],
1, /* blocklen */
size, /* stride */
@@ -257,18 +257,18 @@ int MPI_Type_create_subarray(int ndims,
/* add displacement and UB */
- disps[1] = (MPI_Aint)(unsigned long)(array_of_starts[ndims-1]);
+ disps[1] = (MPI_Aint)(array_of_starts[ndims-1]);
size = 1;
for (i=ndims-2; i>=0; i--) {
- size *= (MPI_Aint)(unsigned long)(array_of_sizes[i+1]);
- disps[1] += size * (MPI_Aint)(unsigned long)(array_of_starts[i]);
+ size *= (MPI_Aint)(array_of_sizes[i+1]);
+ disps[1] += size * (MPI_Aint)(array_of_starts[i]);
}
}
disps[1] *= extent;
disps[2] = extent;
- for (i=0; i<ndims; i++) disps[2] *= (MPI_Aint)(unsigned long)(array_of_sizes[i]);
+ for (i=0; i<ndims; i++) disps[2] *= (MPI_Aint)(array_of_sizes[i]);
disps[0] = 0;
blklens[0] = blklens[1] = blklens[2] = 1;
diff --git a/lib/mpi/mpich2/src/mpi/datatype/unpack.c b/lib/mpi/mpich2/src/mpi/datatype/unpack.c
index 3018ba7..57cd4b7 100644
--- a/lib/mpi/mpich2/src/mpi/datatype/unpack.c
+++ b/lib/mpi/mpich2/src/mpi/datatype/unpack.c
@@ -138,8 +138,8 @@ int MPI_Unpack(void *inbuf, int insize, int *position,
&last,
(void *) ((char *) inbuf + *position));
- /* Ensure that "last" fits into an int datatype and is positive. */
- MPID_Ensure_Aint_fits_in_positive_int( last );
+ /* Ensure that "last" fits into an int datatype. */
+ MPID_Ensure_Aint_fits_in_int( last );
*position += (int) last;
diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/dataloop/dataloop.c b/lib/mpi/mpich2/src/mpid/common/datatype/dataloop/dataloop.c
index cf8ad79..c403db4 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/dataloop/dataloop.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/dataloop/dataloop.c
@@ -598,7 +598,7 @@ PREPEND_PREFIX(Dataloop_stream_size)(struct DLOOP_Dataloop *dl_p,
tmp_sz = 0;
for (i = 0; i < dl_p->loop_params.s_t.count; i++)
{
- ret += (DLOOP_Offset)(unsigned long)(dl_p->loop_params.s_t.blocksize_array[i]) *
+ ret += (DLOOP_Offset)(dl_p->loop_params.s_t.blocksize_array[i]) *
PREPEND_PREFIX(Dataloop_stream_size)(dl_p->loop_params.s_t.dataloop_array[i], sizefn);
}
return tmp_sz * tmp_ct;
@@ -606,15 +606,15 @@ PREPEND_PREFIX(Dataloop_stream_size)(struct DLOOP_Dataloop *dl_p,
switch (dl_p->kind & DLOOP_KIND_MASK) {
case DLOOP_KIND_CONTIG:
- tmp_ct *= (DLOOP_Offset)(unsigned long)(dl_p->loop_params.c_t.count);
+ tmp_ct *= (DLOOP_Offset)(dl_p->loop_params.c_t.count);
#ifdef DLOOP_DEBUG_SIZE
DLOOP_dbg_printf("stream_size: contig: ct = %d; new tot_ct = " MPI_AINT_FMT_DEC_SPEC "\n",
(int) dl_p->loop_params.c_t.count, (MPI_Aint) tmp_ct);
#endif
break;
case DLOOP_KIND_VECTOR:
- tmp_ct *= (DLOOP_Offset)(unsigned long)(dl_p->loop_params.v_t.count) *
- (DLOOP_Offset)(unsigned long)(dl_p->loop_params.v_t.blocksize);
+ tmp_ct *= (DLOOP_Offset)(dl_p->loop_params.v_t.count) *
+ (DLOOP_Offset)(dl_p->loop_params.v_t.blocksize);
#ifdef DLOOP_DEBUG_SIZE
DLOOP_dbg_printf("stream_size: vector: ct = %d; blk = %d; new tot_ct = " MPI_AINT_FMT_DEC_SPEC "\n",
(int) dl_p->loop_params.v_t.count,
@@ -623,8 +623,8 @@ PREPEND_PREFIX(Dataloop_stream_size)(struct DLOOP_Dataloop *dl_p,
#endif
break;
case DLOOP_KIND_BLOCKINDEXED:
- tmp_ct *= (DLOOP_Offset)(unsigned long)(dl_p->loop_params.bi_t.count) *
- (DLOOP_Offset)(unsigned long)(dl_p->loop_params.bi_t.blocksize);
+ tmp_ct *= (DLOOP_Offset)(dl_p->loop_params.bi_t.count) *
+ (DLOOP_Offset)(dl_p->loop_params.bi_t.blocksize);
#ifdef DLOOP_DEBUG_SIZE
DLOOP_dbg_printf("stream_size: blkindexed: blks = %d; new tot_ct = " MPI_AINT_FMT_DEC_SPEC "\n",
(int) dl_p->loop_params.bi_t.count *
@@ -633,7 +633,7 @@ PREPEND_PREFIX(Dataloop_stream_size)(struct DLOOP_Dataloop *dl_p,
#endif
break;
case DLOOP_KIND_INDEXED:
- tmp_ct *= (DLOOP_Offset)(unsigned long)(dl_p->loop_params.i_t.total_blocks);
+ tmp_ct *= (DLOOP_Offset)(dl_p->loop_params.i_t.total_blocks);
#ifdef DLOOP_DEBUG_SIZE
DLOOP_dbg_printf("stream_size: contig: blks = %d; new tot_ct = " MPI_AINT_FMT_DEC_SPEC "\n",
(int) dl_p->loop_params.i_t.total_blocks,
diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_segment.c b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_segment.c
index 7e90351..fd00e76 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_segment.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_segment.c
@@ -235,9 +235,9 @@ static int MPID_Segment_contig_pack_to_iov(DLOOP_Offset *blocks_p,
size = *blocks_p * (DLOOP_Offset) el_size;
MPIU_DBG_MSG_FMT(DATATYPE,VERBOSE,(MPIU_DBG_FDEST,
- "\t[contig to vec: do=MPI_AINT_FMT_DEC_SPEC, dp=%x, ind=%d, sz=%d, blksz="MPI_AINT_FMT_DEC_SPEC"]\n",
+ "\t[contig to vec: do=" MPI_AINT_FMT_DEC_SPEC ", dp=%p, ind=%d, sz=%d, blksz=" MPI_AINT_FMT_DEC_SPEC "]\n",
(MPI_Aint) rel_off,
- (unsigned) (MPI_Aint)bufp,
+ bufp,
paramp->u.pack_vector.index,
el_size,
(MPI_Aint) *blocks_p));
@@ -306,18 +306,18 @@ static int MPID_Segment_vector_pack_to_iov(DLOOP_Offset *blocks_p,
MPIDI_FUNC_ENTER(MPID_STATE_MPID_SEGMENT_VECTOR_PACK_TO_IOV);
- basic_size = (DLOOP_Offset)(unsigned long)MPID_Datatype_get_basic_size(el_type);
+ basic_size = (DLOOP_Offset)MPID_Datatype_get_basic_size(el_type);
blocks_left = *blocks_p;
MPIU_DBG_MSG_FMT(DATATYPE,VERBOSE,(MPIU_DBG_FDEST,
"\t[vector to vec: do=" MPI_AINT_FMT_DEC_SPEC
- ", dp=" MPI_AINT_FMT_HEX_SPEC
+ ", dp=%p"
", len=%d, ind=%d, ct=%d, blksz=%d"
", str=" MPI_AINT_FMT_DEC_SPEC
", blks=" MPI_AINT_FMT_DEC_SPEC
"]\n",
(MPI_Aint) rel_off,
- (MPI_Aint)bufp,
+ bufp,
paramp->u.pack_vector.length,
paramp->u.pack_vector.index,
count,
@@ -329,9 +329,9 @@ static int MPID_Segment_vector_pack_to_iov(DLOOP_Offset *blocks_p,
int last_idx;
char *last_end = NULL;
- if (blocks_left > (DLOOP_Offset)(unsigned long)blksz) {
- size = ((DLOOP_Offset)(unsigned long)blksz) * basic_size;
- blocks_left -= (DLOOP_Offset)(unsigned long)blksz;
+ if (blocks_left > (DLOOP_Offset)blksz) {
+ size = ((DLOOP_Offset)blksz) * basic_size;
+ blocks_left -= (DLOOP_Offset)blksz;
}
else {
/* last pass */
@@ -415,7 +415,7 @@ static int MPID_Segment_contig_flatten(DLOOP_Offset *blocks_p,
MPIDI_FUNC_ENTER(MPID_STATE_MPID_SEGMENT_CONTIG_FLATTEN);
el_size = MPID_Datatype_get_basic_size(el_type);
- size = *blocks_p * (DLOOP_Offset)(unsigned long)el_size;
+ size = *blocks_p * (DLOOP_Offset)el_size;
index = paramp->u.flatten.index;
#ifdef MPID_SP_VERBOSE
@@ -429,7 +429,7 @@ static int MPID_Segment_contig_flatten(DLOOP_Offset *blocks_p,
if (index > 0 && ((DLOOP_Offset) MPI_VOID_PTR_CAST_TO_MPI_AINT bufp + rel_off) ==
((paramp->u.flatten.offp[index - 1]) +
- (DLOOP_Offset)(unsigned long)paramp->u.flatten.sizep[index - 1]))
+ (DLOOP_Offset)paramp->u.flatten.sizep[index - 1]))
{
/* add this size to the last vector rather than using up another one */
paramp->u.flatten.sizep[index - 1] += size;
@@ -482,15 +482,15 @@ static int MPID_Segment_vector_flatten(DLOOP_Offset *blocks_p,
MPIDI_FUNC_ENTER(MPID_STATE_MPID_SEGMENT_VECTOR_FLATTEN);
- basic_size = (DLOOP_Offset)(unsigned long)MPID_Datatype_get_basic_size(el_type);
+ basic_size = (DLOOP_Offset)MPID_Datatype_get_basic_size(el_type);
blocks_left = *blocks_p;
for (i=0; i < count && blocks_left > 0; i++) {
int index = paramp->u.flatten.index;
- if (blocks_left > (DLOOP_Offset)(unsigned long)blksz) {
- size = ((DLOOP_Offset)(unsigned long)blksz) * basic_size;
- blocks_left -= (DLOOP_Offset)(unsigned long)blksz;
+ if (blocks_left > (DLOOP_Offset)blksz) {
+ size = ((DLOOP_Offset)blksz) * basic_size;
+ blocks_left -= (DLOOP_Offset)blksz;
}
else {
/* last pass */
@@ -499,7 +499,7 @@ static int MPID_Segment_vector_flatten(DLOOP_Offset *blocks_p,
}
if (index > 0 && ((DLOOP_Offset) MPI_VOID_PTR_CAST_TO_MPI_AINT bufp + rel_off) ==
- ((paramp->u.flatten.offp[index - 1]) + (DLOOP_Offset)(unsigned long)paramp->u.flatten.sizep[index - 1]))
+ ((paramp->u.flatten.offp[index - 1]) + (DLOOP_Offset)paramp->u.flatten.sizep[index - 1]))
{
/* add this size to the last region rather than using up another one */
paramp->u.flatten.sizep[index - 1] += size;
diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_blockindexed.c b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_blockindexed.c
index b69c49e..71b879f 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_blockindexed.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_blockindexed.c
@@ -86,7 +86,7 @@ int MPID_Type_blockindexed(int count,
if (is_builtin)
{
- el_sz = (MPI_Aint)(unsigned long)MPID_Datatype_get_basic_size(oldtype);
+ el_sz = (MPI_Aint)MPID_Datatype_get_basic_size(oldtype);
el_type = oldtype;
old_lb = 0;
@@ -96,8 +96,8 @@ int MPID_Type_blockindexed(int count,
old_extent = el_sz;
old_is_contig = 1;
- new_dtp->size = (MPI_Aint)(unsigned long)count *
- (MPI_Aint)(unsigned long)blocklength * el_sz;
+ new_dtp->size = (MPI_Aint)count *
+ (MPI_Aint)blocklength * el_sz;
new_dtp->has_sticky_lb = 0;
new_dtp->has_sticky_ub = 0;
@@ -124,9 +124,9 @@ int MPID_Type_blockindexed(int count,
old_extent = old_dtp->extent;
old_is_contig = old_dtp->is_contig;
- new_dtp->size = (MPI_Aint)(unsigned long)count *
- (MPI_Aint)(unsigned long)blocklength *
- (MPI_Aint)(unsigned long)old_dtp->size;
+ new_dtp->size = (MPI_Aint)count *
+ (MPI_Aint)blocklength *
+ (MPI_Aint)old_dtp->size;
new_dtp->has_sticky_lb = old_dtp->has_sticky_lb;
new_dtp->has_sticky_ub = old_dtp->has_sticky_ub;
@@ -141,7 +141,7 @@ int MPID_Type_blockindexed(int count,
/* priming for loop */
eff_disp = (dispinbytes) ? ((MPI_Aint *) displacement_array)[0] :
(((MPI_Aint) ((int *) displacement_array)[0]) * old_extent);
- MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)(unsigned long)blocklength,
+ MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)blocklength,
eff_disp,
old_lb,
old_ub,
@@ -156,7 +156,7 @@ int MPID_Type_blockindexed(int count,
eff_disp = (dispinbytes) ? ((MPI_Aint *) displacement_array)[i] :
(((MPI_Aint) ((int *) displacement_array)[i]) * old_extent);
- MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)(unsigned long)blocklength,
+ MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)blocklength,
eff_disp,
old_lb,
old_ub,
@@ -178,7 +178,7 @@ int MPID_Type_blockindexed(int count,
* its size and extent are the same, and the old type was also
* contiguous.
*/
- if (old_is_contig && ((MPI_Aint)(unsigned long)new_dtp->size == new_dtp->extent))
+ if (old_is_contig && ((MPI_Aint)new_dtp->size == new_dtp->extent))
{
contig_count = MPIDI_Type_blockindexed_count_contig(count,
blocklength,
@@ -223,7 +223,7 @@ int MPIDI_Type_blockindexed_count_contig(int count,
for (i=1; i < count; i++)
{
- if (cur_bdisp + (MPI_Aint)(unsigned long)blklen * old_extent !=
+ if (cur_bdisp + (MPI_Aint)blklen * old_extent !=
((MPI_Aint *) disp_array)[i])
{
contig_count++;
diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_contiguous.c b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_contiguous.c
index 951590b..4502943 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_contiguous.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_contiguous.c
@@ -101,7 +101,7 @@ int MPID_Type_contiguous(int count,
new_dtp->has_sticky_ub = old_dtp->has_sticky_ub;
new_dtp->has_sticky_lb = old_dtp->has_sticky_lb;
- MPID_DATATYPE_CONTIG_LB_UB((MPI_Aint)(unsigned long)count,
+ MPID_DATATYPE_CONTIG_LB_UB((MPI_Aint)count,
old_dtp->lb,
old_dtp->ub,
old_dtp->extent,
diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_create_pairtype.c b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_create_pairtype.c
index ec1c155..e509101 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_create_pairtype.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_create_pairtype.c
@@ -166,8 +166,8 @@ int MPID_Type_create_pairtype(MPI_Datatype type,
break;
}
- new_dtp->is_contig = ( ((MPI_Aint)(unsigned long)type_size) == type_extent) ? 1 : 0;
- new_dtp->n_contig_blocks = ( ((MPI_Aint)(unsigned long)type_size) == type_extent) ? 1 : 2;
+ new_dtp->is_contig = ( ((MPI_Aint)type_size) == type_extent) ? 1 : 0;
+ new_dtp->n_contig_blocks = ( ((MPI_Aint)type_size) == type_extent) ? 1 : 2;
/* fill in dataloops -- only case where we precreate dataloops
*
diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_indexed.c b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_indexed.c
index 73d5d74..00fabeb 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_indexed.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_indexed.c
@@ -102,16 +102,16 @@ int MPID_Type_indexed(int count,
old_lb = 0;
old_true_lb = 0;
- old_ub = (MPI_Aint)(unsigned long)el_sz;
- old_true_ub = (MPI_Aint)(unsigned long)el_sz;
- old_extent = (MPI_Aint)(unsigned long)el_sz;
+ old_ub = (MPI_Aint)el_sz;
+ old_true_ub = (MPI_Aint)el_sz;
+ old_extent = (MPI_Aint)el_sz;
old_is_contig = 1;
new_dtp->has_sticky_ub = 0;
new_dtp->has_sticky_lb = 0;
new_dtp->alignsize = el_sz; /* ??? */
- new_dtp->element_size = (MPI_Aint)(unsigned long)el_sz;
+ new_dtp->element_size = (MPI_Aint)el_sz;
new_dtp->eltype = el_type;
new_dtp->n_contig_blocks = count;
@@ -123,8 +123,8 @@ int MPID_Type_indexed(int count,
MPID_Datatype_get_ptr(oldtype, old_dtp);
- /* Ensure that "element_size" fits into an int datatype and is positive. */
- MPID_Ensure_Aint_fits_in_positive_int( old_dtp->element_size );
+ /* Ensure that "element_size" fits into an int datatype. */
+ MPID_Ensure_Aint_fits_in_int( old_dtp->element_size );
el_sz = old_dtp->element_size;
old_sz = old_dtp->size;
@@ -140,7 +140,7 @@ int MPID_Type_indexed(int count,
new_dtp->has_sticky_lb = old_dtp->has_sticky_lb;
new_dtp->has_sticky_ub = old_dtp->has_sticky_ub;
- new_dtp->element_size = (MPI_Aint)(unsigned long)el_sz;
+ new_dtp->element_size = (MPI_Aint)el_sz;
new_dtp->eltype = el_type;
new_dtp->n_contig_blocks = old_dtp->n_contig_blocks * count;
@@ -160,7 +160,7 @@ int MPID_Type_indexed(int count,
eff_disp = (dispinbytes) ? ((MPI_Aint *) displacement_array)[i] :
(((MPI_Aint) ((int *) displacement_array)[i]) * old_extent);
- MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)(unsigned long)blocklength_array[i],
+ MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)blocklength_array[i],
eff_disp,
old_lb,
old_ub,
@@ -182,7 +182,7 @@ int MPID_Type_indexed(int count,
(((MPI_Aint) ((int *) displacement_array)[i]) * old_extent);
/* calculate ub and lb for this block */
- MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)(unsigned long)(blocklength_array[i]),
+ MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)(blocklength_array[i]),
eff_disp,
old_lb,
old_ub,
@@ -215,7 +215,7 @@ int MPID_Type_indexed(int count,
dispinbytes,
old_extent);
- if ((contig_count == 1) && ((MPI_Aint)(unsigned long)new_dtp->size == new_dtp->extent))
+ if ((contig_count == 1) && ((MPI_Aint)new_dtp->size == new_dtp->extent))
{
new_dtp->is_contig = old_is_contig;
}
@@ -278,7 +278,7 @@ int MPIDI_Type_indexed_count_contig(int count,
{
continue;
}
- else if (cur_bdisp + (MPI_Aint)(unsigned long)cur_blklen * old_extent ==
+ else if (cur_bdisp + (MPI_Aint)cur_blklen * old_extent ==
((MPI_Aint *) displacement_array)[i])
{
/* adjacent to current block; add to block */
diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_struct.c b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_struct.c
index 0b2f509..5ef320f 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_struct.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_struct.c
@@ -229,7 +229,7 @@ int MPID_Type_struct(int count,
tmp_el_sz = MPID_Datatype_get_basic_size(oldtype_array[i]);
tmp_el_type = oldtype_array[i];
- MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)(unsigned long)(blocklength_array[i]),
+ MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)(blocklength_array[i]),
displacement_array[i],
0,
tmp_el_sz,
@@ -247,13 +247,13 @@ int MPID_Type_struct(int count,
{
MPID_Datatype_get_ptr(oldtype_array[i], old_dtp);
- /* Ensure that "element_size" fits into an int datatype and is positive. */
- MPID_Ensure_Aint_fits_in_positive_int( old_dtp->element_size );
+ /* Ensure that "element_size" fits into an int datatype. */
+ MPID_Ensure_Aint_fits_in_int( old_dtp->element_size );
tmp_el_sz = old_dtp->element_size;
tmp_el_type = old_dtp->eltype;
- MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)(unsigned long)blocklength_array[i],
+ MPID_DATATYPE_BLOCK_LB_UB((MPI_Aint)blocklength_array[i],
displacement_array[i],
old_dtp->lb,
old_dtp->ub,
@@ -380,11 +380,11 @@ int MPID_Type_struct(int count,
{
/* account for padding */
MPI_Aint epsilon = (new_dtp->alignsize > 0) ?
- new_dtp->extent % ((MPI_Aint)(unsigned long)(new_dtp->alignsize)) : 0;
+ new_dtp->extent % ((MPI_Aint)(new_dtp->alignsize)) : 0;
if (epsilon)
{
- new_dtp->ub += ((MPI_Aint)(unsigned long)(new_dtp->alignsize) - epsilon);
+ new_dtp->ub += ((MPI_Aint)(new_dtp->alignsize) - epsilon);
new_dtp->extent = new_dtp->ub - new_dtp->lb;
}
}
@@ -395,7 +395,7 @@ int MPID_Type_struct(int count,
* same, and the old type was also contiguous, and we didn't see
* something noncontiguous based on true ub/ub.
*/
- if (((MPI_Aint)(unsigned long)(new_dtp->size) == new_dtp->extent) &&
+ if (((MPI_Aint)(new_dtp->size) == new_dtp->extent) &&
old_are_contig && (! definitely_not_contig))
{
new_dtp->is_contig = 1;
diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_vector.c b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_vector.c
index 97ecfe8..bc11bdc 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_vector.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_vector.c
@@ -76,7 +76,7 @@ int MPID_Type_vector(int count,
is_builtin = (HANDLE_GET_KIND(oldtype) == HANDLE_KIND_BUILTIN);
if (is_builtin) {
- el_sz = (MPI_Aint)(unsigned long)MPID_Datatype_get_basic_size(oldtype);
+ el_sz = (MPI_Aint)MPID_Datatype_get_basic_size(oldtype);
el_type = oldtype;
old_lb = 0;
@@ -87,8 +87,8 @@ int MPID_Type_vector(int count,
old_extent = el_sz;
old_is_contig = 1;
- new_dtp->size = (MPI_Aint)(unsigned long)count *
- (MPI_Aint)(unsigned long)blocklength * el_sz;
+ new_dtp->size = (MPI_Aint)count *
+ (MPI_Aint)blocklength * el_sz;
new_dtp->has_sticky_lb = 0;
new_dtp->has_sticky_ub = 0;
@@ -130,9 +130,9 @@ int MPID_Type_vector(int count,
eff_stride = (strideinbytes) ? stride : (stride * old_dtp->extent);
}
- MPID_DATATYPE_VECTOR_LB_UB((MPI_Aint)(unsigned long)count,
+ MPID_DATATYPE_VECTOR_LB_UB((MPI_Aint)count,
eff_stride,
- (MPI_Aint)(unsigned long)blocklength,
+ (MPI_Aint)blocklength,
old_lb,
old_ub,
old_extent,
@@ -146,8 +146,8 @@ int MPID_Type_vector(int count,
* size and extent of new type are equivalent, and stride is
* equal to blocklength * size of old type.
*/
- if ((MPI_Aint)(unsigned long)(new_dtp->size) == new_dtp->extent &&
- eff_stride == (MPI_Aint)(unsigned long)blocklength * old_sz &&
+ if ((MPI_Aint)(new_dtp->size) == new_dtp->extent &&
+ eff_stride == (MPI_Aint)blocklength * old_sz &&
old_is_contig)
{
new_dtp->is_contig = 1;
--
1.5.3.7
More information about the mpich2-dev
mailing list