Commit 9f8bc14f authored by Rob Latham's avatar Rob Latham Committed by Pavan Balaji
Browse files

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's avatarPavan Balaji <balaji@mcs.anl.gov>
parent 0f06d7ac
......@@ -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,
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 ... */
......
......@@ -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
......
......@@ -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 ... */
......
......@@ -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;
......
......@@ -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)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment