Commit 8754e0b4 authored by Darius Buntinas's avatar Darius Buntinas
Browse files

[svn-r7029] replaced NMPI_ functions with MPIR_ _impl for pack, unpack,...

[svn-r7029] replaced NMPI_ functions with MPIR_ _impl for pack, unpack, pack_size, and group_translate_ranks.  reviewed by balaji@
parent 99ab74a6
......@@ -3550,6 +3550,12 @@ int MPIR_Type_indexed_impl(int count, int blocklens[], int indices[], MPI_Dataty
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, int blocklens[], MPI_Aint indices[], MPI_Datatype old_types[], MPI_Datatype *newtype);
void MPIR_Group_translate_ranks_impl(MPID_Group *group_ptr1, int n, int *ranks1,
MPID_Group *group_ptr2, int *ranks2);
int MPIR_Pack_impl(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(void *inbuf, int insize, int *position,
void *outbuf, int outcount, MPI_Datatype datatype);
void MPIR_Type_lb_impl(MPI_Datatype datatype, MPI_Aint *displacement);
int MPIR_Ibsend_impl(void *buf, int count, MPI_Datatype datatype, int dest, int tag,
MPID_Comm *comm_ptr, MPI_Request *request);
......@@ -3558,5 +3564,4 @@ int MPIR_Wait_impl(MPI_Request *request, MPI_Status *status);
int MPIR_Waitall_impl(int count, MPI_Request array_of_requests[],
MPI_Status array_of_statuses[]);
#endif /* MPIIMPL_INCLUDED */
......@@ -23,9 +23,6 @@
*/
#ifdef USE_MPI_FOR_NMPI
#define NMPI_Pack MPI_Pack
#define NMPI_Pack_size MPI_Pack_size
#define NMPI_Unpack MPI_Unpack
#define NMPI_Type_get_attr MPI_Type_get_attr
#define NMPI_Type_set_attr MPI_Type_set_attr
#define NMPI_Irecv MPI_Irecv
......@@ -33,7 +30,6 @@
#define NMPI_Type_lb MPI_Type_lb
#define NMPI_Iprobe MPI_Iprobe
#define NMPI_Probe MPI_Probe
#define NMPI_Group_translate_ranks MPI_Group_translate_ranks
#define NMPI_Wtime MPI_Wtime
#define NMPI_Info_create MPI_Info_create
#define NMPI_Info_set MPI_Info_set
......@@ -44,9 +40,6 @@
#define NMPIX_Grequest_class_allocate MPIX_Grequest_class_allocate
#define NMPIX_Grequest_start MPIX_Grequest_start
#else
#define NMPI_Pack PMPI_Pack
#define NMPI_Pack_size PMPI_Pack_size
#define NMPI_Unpack PMPI_Unpack
#define NMPI_Type_get_attr PMPI_Type_get_attr
#define NMPI_Type_set_attr PMPI_Type_set_attr
#define NMPI_Irecv PMPI_Irecv
......@@ -54,7 +47,6 @@
#define NMPI_Type_lb PMPI_Type_lb
#define NMPI_Iprobe PMPI_Iprobe
#define NMPI_Probe PMPI_Probe
#define NMPI_Group_translate_ranks PMPI_Group_translate_ranks
#define NMPI_Wtime PMPI_Wtime
#define NMPI_Info_create PMPI_Info_create
#define NMPI_Info_set PMPI_Info_set
......
......@@ -272,7 +272,7 @@ int MPIR_Allgather_intra (
else {
/* heterogeneous. need to use temp. buffer. */
NMPI_Pack_size(recvcount*comm_size, recvtype, comm, &tmp_buf_size);
MPIR_Pack_size_impl(recvcount*comm_size, recvtype, &tmp_buf_size);
MPIU_CHKLMEM_MALLOC(tmp_buf, void*, tmp_buf_size, mpi_errno, "tmp_buf");
......@@ -285,21 +285,21 @@ int MPIR_Allgather_intra (
'position' is incremented. */
position = 0;
NMPI_Pack(recvbuf, 1, recvtype, tmp_buf, tmp_buf_size,
&position, comm);
MPIR_Pack_impl(recvbuf, 1, recvtype, tmp_buf, tmp_buf_size, &position);
nbytes = position*recvcount;
/* pack local data into right location in tmp_buf */
position = rank * nbytes;
if (sendbuf != MPI_IN_PLACE) {
NMPI_Pack(sendbuf, sendcount, sendtype, tmp_buf, tmp_buf_size,
&position, comm);
mpi_errno = MPIR_Pack_impl(sendbuf, sendcount, sendtype, tmp_buf, tmp_buf_size,
&position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else {
/* if in_place specified, local data is found in recvbuf */
NMPI_Pack(((char *)recvbuf + recvtype_extent*rank), recvcount,
recvtype, tmp_buf, tmp_buf_size,
&position, comm);
mpi_errno = MPIR_Pack_impl(((char *)recvbuf + recvtype_extent*rank), recvcount,
recvtype, tmp_buf, tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
curr_cnt = nbytes;
......@@ -383,12 +383,10 @@ int MPIR_Allgather_intra (
last_recv_cnt, MPI_BYTE,
dst, MPIR_ALLGATHER_TAG,
comm);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* last_recv_cnt was set in the previous
receive. that's the amount of data to be
sent now. */
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
}
/* recv only if this proc. doesn't have data and sender
has data */
......@@ -400,11 +398,9 @@ int MPIR_Allgather_intra (
MPI_BYTE, dst,
MPIR_ALLGATHER_TAG,
comm, &status);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* nprocs_completed is also equal to the
no. of processes whose data we don't have */
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
MPIR_Get_count_impl(&status, MPI_BYTE, &last_recv_cnt);
curr_cnt += last_recv_cnt;
}
......@@ -417,8 +413,9 @@ int MPIR_Allgather_intra (
}
position = 0;
NMPI_Unpack(tmp_buf, tmp_buf_size, &position, recvbuf,
recvcount*comm_size, recvtype, comm);
mpi_errno = MPIR_Unpack_impl(tmp_buf, tmp_buf_size, &position, recvbuf,
recvcount*comm_size, recvtype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
#endif /* MPID_HAS_HETERO */
}
......
......@@ -309,7 +309,7 @@ int MPIR_Allgatherv_intra (
#ifdef MPID_HAS_HETERO
else {
/* heterogeneous. need to use temp. buffer. */
NMPI_Pack_size(total_count, recvtype, comm, &tmp_buf_size);
MPIR_Pack_size_impl(total_count, recvtype, &tmp_buf_size);
MPIU_CHKLMEM_MALLOC(tmp_buf, void *, tmp_buf_size, mpi_errno, "tmp_buf");
/* calculate the value of nbytes, the number of bytes in packed
......@@ -319,8 +319,9 @@ int MPIR_Allgatherv_intra (
into tmp_buf and see by how much 'position' is incremented. */
position = 0;
NMPI_Pack(recvbuf, 1, recvtype, tmp_buf, tmp_buf_size,
&position, comm);
mpi_errno = MPIR_Pack_impl(recvbuf, 1, recvtype, tmp_buf, tmp_buf_size,
&position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
nbytes = position;
/* pack local data into right location in tmp_buf */
......@@ -329,14 +330,16 @@ int MPIR_Allgatherv_intra (
position *= nbytes;
if (sendbuf != MPI_IN_PLACE) {
NMPI_Pack(sendbuf, sendcount, sendtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(sendbuf, sendcount, sendtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else {
/* if in_place specified, local data is found in recvbuf */
NMPI_Pack(((char *)recvbuf + displs[rank]*recvtype_extent),
recvcounts[rank], recvtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(((char *)recvbuf + displs[rank]*recvtype_extent),
recvcounts[rank], recvtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
curr_cnt = recvcounts[rank]*nbytes;
......@@ -463,9 +466,10 @@ int MPIR_Allgatherv_intra (
if ((sendbuf != MPI_IN_PLACE) || (j != rank)) {
/* not necessary to unpack if in_place and
j==rank. otherwise unpack. */
NMPI_Unpack(tmp_buf, tmp_buf_size, &position,
((char *)recvbuf + displs[j]*recvtype_extent),
recvcounts[j], recvtype, comm);
mpi_errno = MPIR_Unpack_impl(tmp_buf, tmp_buf_size, &position,
((char *)recvbuf + displs[j]*recvtype_extent),
recvcounts[j], recvtype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
}
......
......@@ -162,7 +162,7 @@ int MPIR_Alltoall_intra(
* IEEE TPDS, Nov. 97 */
/* allocate temporary buffer */
NMPI_Pack_size(recvcount*comm_size, recvtype, comm, &pack_size);
MPIR_Pack_size_impl(recvcount*comm_size, recvtype, &pack_size);
MPIU_CHKLMEM_MALLOC(tmp_buf, void *, pack_size, mpi_errno, "tmp_buf");
/* Do Phase 1 of the algorithim. Shift the data blocks on process i
......@@ -213,8 +213,7 @@ int MPIR_Alltoall_intra(
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
position = 0;
mpi_errno = NMPI_Pack(recvbuf, 1, newtype, tmp_buf, pack_size,
&position, comm);
mpi_errno = MPIR_Pack_impl(recvbuf, 1, newtype, tmp_buf, pack_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIC_Sendrecv(tmp_buf, position, MPI_PACKED, dst,
......
......@@ -94,13 +94,11 @@ static int MPIR_Bcast_binomial(
* heterogeneous systems. We want to use MPI_Type_size() wherever
* possible, and MPI_Pack_size() in other places.
*/
if (is_homogeneous) {
if (is_homogeneous)
MPID_Datatype_get_size_macro(datatype, type_size);
}
else {
mpi_errno = NMPI_Pack_size(1, datatype, comm, &type_size);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else
MPIR_Pack_size_impl(1, datatype, &type_size);
nbytes = type_size * count;
if (!is_contig || !is_homogeneous)
......@@ -109,9 +107,11 @@ static int MPIR_Bcast_binomial(
/* TODO: Pipeline the packing and communication */
position = 0;
if (rank == root)
NMPI_Pack(buffer, count, datatype, tmp_buf, nbytes,
&position, comm);
if (rank == root) {
mpi_errno = MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes,
&position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
relative_rank = (rank >= root) ? rank - root : rank - root + comm_size;
......@@ -194,8 +194,10 @@ static int MPIR_Bcast_binomial(
if (rank != root)
{
position = 0;
NMPI_Unpack(tmp_buf, nbytes, &position, buffer, count,
datatype, comm);
mpi_errno = MPIR_Unpack_impl(tmp_buf, nbytes, &position, buffer,
count, datatype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
......@@ -399,13 +401,11 @@ static int MPIR_Bcast_scatter_doubling_allgather(
* heterogeneous systems. We want to use MPI_Type_size() wherever
* possible, and MPI_Pack_size() in other places.
*/
if (is_homogeneous) {
if (is_homogeneous)
MPID_Datatype_get_size_macro(datatype, type_size);
}
else {
mpi_errno = NMPI_Pack_size(1, datatype, comm, &type_size);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else
MPIR_Pack_size_impl(1, datatype, &type_size);
nbytes = type_size * count;
if (is_contig && is_homogeneous)
......@@ -421,9 +421,11 @@ static int MPIR_Bcast_scatter_doubling_allgather(
/* TODO: Pipeline the packing and communication */
position = 0;
if (rank == root)
NMPI_Pack(buffer, count, datatype, tmp_buf, nbytes,
&position, comm);
if (rank == root) {
mpi_errno = MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes,
&position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
......@@ -576,8 +578,9 @@ static int MPIR_Bcast_scatter_doubling_allgather(
if (rank != root)
{
position = 0;
NMPI_Unpack(tmp_buf, nbytes, &position, buffer, count,
datatype, comm);
mpi_errno = MPIR_Unpack_impl(tmp_buf, nbytes, &position, buffer,
count, datatype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
......@@ -656,13 +659,11 @@ static int MPIR_Bcast_scatter_ring_allgather(
* heterogeneous systems. We want to use MPI_Type_size() wherever
* possible, and MPI_Pack_size() in other places.
*/
if (is_homogeneous) {
if (is_homogeneous)
MPID_Datatype_get_size_macro(datatype, type_size);
}
else {
mpi_errno = NMPI_Pack_size(1, datatype, comm, &type_size);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else
MPIR_Pack_size_impl(1, datatype, &type_size);
nbytes = type_size * count;
if (is_contig && is_homogeneous)
......@@ -678,9 +679,11 @@ static int MPIR_Bcast_scatter_ring_allgather(
/* TODO: Pipeline the packing and communication */
position = 0;
if (rank == root)
NMPI_Pack(buffer, count, datatype, tmp_buf, nbytes,
&position, comm);
if (rank == root) {
mpi_errno = MPIR_Pack_impl(buffer, count, datatype, tmp_buf, nbytes,
&position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
scatter_size = (nbytes + comm_size - 1)/comm_size; /* ceiling division */
......@@ -735,8 +738,9 @@ static int MPIR_Bcast_scatter_ring_allgather(
if (rank != root)
{
position = 0;
NMPI_Unpack(tmp_buf, nbytes, &position, buffer, count,
datatype, comm);
mpi_errno = MPIR_Unpack_impl(tmp_buf, nbytes, &position, buffer,
count, datatype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
......@@ -803,13 +807,11 @@ static int MPIR_SMP_Bcast(
* heterogeneous systems. We want to use MPI_Type_size() wherever
* possible, and MPI_Pack_size() in other places.
*/
if (is_homogeneous) {
if (is_homogeneous)
MPID_Datatype_get_size_macro(datatype, type_size);
}
else {
mpi_errno = NMPI_Pack_size(1, datatype, comm_ptr->handle, &type_size);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else
MPIR_Pack_size_impl(1, datatype, &type_size);
nbytes = type_size * count;
if ((nbytes < MPIR_BCAST_SHORT_MSG) || (comm_ptr->local_size < MPIR_BCAST_MIN_PROCS))
......@@ -1012,13 +1014,11 @@ int MPIR_Bcast_intra (
* heterogeneous systems. We want to use MPI_Type_size() wherever
* possible, and MPI_Pack_size() in other places.
*/
if (is_homogeneous) {
if (is_homogeneous)
MPID_Datatype_get_size_macro(datatype, type_size);
}
else {
mpi_errno = NMPI_Pack_size(1, datatype, comm, &type_size);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else
MPIR_Pack_size_impl(1, datatype, &type_size);
nbytes = type_size * count;
if ((nbytes < MPIR_BCAST_SHORT_MSG) || (comm_size < MPIR_BCAST_MIN_PROCS))
......
......@@ -318,26 +318,26 @@ int MPIR_Gather_intra (
else
{ /* communicator is heterogeneous. pack data into tmp_buf. */
if (rank == root)
NMPI_Pack_size(recvcnt*comm_size, recvtype, comm,
&tmp_buf_size);
MPIR_Pack_size_impl(recvcnt*comm_size, recvtype, &tmp_buf_size);
else
NMPI_Pack_size(sendcnt*(comm_size/2), sendtype, comm,
&tmp_buf_size);
MPIR_Pack_size_impl(sendcnt*(comm_size/2), sendtype, &tmp_buf_size);
MPIU_CHKLMEM_MALLOC(tmp_buf, void *, tmp_buf_size, mpi_errno, "tmp_buf");
position = 0;
if (sendbuf != MPI_IN_PLACE)
{
NMPI_Pack(sendbuf, sendcnt, sendtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(sendbuf, sendcnt, sendtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
nbytes = position;
}
else
{
/* do a dummy pack just to calculate nbytes */
NMPI_Pack(recvbuf, 1, recvtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(recvbuf, 1, recvtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
nbytes = position*recvcnt;
}
......@@ -381,21 +381,24 @@ int MPIR_Gather_intra (
if (sendbuf != MPI_IN_PLACE)
{
position = 0;
NMPI_Unpack(tmp_buf, tmp_buf_size, &position,
((char *) recvbuf + extent*recvcnt*rank),
recvcnt*(comm_size-rank), recvtype, comm);
mpi_errno = MPIR_Unpack_impl(tmp_buf, tmp_buf_size, &position,
((char *) recvbuf + extent*recvcnt*rank),
recvcnt*(comm_size-rank), recvtype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else
{
position = nbytes;
NMPI_Unpack(tmp_buf, tmp_buf_size, &position,
((char *) recvbuf + extent*recvcnt*(rank+1)),
recvcnt*(comm_size-rank-1), recvtype,
comm);
mpi_errno = MPIR_Unpack_impl(tmp_buf, tmp_buf_size, &position,
((char *) recvbuf + extent*recvcnt*(rank+1)),
recvcnt*(comm_size-rank-1), recvtype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
if (root != 0) {
mpi_errno = MPIR_Unpack_impl(tmp_buf, tmp_buf_size, &position, recvbuf,
recvcnt*rank, recvtype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
if (root != 0)
NMPI_Unpack(tmp_buf, tmp_buf_size, &position, recvbuf,
recvcnt*rank, recvtype, comm);
}
}
......
......@@ -218,7 +218,6 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
int tmpbuf_size = 0;
int tmpbuf_count = 0;
MPID_Comm *comm_ptr;
MPIU_THREADPRIV_DECL;
MPIU_CHKLMEM_DECL(1);
MPIDI_STATE_DECL(MPID_STATE_MPIC_SENDRECV_REPLACE);
#ifdef MPID_LOG_ARROWS
......@@ -227,24 +226,18 @@ int MPIC_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
#endif
MPIDI_PT2PT_FUNC_ENTER_BOTH(MPID_STATE_MPIC_SENDRECV_REPLACE);
MPIU_THREADPRIV_GET;
MPID_Comm_get_ptr( comm, comm_ptr );
context_id_offset = (comm_ptr->comm_kind == MPID_INTRACOMM) ?
MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
if (count > 0 && dest != MPI_PROC_NULL)
{
MPIR_Nest_incr();
mpi_errno = NMPI_Pack_size(count, datatype, comm, &tmpbuf_size);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIR_Pack_size_impl(count, datatype, &tmpbuf_size);
MPIU_CHKLMEM_MALLOC(tmpbuf, void *, tmpbuf_size, mpi_errno, "temporary send buffer");
mpi_errno = NMPI_Pack(buf, count, datatype, tmpbuf, tmpbuf_size, &tmpbuf_count, comm);
mpi_errno = MPIR_Pack_impl(buf, count, datatype, tmpbuf, tmpbuf_size, &tmpbuf_count);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIR_Nest_decr();
}
mpi_errno = MPID_Irecv(buf, count, datatype, source, recvtag,
......
......@@ -247,8 +247,7 @@ int MPIR_Scatter_intra (
#ifdef MPID_HAS_HETERO
else { /* communicator is heterogeneous */
if (rank == root) {
NMPI_Pack_size(sendcnt*comm_size, sendtype, comm,
&tmp_buf_size);
MPIR_Pack_size_impl(sendcnt*comm_size, sendtype, &tmp_buf_size);
MPIU_CHKLMEM_MALLOC(tmp_buf, void *, tmp_buf_size, mpi_errno, "tmp_buf");
......@@ -261,8 +260,9 @@ int MPIR_Scatter_intra (
tmp_buf and see by how much 'position' is incremented. */
position = 0;
NMPI_Pack(sendbuf, 1, sendtype, tmp_buf, tmp_buf_size,
&position, comm);
mpi_errno = MPIR_Pack_impl(sendbuf, 1, sendtype, tmp_buf, tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
nbytes = position*sendcnt;
curr_cnt = nbytes*comm_size;
......@@ -270,41 +270,46 @@ int MPIR_Scatter_intra (
if (root == 0) {
if (recvbuf != MPI_IN_PLACE) {
position = 0;
NMPI_Pack(sendbuf, sendcnt*comm_size, sendtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(sendbuf, sendcnt*comm_size, sendtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else {
position = nbytes;
NMPI_Pack(((char *) sendbuf + extent*sendcnt),
sendcnt*(comm_size-1), sendtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(((char *) sendbuf + extent*sendcnt),
sendcnt*(comm_size-1), sendtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
else {
if (recvbuf != MPI_IN_PLACE) {
position = 0;
NMPI_Pack(((char *) sendbuf + extent*sendcnt*rank),
sendcnt*(comm_size-rank), sendtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(((char *) sendbuf + extent*sendcnt*rank),
sendcnt*(comm_size-rank), sendtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
else {
position = nbytes;
NMPI_Pack(((char *) sendbuf + extent*sendcnt*(rank+1)),
sendcnt*(comm_size-rank-1), sendtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(((char *) sendbuf + extent*sendcnt*(rank+1)),
sendcnt*(comm_size-rank-1), sendtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
NMPI_Pack(sendbuf, sendcnt*rank, sendtype, tmp_buf,
tmp_buf_size, &position, comm);
mpi_errno = MPIR_Pack_impl(sendbuf, sendcnt*rank, sendtype, tmp_buf,
tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
else {
NMPI_Pack_size(recvcnt*(comm_size/2), recvtype, comm, &tmp_buf_size);
MPIR_Pack_size_impl(recvcnt*(comm_size/2), recvtype, &tmp_buf_size);
MPIU_CHKLMEM_MALLOC(tmp_buf, void *, tmp_buf_size, mpi_errno, "tmp_buf");
/* calculate nbytes */
position = 0;
NMPI_Pack(recvbuf, 1, recvtype, tmp_buf, tmp_buf_size,
&position, comm);
mpi_errno = MPIR_Pack_impl(recvbuf, 1, recvtype, tmp_buf, tmp_buf_size, &position);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
nbytes = position*recvcnt;
curr_cnt = 0;
......@@ -351,9 +356,11 @@ int MPIR_Scatter_intra (
/* copy local data into recvbuf */
position = 0;
if (recvbuf != MPI_IN_PLACE)
NMPI_Unpack(tmp_buf, tmp_buf_size, &position, recvbuf, recvcnt,
recvtype, comm);
if (recvbuf != MPI_IN_PLACE) {
mpi_errno = MPIR_Unpack_impl(tmp_buf, tmp_buf_size, &position, recvbuf,
recvcnt, recvtype);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
}
#endif /* MPID_HAS_HETERO */
......
......@@ -23,11 +23,92 @@
#undef MPI_Pack
#define MPI_Pack PMPI_Pack
#undef FUNCNAME
#define FUNCNAME MPIR_Pack_impl
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIR_Pack_impl(void *inbuf,
int incount,
MPI_Datatype datatype,
void *outbuf,
int outcount,
int *position)
{
int mpi_errno = MPI_SUCCESS;
MPI_Aint first, last;
MPID_Segment *segp;
int contig;
MPI_Aint dt_true_lb;
MPI_Aint data_sz;
if (incount == 0) {
goto fn_exit;
}
/* Handle contig case quickly */
if (HANDLE_GET_KIND(datatype) == HANDLE_KIND_BUILTIN) {
contig = TRUE;
dt_true_lb = 0;
data_sz = incount * MPID_Datatype_get_basic_size(datatype);