[mpich2-dev] [PATCH 2/4] Issue 4120: Fix BlueGene-specific ROMIO to pass a valid recvBuf to MPI_Alltoallv

Jeff Parker jjparker at us.ibm.com
Sun Mar 30 23:54:10 CDT 2008


Function ADIOI_BGL_Calc_others_req(), which I optimized a long time ago to 
use MPI_Alltoallv(), was passing in a recvBuf pointer = 0xFFFFFFFF if there 
was nothing to be received.  Before the MPI_Aint work, MPI_Alltoallv() 
ignored the recvBuf pointer if the recv counts were all zero.  But, the 
addition of the MPID_Ensure_Aint_fits_in_pointer() sanity checks checks 
the send and recv pointers no matter what, so a sane address is required.  
I think it is reasonable to send in a sane address, so I changed 
ADIOI_BGL_Calc_others_req() to send in a NULL pointer if there is nothing 
to receive.  This works in both 4 and 8 byte modes.  In 
ADIOI_BGL_Calc_others_req(), I also changed the pointer arithmetic to 
first cast to a new datatype MPI_Puint, which is an unsigned numeric type
that is the size of a pointer.  Also added a signed version for future use.

Signed-off-by: Jeff Parker <jjparker at us.ibm.com>
---
 lib/mpi/mpich2/configure.in                        |    6 +++
 lib/mpi/mpich2/src/include/mpi.h.in                |    2 +
 .../src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.c       |   37 +++++++++++++-------
 3 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/lib/mpi/mpich2/configure.in b/lib/mpi/mpich2/configure.in
index a75c2dc..a5abf78 100755
--- a/lib/mpi/mpich2/configure.in
+++ b/lib/mpi/mpich2/configure.in
@@ -4997,6 +4997,12 @@ for type in int long long_long short ; do
         break
     fi
 done
+# Set signed and unsigned pointer type
+MPI_PINT=$MPI_AINT
+MPI_PUINT="unsigned $MPI_AINT"
+AC_SUBST(MPI_PINT)
+AC_SUBST(MPI_PUINT)
+
 if test "$with_aint_size" == "0" ; then
     # use default size
     AC_MSG_RESULT([Default MPI_Aint $with_aint_size $MPI_SIZEOF_AINT])
diff --git a/lib/mpi/mpich2/src/include/mpi.h.in b/lib/mpi/mpich2/src/include/mpi.h.in
index 8973900..2250b59 100644
--- a/lib/mpi/mpich2/src/include/mpi.h.in
+++ b/lib/mpi/mpich2/src/include/mpi.h.in
@@ -300,6 +300,8 @@ typedef int MPI_Info;
 
 /* Definitions that are determined by configure. */
 typedef @MPI_AINT@ MPI_Aint;
+typedef @MPI_PINT@ MPI_Pint;
+typedef @MPI_PUINT@ MPI_Puint;
 typedef @MPI_FINT@ MPI_Fint;
 #define MPI_AINT_FMT_DEC_SPEC "@MPI_AINT_FMT_DEC_SPEC@"
 #define MPI_AINT_FMT_HEX_SPEC "@MPI_AINT_FMT_HEX_SPEC@"
diff --git a/lib/mpi/mpich2/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.c b/lib/mpi/mpich2/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.c
index 87da3ab..9a710c3 100644
--- a/lib/mpi/mpich2/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.c
+++ b/lib/mpi/mpich2/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.c
@@ -886,9 +886,9 @@ void ADIOI_BGL_Calc_others_req(ADIO_File fd, int count_my_req_procs,
 	    others_req[i].lens = (int *)
 		ADIOI_Malloc(count_others_req_per_proc[i]*sizeof(int)); 
 
-	    if ( (unsigned)others_req[i].offsets < (unsigned)recvBufForOffsets )
+	    if ( (MPI_Puint)others_req[i].offsets < (MPI_Puint)recvBufForOffsets )
 		recvBufForOffsets = others_req[i].offsets;
-	    if ( (unsigned)others_req[i].lens < (unsigned)recvBufForLens )
+	    if ( (MPI_Puint)others_req[i].lens < (MPI_Puint)recvBufForLens )
 		recvBufForLens = others_req[i].lens;
 
 	    others_req[i].mem_ptrs = (MPI_Aint *)
@@ -903,6 +903,9 @@ void ADIOI_BGL_Calc_others_req(ADIO_File fd, int count_my_req_procs,
 	    others_req[i].lens    = NULL;
 	}
     }
