[mpich2-commits] r7745 - mpich2/trunk/src/mpi/coll

balaji at mcs.anl.gov balaji at mcs.anl.gov
Tue Jan 18 16:17:25 CST 2011


Author: balaji
Date: 2011-01-18 16:17:25 -0600 (Tue, 18 Jan 2011)
New Revision: 7745

Modified:
   mpich2/trunk/src/mpi/coll/alltoallv.c
   mpich2/trunk/src/mpi/coll/alltoallw.c
Log:
Check for the datatype count and size to be zero before deciding
whether to send/recv a message or not. This occurs if an alltoallv/w
uses zero-count on one process and non-zero-count, but zero size
datatype (MPI_DATATYPE_NULL) on another process.

Reviewed by buntinas.

Modified: mpich2/trunk/src/mpi/coll/alltoallv.c
===================================================================
--- mpich2/trunk/src/mpi/coll/alltoallv.c	2011-01-18 22:17:21 UTC (rev 7744)
+++ mpich2/trunk/src/mpi/coll/alltoallv.c	2011-01-18 22:17:25 UTC (rev 7745)
@@ -67,7 +67,7 @@
 	MPID_Comm *comm_ptr )
 {
     int        comm_size, i, j;
-    MPI_Aint   send_extent, recv_extent;
+    MPI_Aint   send_extent, recv_extent, send_size, recv_size;
     int        mpi_errno = MPI_SUCCESS;
     MPI_Status *starray;
     MPI_Status status;
@@ -86,6 +86,8 @@
     /* Get extent of send and recv types */
     MPID_Datatype_get_extent_macro(sendtype, send_extent);
     MPID_Datatype_get_extent_macro(recvtype, recv_extent);
+    MPID_Datatype_get_size_macro(sendtype, send_size);
+    MPID_Datatype_get_size_macro(recvtype, recv_size);
     
     /* check if multiple threads are calling this collective function */
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
@@ -103,7 +105,7 @@
         for (i = 0; i < comm_size; ++i) {
             /* start inner loop at i to avoid re-exchanging data */
             for (j = i; j < comm_size; ++j) {
-                if (rank == i && recvcnts[j]) {
+                if (rank == i && (recvcnts[j] * recv_size)) {
                     /* also covers the (rank == i && rank == j) case */
                     mpi_errno = MPIC_Sendrecv_replace(((char *)recvbuf + rdispls[j]*recv_extent),
                                                       recvcnts[j], recvtype,
@@ -112,7 +114,7 @@
                                                       comm, &status);
                     if (mpi_errno) MPIU_ERR_POP(mpi_errno);
                 }
-                else if (rank == j && recvcnts[i]) {
+                else if (rank == j && (recvcnts[i] * recv_size)) {
                     /* same as above with i/j args reversed */
                     mpi_errno = MPIC_Sendrecv_replace(((char *)recvbuf + rdispls[i]*recv_extent),
                                                       recvcnts[i], recvtype,
@@ -139,7 +141,7 @@
             /* do the communication -- post ss sends and receives: */
             for ( i=0; i<ss; i++ ) { 
                 dst = (rank+i+ii) % comm_size;
-                if (recvcnts[dst]) {
+                if (recvcnts[dst] * recv_size) {
                     MPID_Datatype_get_size_macro(recvtype, type_size);
                     if (type_size) {
                         MPID_Ensure_Aint_fits_in_pointer(MPI_VOID_PTR_CAST_TO_MPI_AINT recvbuf +
@@ -156,7 +158,7 @@
 
             for ( i=0; i<ss; i++ ) { 
                 dst = (rank-i-ii+comm_size) % comm_size;
-                if (sendcnts[dst]) {
+                if (sendcnts[dst] * send_size) {
                     MPID_Datatype_get_size_macro(sendtype, type_size);
                     if (type_size) {
                         MPID_Ensure_Aint_fits_in_pointer(MPI_VOID_PTR_CAST_TO_MPI_AINT sendbuf +
@@ -228,7 +230,7 @@
 
 */
     int local_size, remote_size, max_size, i;
-    MPI_Aint   send_extent, recv_extent;
+    MPI_Aint   send_extent, recv_extent, send_size, recv_size;
     int        mpi_errno = MPI_SUCCESS;
     MPI_Status status;
     int src, dst, rank, sendcount, recvcount;
@@ -243,6 +245,8 @@
     /* Get extent of send and recv types */
     MPID_Datatype_get_extent_macro(sendtype, send_extent);
     MPID_Datatype_get_extent_macro(recvtype, recv_extent);
+    MPID_Datatype_get_size_macro(sendtype, send_size);
+    MPID_Datatype_get_size_macro(recvtype, recv_size);
     
     /* check if multiple threads are calling this collective function */
     MPIDU_ERR_CHECK_MULTIPLE_THREADS_ENTER( comm_ptr );
@@ -275,9 +279,9 @@
             sendcount = sendcnts[dst];
         }
 
-        if (sendcount == 0)
+        if (sendcount * send_size == 0)
             dst = MPI_PROC_NULL;
-        if (recvcount == 0)
+        if (recvcount * recv_size == 0)
             src = MPI_PROC_NULL;
         mpi_errno = MPIC_Sendrecv(sendaddr, sendcount, sendtype, dst, 
                                   MPIR_ALLTOALLV_TAG, recvaddr, recvcount, 

Modified: mpich2/trunk/src/mpi/coll/alltoallw.c
===================================================================
--- mpich2/trunk/src/mpi/coll/alltoallw.c	2011-01-18 22:17:21 UTC (rev 7744)
+++ mpich2/trunk/src/mpi/coll/alltoallw.c	2011-01-18 22:17:25 UTC (rev 7745)
@@ -72,6 +72,7 @@
     int outstanding_requests;
     int ii, ss, bblock;
     int type_size;
+    MPI_Aint size1, size2;
     MPIU_CHKLMEM_DECL(2);
     
     comm = comm_ptr->handle;
@@ -94,7 +95,11 @@
         for (i = 0; i < comm_size; ++i) {
             /* start inner loop at i to avoid re-exchanging data */
             for (j = i; j < comm_size; ++j) {
-                if (rank == i && recvcnts[j]) {
+                /* Get size of recv types */
+                MPID_Datatype_get_size_macro(recvtypes[i], size1);
+                MPID_Datatype_get_size_macro(recvtypes[j], size2);
+
+                if (rank == i && (recvcnts[j] * size2)) {
                     /* also covers the (rank == i && rank == j) case */
                     mpi_errno = MPIC_Sendrecv_replace(((char *)recvbuf + rdispls[j]),
                                                       recvcnts[j], recvtypes[j],
@@ -107,7 +112,7 @@
                         MPIU_ERR_ADD(mpi_errno_ret, mpi_errno);
                     }
                 }
-                else if (rank == j && recvcnts[i]) {
+                else if (rank == j && (recvcnts[i] * size1)) {
                     /* same as above with i/j args reversed */
                     mpi_errno = MPIC_Sendrecv_replace(((char *)recvbuf + rdispls[i]),
                                                       recvcnts[i], recvtypes[i],
@@ -262,6 +267,7 @@
     int src, dst, rank, sendcount, recvcount;
     char *sendaddr, *recvaddr;
     MPI_Datatype sendtype, recvtype;
+    MPI_Aint send_size, recv_size;
     MPI_Comm comm;
     
     local_size = comm_ptr->local_size; 
@@ -300,9 +306,12 @@
             sendtype = sendtypes[dst];
         }
 
-        if (sendcount == 0)
+        MPID_Datatype_get_size_macro(sendtypes[dst], send_size);
+        MPID_Datatype_get_size_macro(recvtypes[src], recv_size);
+
+        if (sendcount * send_size == 0)
             dst = MPI_PROC_NULL;
-        if (recvcount == 0)
+        if (recvcount * recv_size == 0)
             src = MPI_PROC_NULL;
         mpi_errno = MPIC_Sendrecv(sendaddr, sendcount, sendtype, 
                                   dst, MPIR_ALLTOALLW_TAG, recvaddr, 



More information about the mpich2-commits mailing list