[mpich2-commits] r3939 - in mpich2/trunk: src/mpid/common/datatype/dataloop test/mpi/datatype

goodell at mcs.anl.gov goodell at mcs.anl.gov
Thu Mar 5 12:47:55 CST 2009


Author: goodell
Date: 2009-03-05 12:47:55 -0600 (Thu, 05 Mar 2009)
New Revision: 3939

Modified:
   mpich2/trunk/src/mpid/common/datatype/dataloop/dataloop_create_struct.c
   mpich2/trunk/test/mpi/datatype/hvector-zeros.c
Log:
Followup to r3927 (hvector assert bug).

This adds augments the hvector-zeros test to include all zero count arguments
and then fixes the resulting bug in the dataloop code.  This is a tweaked
version of Rob Ross' patch.

No reviewer.

Modified: mpich2/trunk/src/mpid/common/datatype/dataloop/dataloop_create_struct.c
===================================================================
--- mpich2/trunk/src/mpid/common/datatype/dataloop/dataloop_create_struct.c	2009-03-04 23:02:37 UTC (rev 3938)
+++ mpich2/trunk/src/mpid/common/datatype/dataloop/dataloop_create_struct.c	2009-03-05 18:47:55 UTC (rev 3939)
@@ -576,8 +576,9 @@
 
             DLOOP_Handle_get_size_macro(oldtypes[i], sz);
 
-            /* if the derived type has some data to contribute, add to flattened representation */
-            if ((blklens[i] > 0) && (sz > 0)) {
+            /* if the derived type has some data to contribute,
+             * add to flattened representation */
+            if (sz > 0) {
                 PREPEND_PREFIX(Segment_init)(NULL,
                                              (DLOOP_Count) blklens[i],
                                              oldtypes[i],
@@ -595,11 +596,28 @@
         }
     }
 
+    /* it's possible for us to get to this point only to realize that
+     * there isn't any data in this type. in that case do what we always
+     * do: store a simple contig of zero ints and call it done.
+     */
+    if (nr_blks == 0) {
+	PREPEND_PREFIX(Segment_free)(segp);
+	err = PREPEND_PREFIX(Dataloop_create_contiguous)(0,
+							 MPI_INT,
+							 dlp_p,
+							 dlsz_p,
+							 dldepth_p,
+							 flag);
+	return err;
+
+    }
+
     nr_blks += 2; /* safety measure */
 
     tmp_blklens = (int *) DLOOP_Malloc(nr_blks * sizeof(int));
     /* --BEGIN ERROR HANDLING-- */
     if (!tmp_blklens) {
+	PREPEND_PREFIX(Segment_free)(segp);
 	return DLOOP_Dataloop_create_struct_memory_error();
     }
     /* --END ERROR HANDLING-- */
@@ -609,6 +627,7 @@
     /* --BEGIN ERROR HANDLING-- */
     if (!tmp_disps) {
 	DLOOP_Free(tmp_blklens);
+	PREPEND_PREFIX(Segment_free)(segp);
 	return DLOOP_Dataloop_create_struct_memory_error();
     }
     /* --END ERROR HANDLING-- */
@@ -617,6 +636,12 @@
     first_ind = 0;
     for (i=0; i < count; i++)
     {
+	int is_basic;
+	DLOOP_Count sz = -1;
+
+	is_basic = (DLOOP_Handle_hasloop_macro(oldtypes[i])) ? 0 : 1;
+	if (!is_basic) DLOOP_Handle_get_size_macro(oldtypes[i], sz);
+
 	/* we're going to use the segment code to flatten the type.
 	 * we put in our displacement as the buffer location, and use
 	 * the blocklength as the count value to get N contiguous copies
@@ -625,7 +650,10 @@
 	 * Note that we're going to get back values in bytes, so that will
 	 * be our new element type.
 	 */
-	if (oldtypes[i] != MPI_UB && oldtypes[i] != MPI_LB && blklens[i] != 0)
+	if (oldtypes[i] != MPI_UB &&
+	    oldtypes[i] != MPI_LB &&
+	    blklens[i] != 0 &&
+	    (is_basic || sz > 0))
 	{
 	    PREPEND_PREFIX(Segment_init)((char *) MPI_AINT_CAST_TO_VOID_PTR disps[i],
 					 (DLOOP_Count) blklens[i],

Modified: mpich2/trunk/test/mpi/datatype/hvector-zeros.c
===================================================================
--- mpich2/trunk/test/mpi/datatype/hvector-zeros.c	2009-03-04 23:02:37 UTC (rev 3938)
+++ mpich2/trunk/test/mpi/datatype/hvector-zeros.c	2009-03-05 18:47:55 UTC (rev 3939)
@@ -34,6 +34,23 @@
         MPI_Type_free(&vecs[i]);
     }
 
+    /* this time with the first argument always 0 */
+    for(i = 0; i < 3; i++)
+    {
+        MPI_Type_hvector(0, 1, stride, MPI_INT, &vecs[i]);
+        MPI_Type_commit(&vecs[i]);
+        blockcount[i]=1;
+    }
+    displs[0]=0; displs[1]=-100; displs[2]=-200; /* irrelevant */
+
+    MPI_Type_struct(3, blockcount, displs, vecs, &mystruct);
+    MPI_Type_commit(&mystruct);
+
+    MPI_Type_free(&mystruct);
+    for(i = 0; i < 3; i++)
+    {
+        MPI_Type_free(&vecs[i]);
+    }
     printf(" No Errors\n");
 
     MPI_Finalize();



More information about the mpich2-commits mailing list