[mpich-commits] r10634 - mpich2/trunk/src/mpi/datatype

goodell at mcs.anl.gov goodell at mcs.anl.gov
Tue Nov 20 16:20:54 CST 2012


Author: goodell
Date: 2012-11-20 16:20:54 -0600 (Tue, 20 Nov 2012)
New Revision: 10634

Modified:
   mpich2/trunk/src/mpi/datatype/type_create_darray.c
Log:
check rank and the product of array_of_psizes in MPI_Type_create_darray

Contributed by IBM.  Based on patch 0004 from code discussions.

Modified: mpich2/trunk/src/mpi/datatype/type_create_darray.c
===================================================================
--- mpich2/trunk/src/mpi/datatype/type_create_darray.c	2012-11-20 22:20:53 UTC (rev 10633)
+++ mpich2/trunk/src/mpi/datatype/type_create_darray.c	2012-11-20 22:20:54 UTC (rev 10634)
@@ -403,9 +403,11 @@
         MPID_BEGIN_ERROR_CHECKS;
         {
 	    /* Check parameters */
-	    MPIR_ERRTEST_ARGNEG(rank, "rank", mpi_errno);
-	    MPIR_ERRTEST_ARGNONPOS(size, "size", mpi_errno);
-	    MPIR_ERRTEST_ARGNONPOS(ndims, "ndims", mpi_errno);
+	    MPIR_ERRTEST_ARGNONPOS(size, "size", mpi_errno, MPI_ERR_ARG);
+            /* use MPI_ERR_RANK class for PE-MPI compatibility */
+            MPIU_ERR_CHKANDJUMP3((rank < 0 || rank >= size), mpi_errno, MPI_ERR_RANK,
+                                 "**argrange", "**argrange %s %d %d", "rank", rank, (size-1));
+	    MPIR_ERRTEST_ARGNONPOS(ndims, "ndims", mpi_errno, MPI_ERR_DIMS);
 
 	    MPIR_ERRTEST_ARGNULL(array_of_gsizes, "array_of_gsizes", mpi_errno);
 	    MPIR_ERRTEST_ARGNULL(array_of_distribs, "array_of_distribs", mpi_errno);
@@ -423,6 +425,7 @@
                 goto fn_fail;
 	    }
 
+            tmp_size = 1;
 	    for (i=0; mpi_errno == MPI_SUCCESS && i < ndims; i++) {
 		MPIR_ERRTEST_ARGNONPOS(array_of_gsizes[i], "gsize", mpi_errno);
 		MPIR_ERRTEST_ARGNONPOS(array_of_psizes[i], "psize", mpi_errno);
@@ -468,8 +471,13 @@
 						     i, array_of_psizes[i]);
                     goto fn_fail;
 		}
+
+                tmp_size *= array_of_psizes[i];
 	    }
 
+            MPIU_ERR_CHKANDJUMP1((tmp_size != size), mpi_errno, MPI_ERR_ARG,
+                                 "**arg", "**arg %s", "array_of_psizes");
+
 	    /* TODO: GET THIS CHECK IN ALSO */
 
 	    /* check if MPI_Aint is large enough for size of global array.



More information about the commits mailing list