+    /* If no recv buffer was allocated in the loop above, make it NULL */
+    if ( recvBufForOffsets == (void*)0xFFFFFFFF) recvBufForOffsets = NULL;
+    if ( recvBufForLens    == (void*)0xFFFFFFFF) recvBufForLens    = NULL;
     
     /* Now send the calculated offsets and lengths to respective processes */
 
@@ -914,11 +917,11 @@ void ADIOI_BGL_Calc_others_req(ADIO_File fd, int count_my_req_procs,
     for (i=0; i<nprocs; i++)
     {
 	if ( (my_req[i].count) &&
-	     ((unsigned)my_req[i].offsets <= (unsigned)sendBufForOffsets) )
-	    sendBufForOffsets = my_req[i].offsets;
+	     ((MPI_Puint)my_req[i].offsets <= (MPI_Puint)sendBufForOffsets) )
+	  sendBufForOffsets = my_req[i].offsets;
 	   
 	if ( (my_req[i].count) &&
-	     ((unsigned)my_req[i].lens <= (unsigned)sendBufForLens) )
+	     ((MPI_Puint)my_req[i].lens <= (MPI_Puint)sendBufForLens) )
 	    sendBufForLens = my_req[i].lens;
     }
 
@@ -930,16 +933,20 @@ void ADIOI_BGL_Calc_others_req(ADIO_File fd, int count_my_req_procs,
 	if ( scounts[i] == 0 )
 	    sdispls[i] = 0;
 	else
-	    sdispls[i] = ( (unsigned)my_req[i].offsets - 
-			   (unsigned)sendBufForOffsets ) / sizeof(ADIO_Offset);
+  	  sdispls[i] =  (int)
+	                ( ( (MPI_Puint)my_req[i].offsets - 
+			   (MPI_Puint)sendBufForOffsets ) / 
+			  (MPI_Puint)sizeof(ADIO_Offset) );
 
 	// Receive these offsets from process i.
 	rcounts[i] = count_others_req_per_proc[i];
 	if ( rcounts[i] == 0 )
 	    rdispls[i] = 0;
 	else
-	    rdispls[i] = ( (unsigned)others_req[i].offsets - 
-			   (unsigned)recvBufForOffsets ) / sizeof(ADIO_Offset);
+	    rdispls[i] = (int)
+	                 ( ( (MPI_Puint)others_req[i].offsets - 
+			     (MPI_Puint)recvBufForOffsets ) / 
+			   (MPI_Puint)sizeof(ADIO_Offset) );
     }
 
     /* Exchange the offsets */
@@ -960,16 +967,20 @@ void ADIOI_BGL_Calc_others_req(ADIO_File fd, int count_my_req_procs,
 	if ( scounts[i] == 0 )
 	    sdispls[i] = 0;
 	else
-	    sdispls[i] = ( (unsigned)my_req[i].lens - 
-			   (unsigned)sendBufForLens ) / sizeof(int);
+	  sdispls[i] = (int)
+	               ( ( (MPI_Puint)my_req[i].lens - 
+			   (MPI_Puint)sendBufForLens ) / 
+			 (MPI_Puint) sizeof(int) );
 	
 	// Receive these offsets from process i.
 	rcounts[i] = count_others_req_per_proc[i];
 	if ( rcounts[i] == 0 )
 	    rdispls[i] = 0;
 	else
-	    rdispls[i] = ( (unsigned)others_req[i].lens - 
-			   (unsigned)recvBufForLens ) / sizeof(int);
+	    rdispls[i] = (int)
+	                 ( ( (MPI_Puint)others_req[i].lens - 
+			     (MPI_Puint)recvBufForLens ) / 
+			   (MPI_Puint) sizeof(int) );
     }
 
     /* Exchange the lengths */
-- 
1.5.3.7




More information about the mpich2-dev mailing list