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

balaji at mcs.anl.gov balaji at mcs.anl.gov
Fri Mar 6 07:30:35 CST 2009


Author: balaji
Date: 2009-03-06 07:30:35 -0600 (Fri, 06 Mar 2009)
New Revision: 3947

Modified:
   mpich2/trunk/src/mpi/coll/allgatherv.c
Log:
Bug fix to the allgatherv code that was happening because of message indices wrapping around.

Modified: mpich2/trunk/src/mpi/coll/allgatherv.c
===================================================================
--- mpich2/trunk/src/mpi/coll/allgatherv.c	2009-03-06 08:58:55 UTC (rev 3946)
+++ mpich2/trunk/src/mpi/coll/allgatherv.c	2009-03-06 13:30:35 UTC (rev 3947)
@@ -699,7 +699,7 @@
     else {
 	/* long message or medium-size message and non-power-of-two
 	 * no. of processes. Use ring algorithm. */
-	char * sbuf = NULL, * rbuf = NULL, * smsg, * rmsg;
+	char * sbuf = NULL, * rbuf = NULL;
         int soffset, roffset;
 	int torecv, tosend, min;
 	int sendnow, recvnow;
@@ -746,13 +746,18 @@
             sbuf = recvbuf + ((displs[sindex] + soffset) * recvtype_extent);
             rbuf = recvbuf + ((displs[rindex] + roffset) * recvtype_extent);
 
+            /* Protect against wrap-around of indices */
+            if (!tosend)
+                sendnow = 0;
+            if (!torecv)
+                recvnow = 0;
+
 	    /* Communicate */
 	    if (!sendnow && !recvnow) {
 		/* Don't do anything. This case is possible if two
 		 * consecutive processes contribute 0 bytes each. */
 	    }
 	    else if (!sendnow) { /* If there's no data to send, just do a recv call */
-		MPIU_Assert(recvnow > 0);
 		mpi_errno = MPIC_Recv(rbuf, recvnow, recvtype, left, MPIR_ALLGATHERV_TAG, comm, &status);
 		/* --BEGIN ERROR HANDLING-- */
 		if (mpi_errno)
@@ -764,7 +769,6 @@
 		torecv -= recvnow;
 	    }
 	    else if (!recvnow) { /* If there's no data to receive, just do a send call */
-		MPIU_Assert(sendnow > 0);
 		mpi_errno = MPIC_Send(sbuf, sendnow, recvtype, right, MPIR_ALLGATHERV_TAG, comm);
 		/* --BEGIN ERROR HANDLING-- */
 		if (mpi_errno)
@@ -776,8 +780,6 @@
 		tosend -= sendnow;
 	    }
 	    else { /* There's data to be sent and received */
-		MPIU_Assert(sendnow > 0);
-		MPIU_Assert(recvnow > 0);
 		mpi_errno = MPIC_Sendrecv(sbuf, sendnow, recvtype, right, MPIR_ALLGATHERV_TAG, 
 					  rbuf, recvnow, recvtype, left, MPIR_ALLGATHERV_TAG,
 					  comm, &status);



More information about the mpich2-commits mailing list