[mpich2-dev] [PATCH 1/1] Issue 4120: Fix mpid_type_debug alignment problem.

Bob Cernohous bobc at us.ibm.com
Wed Mar 19 09:11:59 CDT 2008


Can't just point to ints/aints in the datatype.  Have to figure out the
alignment.  Easiest way is to call MPIDI_Datatype_get_contents_xxxx().

Signed-off-by: Bob Cernohous <bobc at us.ibm.com>
---
 .../src/mpid/common/datatype/mpid_type_debug.c     |   46 +++++++++++++------
 1 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_debug.c b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_debug.c
index 1e3c761..71fafb7 100644
--- a/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_debug.c
+++ b/lib/mpi/mpich2/src/mpid/common/datatype/mpid_type_debug.c
@@ -494,6 +494,12 @@ static char *MPIDI_Datatype_depth_spacing(int depth)
 	default: return d5;
     }
 }
+    
+#define __mpidi_datatype_free_and_return { \
+ if (cp->nr_ints  > 0) MPIU_Free(ints );   \
+ if (cp->nr_aints > 0) MPIU_Free(aints);   \
+ if (cp->nr_types > 0) MPIU_Free(types);   \
+ return;                                 }
 
 void MPIDI_Datatype_contents_printf(MPI_Datatype type,
 				    int depth,
@@ -522,12 +528,22 @@ void MPIDI_Datatype_contents_printf(MPI_Datatype type,
 	return;
     }
 
-    types = (MPI_Datatype *) (((char *) cp) +
-			      sizeof(MPID_Datatype_contents));
-    ints  = (int *) (((char *) types) +
-		     cp->nr_types * sizeof(MPI_Datatype));
-    aints = (MPI_Aint *) (((char *) ints) +
-			  cp->nr_ints * sizeof(int));
+    if (cp->nr_ints > 0)
+    {
+      ints = (int*) MPIU_Malloc(cp->nr_ints * sizeof(int));
+      MPIDI_Datatype_get_contents_ints(cp, ints);
+    }
+
+    if (cp->nr_aints > 0) {
+      aints = (MPI_Aint*) MPIU_Malloc(cp->nr_aints * sizeof(MPI_Aint));
+      MPIDI_Datatype_get_contents_aints(cp, aints);
+    }
+
+    if (cp->nr_types > 0) {
+      types = (MPI_Datatype*) MPIU_Malloc(cp->nr_types * sizeof(MPI_Datatype));
+      MPIDI_Datatype_get_contents_types(cp, types);
+    }
+
 
     MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %scombiner: %s",
 		    MPIDI_Datatype_depth_spacing(depth),
@@ -536,10 +552,10 @@ void MPIDI_Datatype_contents_printf(MPI_Datatype type,
     switch (cp->combiner) {
 	case MPI_COMBINER_NAMED:
 	case MPI_COMBINER_DUP:
-	    return;
+	    __mpidi_datatype_free_and_return;
 	case MPI_COMBINER_RESIZED:
 	    /* not done */
-	    return;
+	    __mpidi_datatype_free_and_return;
 	case MPI_COMBINER_CONTIGUOUS:
 	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %scontig ct = %d\n", 
 			    MPIDI_Datatype_depth_spacing(depth),
@@ -547,7 +563,7 @@ void MPIDI_Datatype_contents_printf(MPI_Datatype type,
 	    MPIDI_Datatype_contents_printf(*types,
 					   depth + 1,
 					   acount);
-	    return;
+	    __mpidi_datatype_free_and_return;
 	case MPI_COMBINER_VECTOR:
 	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
 	                "# %svector ct = %d, blk = %d, str = %d\n",
@@ -558,7 +574,7 @@ void MPIDI_Datatype_contents_printf(MPI_Datatype type,
 	    MPIDI_Datatype_contents_printf(*types,
 					   depth + 1,
 					   acount);
-	    return;
+	    __mpidi_datatype_free_and_return;
         case MPI_COMBINER_HVECTOR:
 	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
 	                  "# %shvector ct = %d, blk = %d, str = " MPI_AINT_FMT_DEC_SPEC "\n",
@@ -569,7 +585,7 @@ void MPIDI_Datatype_contents_printf(MPI_Datatype type,
 	    MPIDI_Datatype_contents_printf(*types,
 					   depth + 1,
 					   acount);
-	    return;
+	    __mpidi_datatype_free_and_return;
 	case MPI_COMBINER_INDEXED:
 	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %sindexed ct = %d:",
 			    MPIDI_Datatype_depth_spacing(depth),
@@ -585,7 +601,7 @@ void MPIDI_Datatype_contents_printf(MPI_Datatype type,
 					       depth + 1,
 					       acount);
 	    }
-	    return;
+	    __mpidi_datatype_free_and_return;
 	case MPI_COMBINER_HINDEXED:
 	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %shindexed ct = %d:",
 			    MPIDI_Datatype_depth_spacing(depth),
@@ -601,7 +617,7 @@ void MPIDI_Datatype_contents_printf(MPI_Datatype type,
 					       depth + 1,
 					       acount);
 	    }
-	    return;
+	    __mpidi_datatype_free_and_return;
 	case MPI_COMBINER_STRUCT:
 	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %sstruct ct = %d:",
 			    MPIDI_Datatype_depth_spacing(depth),
@@ -617,11 +633,11 @@ void MPIDI_Datatype_contents_printf(MPI_Datatype type,
 					       depth + 1,
 					       acount);
 	    }
-	    return;
+	    __mpidi_datatype_free_and_return;
 	default:
 	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %sunhandled combiner",
 			MPIDI_Datatype_depth_spacing(depth)));
-	    return;
+	    __mpidi_datatype_free_and_return;
     }
 }
 /* --END ERROR HANDLING-- */
-- 
1.5.3.7




More information about the mpich2-dev mailing list