[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.1.1-7-g3b9d2b3

Service Account noreply at mpich.org
Wed Jun 11 11:00:04 CDT 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  3b9d2b36bc4066c5505d5a758b88359ea107d201 (commit)
       via  5b4bdef9b128518a5edab138c27cca1ceadef4c0 (commit)
       via  40862985af601cf019e9201c6eb9f5e1c4534b38 (commit)
      from  00f452cd0738129a19a8782766981a464ae9cfad (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/3b9d2b36bc4066c5505d5a758b88359ea107d201

commit 3b9d2b36bc4066c5505d5a758b88359ea107d201
Author: Wesley Bland <wbland at anl.gov>
Date:   Tue Jun 10 09:34:01 2014 -0500

    Fix coll6 test to use MPI_IN_PLACE when necessary
    
    The test source:test/mpi/coll/coll6.c was sometimes aliasing buffers
    incorrectly. This adds a check for that and uses MPI_IN_PLACE when
    appropriate.
    
    Signed-off-by: Antonio J. Pena <apenya at mcs.anl.gov>

diff --git a/test/mpi/coll/coll6.c b/test/mpi/coll/coll6.c
index 6e8ea36..666b2ee 100644
--- a/test/mpi/coll/coll6.c
+++ b/test/mpi/coll/coll6.c
@@ -53,9 +53,14 @@ int main( int argc, char **argv )
 	  table[i][j] = rank + 10;
       
       /* Everybody gets the gathered data */
-      MPI_Allgatherv(&table[begin_row][0], send_count, MPI_INT, 
-		     &table[0][0], recv_counts, displs, 
-                     MPI_INT, test_comm);
+      if ((char *) &table[begin_row][0] != (char *) table + displs[rank]*sizeof(int))
+          MPI_Allgatherv(&table[begin_row][0], send_count, MPI_INT,
+                         &table[0][0], recv_counts, displs,
+                         MPI_INT, test_comm);
+      else
+          MPI_Allgatherv(MPI_IN_PLACE, send_count, MPI_INT,
+                         &table[0][0], recv_counts, displs,
+                         MPI_INT, test_comm);
 
       /* Everybody should have the same table now.
 

http://git.mpich.org/mpich.git/commitdiff/5b4bdef9b128518a5edab138c27cca1ceadef4c0

commit 5b4bdef9b128518a5edab138c27cca1ceadef4c0
Author: Wesley Bland <wbland at anl.gov>
Date:   Thu May 22 10:42:05 2014 -0500

    Add tests for new buffer aliasing checks
    
    Added tests to the existing test suite. Usually these tests are next to
    existing MPI_IN_PLACE tests to make sure that the IN_PLACE checks are correct.
    For the nonblocking tests, they are all in one big test (nonblocking4) since
    the other nonblocking tests were already in that format.
    
    Fixes #2049
    
    Signed-off-by: Antonio J. Pena <apenya at mcs.anl.gov>

diff --git a/test/mpi/coll/Makefile.am b/test/mpi/coll/Makefile.am
index 98264a4..7368173 100644
--- a/test/mpi/coll/Makefile.am
+++ b/test/mpi/coll/Makefile.am
@@ -70,6 +70,7 @@ noinst_PROGRAMS =      \
     nonblocking        \
     nonblocking2       \
     nonblocking3       \
+    nonblocking4       \
     op_commutative     \
     opband             \
     opbor              \
diff --git a/test/mpi/coll/allgather2.c b/test/mpi/coll/allgather2.c
index edb907d..66a21ec 100644
--- a/test/mpi/coll/allgather2.c
+++ b/test/mpi/coll/allgather2.c
@@ -50,7 +50,18 @@ int main( int argc, char **argv )
 
 	MTestFreeComm( &comm );
     }
-    
+
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    MPI_Comm_size(MPI_COMM_WORLD, &size);
+    vecout = (double *) malloc(size * sizeof(double));
+    if (MPI_SUCCESS == MPI_Allgather(&vecout[rank], 1, MPI_DOUBLE,
+                                      vecout, 1, MPI_DOUBLE, MPI_COMM_WORLD))
+        errs++;
+    free(vecout);
+#endif
+
     MTest_Finalize( errs );
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/coll/allgatherv2.c b/test/mpi/coll/allgatherv2.c
index 4a54344..678193c 100644
--- a/test/mpi/coll/allgatherv2.c
+++ b/test/mpi/coll/allgatherv2.c
@@ -57,11 +57,21 @@ int main( int argc, char **argv )
             }
             free( vecout );
         }
+
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+        MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+        vecout = (double *) malloc(size * sizeof(double));
+        if (MPI_SUCCESS == MPI_Allgatherv(&vecout[rank * recvcounts[rank]], recvcounts[rank], MPI_DOUBLE,
+                                           vecout, recvcounts, displs, MPI_DOUBLE, comm))
+            errs++;
+        free(vecout);
+#endif
+
 	free( displs );
 	free( recvcounts );
 	MTestFreeComm( &comm );
     }
-    
+
     MTest_Finalize( errs );
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/coll/allred6.c b/test/mpi/coll/allred6.c
index ba829e1..65629de 100644
--- a/test/mpi/coll/allred6.c
+++ b/test/mpi/coll/allred6.c
@@ -67,6 +67,14 @@ int main( int argc, char *argv[] )
     }
     MPI_Op_free( &op );
 
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+    /* Check to make sure that aliasing is disallowed correctly */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    if (MPI_SUCCESS == MPI_Allreduce(&rank, &rank, 1, MPI_INT, MPI_OP_NULL, MPI_COMM_WORLD))
+        errs++;
+#endif
+
     MTest_Finalize( errs );
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/coll/alltoall1.c b/test/mpi/coll/alltoall1.c
index cd6d3d8..4d400cf 100644
--- a/test/mpi/coll/alltoall1.c
+++ b/test/mpi/coll/alltoall1.c
@@ -115,6 +115,14 @@ int main( int argc, char *argv[] )
 	MTestFreeComm( &comm );
     }
 
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+    /* Check to make sure that aliasing is disallowed correctly */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    if (MPI_SUCCESS == MPI_Alltoall(&rank, 1, MPI_INT, &rank, 1, MPI_INT, MPI_COMM_WORLD))
+        errs++;
+#endif
+
     MTest_Finalize( errs );
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/coll/alltoallv.c b/test/mpi/coll/alltoallv.c
index bcae133..435b3c3 100644
--- a/test/mpi/coll/alltoallv.c
+++ b/test/mpi/coll/alltoallv.c
@@ -122,6 +122,12 @@ int main( int argc, char **argv )
           }
         }
       }
+
+      /* Check to make sure that aliasing is disallowed correctly */
+      MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+      if (MPI_SUCCESS == MPI_Alltoallv(rbuf, recvcounts, rdispls, MPI_INT,
+                                       rbuf, recvcounts, rdispls, MPI_INT, comm))
+          err++;
 #endif
 
       free( rdispls );
diff --git a/test/mpi/coll/alltoallw2.c b/test/mpi/coll/alltoallw2.c
index 7d40236..e2c7d5f 100644
--- a/test/mpi/coll/alltoallw2.c
+++ b/test/mpi/coll/alltoallw2.c
@@ -133,6 +133,11 @@ int main( int argc, char **argv )
           }
         }
       }
+
+      MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+      if (MPI_SUCCESS == MPI_Alltoallw(rbuf, recvcounts, rdispls, recvtypes,
+                                       rbuf, recvcounts, rdispls, recvtypes, comm))
+          err++;
 #endif
 
       free(recvtypes);
diff --git a/test/mpi/coll/exscan.c b/test/mpi/coll/exscan.c
index 70f4c53..64ab9d5 100644
--- a/test/mpi/coll/exscan.c
+++ b/test/mpi/coll/exscan.c
@@ -84,6 +84,11 @@ int main( int argc, char *argv[] )
                     }
                 }
             }
+
+            MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+            /* Make sure that we check for buffer aliasing properly */
+            if (MPI_SUCCESS == MPI_Exscan( recvbuf, recvbuf, count, MPI_INT, MPI_SUM, comm ))
+                errs++;
 #endif
 
 	    free( sendbuf );
diff --git a/test/mpi/coll/gather.c b/test/mpi/coll/gather.c
index 7433caa..e14503f 100644
--- a/test/mpi/coll/gather.c
+++ b/test/mpi/coll/gather.c
@@ -66,6 +66,16 @@ int main( int argc, char **argv )
     /* do a zero length gather */
     MPI_Gather( NULL, 0, MPI_BYTE, NULL, 0, MPI_BYTE, 0, MPI_COMM_WORLD );
 
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+    /* Check to make sure that aliasing is disallowed correctly */
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+    if (0 == rank)
+        if (MPI_SUCCESS == MPI_Gather(&rank, 1, MPI_INT,
+                                      &rank, 1, MPI_INT, 0, MPI_COMM_WORLD))
+            errs++;
+#endif
+
     MTest_Finalize( errs );
     MPI_Finalize();
     return 0;
diff --git a/test/mpi/coll/iallred.c b/test/mpi/coll/iallred.c
index 2542a3f..d90cacf 100644
--- a/test/mpi/coll/iallred.c
+++ b/test/mpi/coll/iallred.c
@@ -24,6 +24,8 @@ int main(int argc, char *argv[])
     MPI_Request request;
     int size, rank;
     int one = 1, two = 2, isum, sum;
+    int errs = 0;
+
     MPI_Init(&argc,&argv);
     MPI_Comm_size(MPI_COMM_WORLD, &size);
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -35,7 +37,14 @@ int main(int argc, char *argv[])
 
     assert(isum == 2);
     assert(sum == 4);
-    if (rank == 0)
+
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    if (MPI_SUCCESS == MPI_Iallreduce(&one, &one, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &request))
+        errs++;
+#endif
+
+    if (rank == 0 && errs == 0)
         printf(" No errors\n");
 #endif
 
diff --git a/test/mpi/coll/nonblocking4.c b/test/mpi/coll/nonblocking4.c
new file mode 100644
index 0000000..d977406
--- /dev/null
+++ b/test/mpi/coll/nonblocking4.c
@@ -0,0 +1,164 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *  (C) 2010 by Argonne National Laboratory.
+ *      See COPYRIGHT in top-level directory.
+ */
+
+/* This is a very weak sanity test that all nonblocking collectives specified by
+ * MPI-3 are present in the library and take arguments as expected.  This test
+ * does not check for progress, matching issues, or sensible output buffer
+ * values. */
+
+#include "mpi.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpitest.h"
+/* USE_STRICT_MPI may be defined in mpitestconf.h */
+#include "mpitestconf.h"
+
+#define NUM_INTS (2)
+
+#define my_assert(cond_)                                                  \
+    do {                                                                  \
+        if (!(cond_)) {                                                   \
+            fprintf(stderr, "assertion (%s) failed, aborting\n", #cond_); \
+            MPI_Abort(MPI_COMM_WORLD, 1);                                 \
+        }                                                                 \
+    } while (0)
+
+int main(int argc, char **argv)
+{
+    int errs = 0;
+    int i;
+    int rank, size;
+    int *sbuf = NULL;
+    int *rbuf = NULL;
+    int *scounts = NULL;
+    int *rcounts = NULL;
+    int *sdispls = NULL;
+    int *rdispls = NULL;
+    int *types = NULL;
+    MPI_Comm comm;
+    MPI_Request req;
+
+    /* intentionally not using MTest_Init/MTest_Finalize in order to make it
+     * easy to take this test and use it as an NBC sanity test outside of the
+     * MPICH test suite */
+    MPI_Init(&argc, &argv);
+
+    comm = MPI_COMM_WORLD;
+
+    MPI_Comm_size(comm, &size);
+    MPI_Comm_rank(comm, &rank);
+
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+
+#if !defined(USE_STRICT_MPI) && defined(MPICH)
+    /* enough space for every process to contribute at least NUM_INTS ints to any
+     * collective operation */
+    sbuf = malloc(NUM_INTS*size*sizeof(int));
+    my_assert(sbuf);
+    rbuf = malloc(NUM_INTS*size*sizeof(int));
+    my_assert(rbuf);
+    scounts = malloc(size*sizeof(int));
+    my_assert(scounts);
+    rcounts = malloc(size*sizeof(int));
+    my_assert(rcounts);
+    sdispls = malloc(size*sizeof(int));
+    my_assert(sdispls);
+    rdispls = malloc(size*sizeof(int));
+    my_assert(rdispls);
+    types = malloc(size*sizeof(int));
+    my_assert(types);
+
+    for (i = 0; i < size; ++i) {
+        sbuf[2*i]   = i;
+        sbuf[2*i+1] = i;
+        rbuf[2*i]   = i;
+        rbuf[2*i+1] = i;
+        scounts[i]  = NUM_INTS;
+        rcounts[i]  = NUM_INTS;
+        sdispls[i]  = i * NUM_INTS;
+        rdispls[i]  = i * NUM_INTS;
+        types[i]    = MPI_INT;
+    }
+
+    if (rank == 0 && MPI_SUCCESS ==
+            MPI_Igather(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
+        errs++;
+
+    if (rank == 0 && MPI_SUCCESS ==
+            MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, sbuf, rcounts, rdispls, MPI_INT, 0, comm, &req))
+        errs++;
+
+    if (rank == 0 && MPI_SUCCESS ==
+            MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
+        errs++;
+
+    if (rank == 0 && MPI_SUCCESS ==
+            MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Iallgather(&sbuf[rank], 1, MPI_INT, sbuf, 1, MPI_INT, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Iallgatherv(&sbuf[rank * rcounts[rank]], rcounts[rank], MPI_INT, sbuf, rcounts, rdispls, MPI_INT, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, sbuf, scounts, sdispls, MPI_INT, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Ialltoallw(sbuf, scounts, sdispls, types, sbuf, scounts, sdispls, types, comm, &req))
+        errs++;
+
+    if (rank == 0 && MPI_SUCCESS ==
+            MPI_Ireduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Iallreduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Ireduce_scatter(sbuf, sbuf, rcounts, MPI_INT, MPI_SUM, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Ireduce_scatter_block(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Iscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
+        errs++;
+
+    if (MPI_SUCCESS ==
+            MPI_Iexscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
+        errs++;
+
+#endif
+
+    if (sbuf) free(sbuf);
+    if (rbuf) free(rbuf);
+    if (scounts) free(scounts);
+    if (rcounts) free(rcounts);
+    if (sdispls) free(sdispls);
+    if (rdispls) free(rdispls);
+
+    if (rank == 0) {
+        if (errs)
+            fprintf(stderr, "Found %d errors\n", errs);
+        else
+            printf(" No errors\n");
+    }
+    MPI_Finalize();
+    return 0;
+}
+
diff --git a/test/mpi/coll/red3.c b/test/mpi/coll/red3.c
index 32358d9..7835b64 100644
--- a/test/mpi/coll/red3.c
+++ b/test/mpi/coll/red3.c
@@ -182,6 +182,16 @@ int main( int argc, char *argv[] )
 	    if (rank == root) {
 		errs += isShiftLeft( comm, bufout );
 	    }
+
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+            /* Try one more time without IN_PLACE to make sure we check
+             * aliasing correctly */
+            if (rank == root) {
+                MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+                if (MPI_SUCCESS == MPI_Reduce( bufout, bufout, count, mattype, op, root, comm ))
+                    errs++;
+            }
+#endif
 	}
 
 	free( buf );
diff --git a/test/mpi/coll/red_scat_block.c b/test/mpi/coll/red_scat_block.c
index 3092c8d..a2f20a0 100644
--- a/test/mpi/coll/red_scat_block.c
+++ b/test/mpi/coll/red_scat_block.c
@@ -66,6 +66,11 @@ int main(int argc, char **argv)
         fprintf(stdout, "Did not get expected value for reduce scatter block\n");
         fprintf(stdout, "[%d] Got %d expected %d\n", rank, recvbuf[0], sumval);
     }
+
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    if (MPI_SUCCESS == MPI_Reduce_scatter_block(recvbuf, recvbuf, 1, MPI_INT, MPI_SUM, comm))
+        err++;
+
     free(recvbuf);
 #endif
 
diff --git a/test/mpi/coll/redscat3.c b/test/mpi/coll/redscat3.c
index d2ed7ec..5efbd37 100644
--- a/test/mpi/coll/redscat3.c
+++ b/test/mpi/coll/redscat3.c
@@ -80,6 +80,7 @@ int main( int argc, char **argv )
 	}
     }
 
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
     MPI_Reduce_scatter( MPI_IN_PLACE, sendbuf, recvcounts, MPI_INT, MPI_SUM, 
 			comm );
 
@@ -96,6 +97,11 @@ int main( int argc, char **argv )
 	}
     }
 
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    if (MPI_SUCCESS == MPI_Reduce_scatter(sendbuf, sendbuf, recvcounts, MPI_INT, MPI_SUM, comm))
+        err++;
+#endif
+
     free(sendbuf);
     free(recvbuf);
     free(recvcounts);
diff --git a/test/mpi/coll/reduce.c b/test/mpi/coll/reduce.c
index 6106782..ad09c9b 100644
--- a/test/mpi/coll/reduce.c
+++ b/test/mpi/coll/reduce.c
@@ -48,6 +48,15 @@ int main( int argc, char *argv[] )
 	    free( sendbuf );
 	    free( recvbuf );
 	}
+
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+        if (0 == rank) {
+            MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+            if (MPI_SUCCESS == MPI_Reduce(&rank, &rank, 1, MPI_INT, MPI_SUM, 0, comm))
+                errs++;
+        }
+#endif
+
 	MTestFreeComm( &comm );
     }
 
diff --git a/test/mpi/coll/scantst.c b/test/mpi/coll/scantst.c
index 2690644..1359acc 100644
--- a/test/mpi/coll/scantst.c
+++ b/test/mpi/coll/scantst.c
@@ -5,6 +5,7 @@
  */
 #include "mpi.h"
 #include <stdio.h>
+#include "mpitest.h"
 
 void addem ( int *, int *, int *, MPI_Datatype * );
 void assoc ( int *, int *, int *, MPI_Datatype * );
@@ -102,6 +103,12 @@ int main( int argc, char **argv )
         errors++;
     }
 
+#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    if (MPI_SUCCESS == MPI_Scan( &data, &data, 1, MPI_INT, op_assoc, comm))
+        errors++;
+#endif
+
     MPI_Op_free( &op_assoc );
     MPI_Op_free( &op_addem );
     
diff --git a/test/mpi/coll/scatter2.c b/test/mpi/coll/scatter2.c
index 5535a30..feac832 100644
--- a/test/mpi/coll/scatter2.c
+++ b/test/mpi/coll/scatter2.c
@@ -64,7 +64,14 @@ int main( int argc, char **argv )
 	    }
 	}
     }
+
+    MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+    if (rank == 0 && MPI_SUCCESS ==
+            MPI_Scatter(vecin, 1, MPI_DOUBLE, vecin, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD))
+        err++;
     
+    free(vecin);
+    free(vecout);
     MTest_Finalize( err );
     MPI_Type_free( &vec );
     MPI_Finalize();
diff --git a/test/mpi/coll/testlist b/test/mpi/coll/testlist
index 01ef986..c4028f6 100644
--- a/test/mpi/coll/testlist
+++ b/test/mpi/coll/testlist
@@ -139,6 +139,7 @@ nonblocking3 1 mpiversion=3.0
 nonblocking3 4 mpiversion=3.0
 nonblocking3 5 mpiversion=3.0
 nonblocking3 10 timeLimit=600 mpiversion=3.0
+nonblocking4 4 mpiversion=3.0
 iallred 2 mpiversion=3.0
 # ibarrier will hang forever if it fails, but will complete quickly if it
 # succeeds

http://git.mpich.org/mpich.git/commitdiff/40862985af601cf019e9201c6eb9f5e1c4534b38

commit 40862985af601cf019e9201c6eb9f5e1c4534b38
Author: Wesley Bland <wbland at anl.gov>
Date:   Wed May 21 10:12:16 2014 -0500

    Improve error checking for buffer aliasing
    
    If the user isn't using MPI_IN_PLACE when they should, this check will do a
    better job of warning them about it.
    
    See #2049
    
    Signed-off-by: Antonio J. Pena <apenya at mcs.anl.gov>

diff --git a/src/mpi/coll/allgather.c b/src/mpi/coll/allgather.c
index 6ddef58..803ed85 100644
--- a/src/mpi/coll/allgather.c
+++ b/src/mpi/coll/allgather.c
@@ -932,8 +932,18 @@ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
             MPID_Comm_valid_ptr( comm_ptr, mpi_errno );
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 
-	    if (comm_ptr->comm_kind == MPID_INTERCOMM)
+            if (comm_ptr->comm_kind == MPID_INTERCOMM) {
                 MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, sendcount, mpi_errno);
+            } else {
+                /* catch common aliasing cases */
+                if (sendbuf != MPI_IN_PLACE && sendtype == recvtype &&
+                        recvcount != 0 && sendcount != 0) {
+                    int recvtype_size;
+                    MPID_Datatype_get_size_macro(recvtype, recvtype_size);
+                    MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + comm_ptr->rank*recvcount*recvtype_size, mpi_errno);
+                }
+            }
+
             if (sendbuf != MPI_IN_PLACE)
 	    {
                 MPIR_ERRTEST_COUNT(sendcount, mpi_errno);
@@ -961,10 +971,6 @@ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                 if (mpi_errno != MPI_SUCCESS) goto fn_fail;
             }
 	    MPIR_ERRTEST_USERBUFFER(recvbuf,recvcount,recvtype,mpi_errno);
-
-            /* catch common aliasing cases */
-            if (sendbuf != MPI_IN_PLACE && sendtype == recvtype && recvcount != 0 && sendcount != 0)
-                MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
         }
         MPID_END_ERROR_CHECKS;
     }
diff --git a/src/mpi/coll/allgatherv.c b/src/mpi/coll/allgatherv.c
index 275c404..82320a3 100644
--- a/src/mpi/coll/allgatherv.c
+++ b/src/mpi/coll/allgatherv.c
@@ -1057,6 +1057,16 @@ int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                     if (mpi_errno != MPI_SUCCESS) goto fn_fail;
                 }
                 MPIR_ERRTEST_USERBUFFER(sendbuf,sendcount,sendtype,mpi_errno);
+
+                /* catch common aliasing cases */
+                if (comm_ptr->comm_kind == MPID_INTRACOMM &&
+                        sendtype == recvtype &&
+                        recvcounts[comm_ptr->rank] != 0 &&
+                        sendcount != 0) {
+                    int recvtype_size;
+                    MPID_Datatype_get_size_macro(recvtype, recvtype_size);
+                    MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + displs[comm_ptr->rank]*recvtype_size, mpi_errno);
+                }
             }
 
             if (comm_ptr->comm_kind == MPID_INTRACOMM) 
diff --git a/src/mpi/coll/allreduce.c b/src/mpi/coll/allreduce.c
index c2ac3b5..74758f0 100644
--- a/src/mpi/coll/allreduce.c
+++ b/src/mpi/coll/allreduce.c
@@ -868,8 +868,12 @@ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
                 if (mpi_errno != MPI_SUCCESS) goto fn_fail;
             }
 
-	    if (comm_ptr->comm_kind == MPID_INTERCOMM)
+            if (comm_ptr->comm_kind == MPID_INTERCOMM) {
                 MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, count, mpi_errno);
+            } else {
+                if (count != 0 && sendbuf != MPI_IN_PLACE)
+                    MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
+            }
             
             if (sendbuf != MPI_IN_PLACE) 
                 MPIR_ERRTEST_USERBUFFER(sendbuf,count,datatype,mpi_errno);
@@ -885,9 +889,6 @@ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count,
                 mpi_errno = 
                     ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype); 
             }
-	    if (count != 0) {
-		MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
-	    }
 	    if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 	}
         MPID_END_ERROR_CHECKS;
diff --git a/src/mpi/coll/alltoall.c b/src/mpi/coll/alltoall.c
index c3d381f..28143cb 100644
--- a/src/mpi/coll/alltoall.c
+++ b/src/mpi/coll/alltoall.c
@@ -845,6 +845,13 @@ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                     MPID_Datatype_committed_ptr( sendtype_ptr, mpi_errno );
                     if (mpi_errno != MPI_SUCCESS) goto fn_fail;
                 }
+
+                if (comm_ptr->comm_kind == MPID_INTRACOMM &&
+                        sendbuf != MPI_IN_PLACE &&
+                        sendcount == recvcount &&
+                        sendtype == recvtype &&
+                        sendcount != 0)
+                    MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
             }
 
 	    MPIR_ERRTEST_COUNT(recvcount, mpi_errno);
diff --git a/src/mpi/coll/alltoallv.c b/src/mpi/coll/alltoallv.c
index 359cd41..665c580 100644
--- a/src/mpi/coll/alltoallv.c
+++ b/src/mpi/coll/alltoallv.c
@@ -469,9 +469,12 @@ int MPI_Alltoallv(const void *sendbuf, const int *sendcounts,
             MPID_Comm_valid_ptr( comm_ptr, mpi_errno );
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 
-            if (comm_ptr->comm_kind == MPID_INTRACOMM)
+            if (comm_ptr->comm_kind == MPID_INTRACOMM) {
                 comm_size = comm_ptr->local_size;
-            else
+
+                if (sendbuf != MPI_IN_PLACE && sendtype == recvtype && sendcounts == recvcounts)
+                    MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
+            } else
                 comm_size = comm_ptr->remote_size;
 
             if (comm_ptr->comm_kind == MPID_INTERCOMM && sendbuf == MPI_IN_PLACE) {
diff --git a/src/mpi/coll/alltoallw.c b/src/mpi/coll/alltoallw.c
index f0e4565..af6ac78 100644
--- a/src/mpi/coll/alltoallw.c
+++ b/src/mpi/coll/alltoallw.c
@@ -471,9 +471,12 @@ int MPI_Alltoallw(const void *sendbuf, const int sendcounts[],
                 MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**sendbuf_inplace");
             }
 
-            if (comm_ptr->comm_kind == MPID_INTRACOMM)
+            if (comm_ptr->comm_kind == MPID_INTRACOMM) {
                 comm_size = comm_ptr->local_size;
-            else
+
+                if (sendbuf != MPI_IN_PLACE && sendcounts == recvcounts && sendtypes == recvtypes)
+                    MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
+            } else
                 comm_size = comm_ptr->remote_size;
 
             for (i=0; i<comm_size; i++) {
diff --git a/src/mpi/coll/exscan.c b/src/mpi/coll/exscan.c
index 0de26b5..3df9fe1 100644
--- a/src/mpi/coll/exscan.c
+++ b/src/mpi/coll/exscan.c
@@ -369,8 +369,10 @@ int MPI_Exscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
                 mpi_errno = 
                     ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype); 
             }
-            
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
+
+            if (sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
         }
         MPID_END_ERROR_CHECKS;
     }
diff --git a/src/mpi/coll/gather.c b/src/mpi/coll/gather.c
index 284ba14..533c85b 100644
--- a/src/mpi/coll/gather.c
+++ b/src/mpi/coll/gather.c
@@ -824,8 +824,11 @@ int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                     MPIR_ERRTEST_USERBUFFER(recvbuf,recvcount,recvtype,mpi_errno);
 
                     /* catch common aliasing cases */
-                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && sendcount != 0)
-                        MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
+                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && sendcount != 0) {
+                        int recvtype_size;
+                        MPID_Datatype_get_size_macro(recvtype, recvtype_size);
+                        MPIR_ERRTEST_ALIAS_COLL(sendbuf, ((char *)recvbuf) + comm_ptr->rank*recvcount*recvtype_size,mpi_errno);
+                    }
                 }
                 else
                     MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, sendcount, mpi_errno);
diff --git a/src/mpi/coll/gatherv.c b/src/mpi/coll/gatherv.c
index 8deb6e3..7934d04 100644
--- a/src/mpi/coll/gatherv.c
+++ b/src/mpi/coll/gatherv.c
@@ -355,6 +355,13 @@ int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                             break;
                         }
                     }
+
+                    /* catch common aliasing cases */
+                    if (sendbuf != MPI_IN_PLACE && sendtype == recvtype && recvcounts[comm_ptr->rank] != 0 && sendcount != 0) {
+                        int recvtype_size;
+                        MPID_Datatype_get_size_macro(recvtype, recvtype_size);
+                        MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + displs[comm_ptr->rank]*recvtype_size, mpi_errno);
+                    }
                 }
                 else
                     MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, sendcount, mpi_errno);
diff --git a/src/mpi/coll/iallgather.c b/src/mpi/coll/iallgather.c
index b526cdd..f45c291 100644
--- a/src/mpi/coll/iallgather.c
+++ b/src/mpi/coll/iallgather.c
@@ -710,7 +710,15 @@ int MPI_Iallgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
             }
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
-            /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
+
+            /* catch common aliasing cases */
+            if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && sendcount != 0) {
+                int recvtype_size;
+                MPID_Datatype_get_size_macro(recvtype, recvtype_size);
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + comm_ptr->rank*recvcount*recvtype_size, mpi_errno);
+            }
+
+            /* TODO more checks may be appropriate (counts, in_place, etc) */
         }
         MPID_END_ERROR_CHECKS
     }
diff --git a/src/mpi/coll/iallgatherv.c b/src/mpi/coll/iallgatherv.c
index 9921146..ce3e827 100644
--- a/src/mpi/coll/iallgatherv.c
+++ b/src/mpi/coll/iallgatherv.c
@@ -796,13 +796,25 @@ int MPI_Iallgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, v
             MPID_Comm_valid_ptr(comm_ptr, mpi_errno);
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 
-            if (sendbuf != MPI_IN_PLACE && HANDLE_GET_KIND(sendtype) != HANDLE_KIND_BUILTIN) {
-                MPID_Datatype *sendtype_ptr = NULL;
-                MPID_Datatype_get_ptr(sendtype, sendtype_ptr);
-                MPID_Datatype_valid_ptr(sendtype_ptr, mpi_errno);
-                if (mpi_errno != MPI_SUCCESS) goto fn_fail;
-                MPID_Datatype_committed_ptr(sendtype_ptr, mpi_errno);
-                if (mpi_errno != MPI_SUCCESS) goto fn_fail;
+            if (sendbuf != MPI_IN_PLACE) {
+                if (HANDLE_GET_KIND(sendtype) != HANDLE_KIND_BUILTIN) {
+                    MPID_Datatype *sendtype_ptr = NULL;
+                    MPID_Datatype_get_ptr(sendtype, sendtype_ptr);
+                    MPID_Datatype_valid_ptr(sendtype_ptr, mpi_errno);
+                    if (mpi_errno != MPI_SUCCESS) goto fn_fail;
+                    MPID_Datatype_committed_ptr(sendtype_ptr, mpi_errno);
+                    if (mpi_errno != MPI_SUCCESS) goto fn_fail;
+                }
+
+                /* catch common aliasing cases */
+                if (comm_ptr->comm_kind == MPID_INTRACOMM &&
+                        sendtype == recvtype &&
+                        recvcounts[comm_ptr->rank] != 0 &&
+                        sendcount != 0) {
+                    int recvtype_size;
+                    MPID_Datatype_get_size_macro(recvtype, recvtype_size);
+                    MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + displs[comm_ptr->rank]*recvtype_size, mpi_errno);
+                }
             }
 
             MPIR_ERRTEST_ARGNULL(recvcounts,"recvcounts", mpi_errno);
diff --git a/src/mpi/coll/iallreduce.c b/src/mpi/coll/iallreduce.c
index 8829c61..0acee0f 100644
--- a/src/mpi/coll/iallreduce.c
+++ b/src/mpi/coll/iallreduce.c
@@ -772,6 +772,10 @@ int MPI_Iallreduce(const void *sendbuf, void *recvbuf, int count,
                 MPIR_ERRTEST_USERBUFFER(sendbuf,count,datatype,mpi_errno);
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
+
+            if (comm_ptr->comm_kind == MPID_INTRACOMM && count != 0 && sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
+
             /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
         }
         MPID_END_ERROR_CHECKS
diff --git a/src/mpi/coll/ialltoall.c b/src/mpi/coll/ialltoall.c
index 0e8e539..129c521 100644
--- a/src/mpi/coll/ialltoall.c
+++ b/src/mpi/coll/ialltoall.c
@@ -641,7 +641,14 @@ int MPI_Ialltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
             }
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
-            /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
+
+            if (comm_ptr->comm_kind == MPID_INTRACOMM &&
+                    sendbuf != MPI_IN_PLACE &&
+                    sendcount == recvcount &&
+                    sendtype == recvtype &&
+                    sendcount != 0)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
+            /* TODO more checks may be appropriate (counts, in_place, etc) */
         }
         MPID_END_ERROR_CHECKS
     }
diff --git a/src/mpi/coll/ialltoallv.c b/src/mpi/coll/ialltoallv.c
index a5f6d99..e6bab8b 100644
--- a/src/mpi/coll/ialltoallv.c
+++ b/src/mpi/coll/ialltoallv.c
@@ -378,6 +378,12 @@ int MPI_Ialltoallv(const void *sendbuf, const int sendcounts[], const int sdispl
             }
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
+
+            if (comm_ptr->comm_kind == MPID_INTRACOMM &&
+                    sendbuf != MPI_IN_PLACE &&
+                    sendcounts == recvcounts &&
+                    sendtype == recvtype)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
             /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
         }
         MPID_END_ERROR_CHECKS
diff --git a/src/mpi/coll/ialltoallw.c b/src/mpi/coll/ialltoallw.c
index fe76606..e0e3675 100644
--- a/src/mpi/coll/ialltoallw.c
+++ b/src/mpi/coll/ialltoallw.c
@@ -360,6 +360,11 @@ int MPI_Ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispl
                 MPIR_ERRTEST_ARGNULL(sendcounts,"sendcounts", mpi_errno);
                 MPIR_ERRTEST_ARGNULL(sdispls,"sdispls", mpi_errno);
                 MPIR_ERRTEST_ARGNULL(sendtypes,"sendtypes", mpi_errno);
+
+                if (comm_ptr->comm_kind == MPID_INTRACOMM &&
+                        sendcounts == recvcounts &&
+                        sendtypes == recvtypes)
+                    MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
             }
             MPIR_ERRTEST_ARGNULL(recvcounts,"recvcounts", mpi_errno);
             MPIR_ERRTEST_ARGNULL(rdispls,"rdispls", mpi_errno);
@@ -368,7 +373,7 @@ int MPI_Ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispl
                 MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**sendbuf_inplace");
             }
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
-            /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
+            /* TODO more checks may be appropriate (counts, in_place, etc) */
         }
         MPID_END_ERROR_CHECKS
     }
diff --git a/src/mpi/coll/iexscan.c b/src/mpi/coll/iexscan.c
index f7b7f17..97ef8cb 100644
--- a/src/mpi/coll/iexscan.c
+++ b/src/mpi/coll/iexscan.c
@@ -305,7 +305,10 @@ int MPI_Iexscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype data
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
-            /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
+
+            if (sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
+            /* TODO more checks may be appropriate (counts, in_place, etc) */
         }
         MPID_END_ERROR_CHECKS
     }
diff --git a/src/mpi/coll/igather.c b/src/mpi/coll/igather.c
index c1e43a4..8a5c9ee 100644
--- a/src/mpi/coll/igather.c
+++ b/src/mpi/coll/igather.c
@@ -649,8 +649,11 @@ int MPI_Igather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                     MPIR_ERRTEST_USERBUFFER(recvbuf,recvcount,recvtype,mpi_errno);
 
                     /* catch common aliasing cases */
-                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && sendcount != 0)
-                        MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
+                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && sendcount != 0) {
+                        int recvtype_size;
+                        MPID_Datatype_get_size_macro(recvtype, recvtype_size);
+                        MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + comm_ptr->rank*recvcount*recvtype_size, mpi_errno);
+                    }
                 }
                 else
                     MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, sendcount, mpi_errno);
diff --git a/src/mpi/coll/igatherv.c b/src/mpi/coll/igatherv.c
index 1985b73..88ac3b2 100644
--- a/src/mpi/coll/igatherv.c
+++ b/src/mpi/coll/igatherv.c
@@ -256,6 +256,13 @@ int MPI_Igatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void
                             break;
                         }
                     }
+
+                    /* catch common aliasing cases */
+                    if (sendbuf != MPI_IN_PLACE && sendtype == recvtype && recvcounts[comm_ptr->rank] != 0 && sendcount != 0) {
+                        int recvtype_size;
+                        MPID_Datatype_get_size_macro(recvtype, recvtype_size);
+                        MPIR_ERRTEST_ALIAS_COLL(sendbuf, (char*)recvbuf + displs[comm_ptr->rank]*recvtype_size, mpi_errno);
+                    }
                 }
                 else
                     MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, sendcount, mpi_errno);
diff --git a/src/mpi/coll/ired_scat.c b/src/mpi/coll/ired_scat.c
index 68a64ff..c9d86b7 100644
--- a/src/mpi/coll/ired_scat.c
+++ b/src/mpi/coll/ired_scat.c
@@ -1133,7 +1133,10 @@ int MPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
-            /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
+
+            if (comm_ptr->comm_kind == MPID_INTRACOMM && sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno)
+            /* TODO more checks may be appropriate (counts, in_place, etc) */
         }
         MPID_END_ERROR_CHECKS
     }
diff --git a/src/mpi/coll/ired_scat_block.c b/src/mpi/coll/ired_scat_block.c
index acb8ff2..6ca9c55 100644
--- a/src/mpi/coll/ired_scat_block.c
+++ b/src/mpi/coll/ired_scat_block.c
@@ -1034,7 +1034,10 @@ int MPI_Ireduce_scatter_block(const void *sendbuf, void *recvbuf,
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
-            /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
+
+            if (comm_ptr->comm_kind == MPID_INTRACOMM && sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno)
+            /* TODO more checks may be appropriate (counts, in_place, etc) */
         }
         MPID_END_ERROR_CHECKS
     }
diff --git a/src/mpi/coll/ireduce.c b/src/mpi/coll/ireduce.c
index 1113e99..94180c1 100644
--- a/src/mpi/coll/ireduce.c
+++ b/src/mpi/coll/ireduce.c
@@ -862,6 +862,8 @@ int MPI_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype data
     {
         MPID_BEGIN_ERROR_CHECKS
         {
+            int rank;
+
             MPID_Comm_valid_ptr(comm_ptr, mpi_errno);
             if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) {
                 MPID_Datatype *datatype_ptr = NULL;
@@ -883,7 +885,24 @@ int MPI_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype data
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
-            /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
+
+            if (comm_ptr->comm_kind == MPID_INTRACOMM) {
+                if (sendbuf != MPI_IN_PLACE)
+                    MPIR_ERRTEST_USERBUFFER(sendbuf,count,datatype,mpi_errno);
+
+                rank = comm_ptr->rank;
+                if (rank == root) {
+                    MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, count, mpi_errno);
+                    MPIR_ERRTEST_USERBUFFER(recvbuf,count,datatype,mpi_errno);
+                    if (count != 0 && sendbuf != MPI_IN_PLACE) {
+                        MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
+                    }
+                }
+                else
+                    MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, count, mpi_errno);
+            }
+
+            /* TODO more checks may be appropriate (counts, in_place, etc) */
         }
         MPID_END_ERROR_CHECKS
     }
diff --git a/src/mpi/coll/iscan.c b/src/mpi/coll/iscan.c
index 7b0d286..e0338fd 100644
--- a/src/mpi/coll/iscan.c
+++ b/src/mpi/coll/iscan.c
@@ -441,7 +441,10 @@ int MPI_Iscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype dataty
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
 
             MPIR_ERRTEST_ARGNULL(request,"request", mpi_errno);
-            /* TODO more checks may be appropriate (counts, in_place, buffer aliasing, etc) */
+
+            if (sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
+            /* TODO more checks may be appropriate (counts, in_place, etc) */
         }
         MPID_END_ERROR_CHECKS
     }
diff --git a/src/mpi/coll/iscatter.c b/src/mpi/coll/iscatter.c
index 07d1cb0..32ff029 100644
--- a/src/mpi/coll/iscatter.c
+++ b/src/mpi/coll/iscatter.c
@@ -665,8 +665,11 @@ int MPI_Iscatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                     MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, sendcount, mpi_errno);
 
                     /* catch common aliasing cases */
-                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && recvcount != 0)
-                        MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
+                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && recvcount != 0) {
+                        int sendtype_size;
+                        MPID_Datatype_get_size_macro(sendtype, sendtype_size);
+                        MPIR_ERRTEST_ALIAS_COLL(recvbuf, (char*)sendbuf + comm_ptr->rank*sendcount*sendtype_size, mpi_errno);
+                    }
                 }
                 else
                     MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, recvcount, mpi_errno);
diff --git a/src/mpi/coll/iscatterv.c b/src/mpi/coll/iscatterv.c
index 13210ca..71c01a2 100644
--- a/src/mpi/coll/iscatterv.c
+++ b/src/mpi/coll/iscatterv.c
@@ -256,6 +256,13 @@ int MPI_Iscatterv(const void *sendbuf, const int sendcounts[], const int displs[
                             break;
                         }
                     }
+                    /* catch common aliasing cases */
+                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcounts[comm_ptr->rank] != 0 && recvcount != 0) {
+                        int sendtype_size;
+                        MPID_Datatype_get_size_macro(sendtype, sendtype_size);
+                        MPIR_ERRTEST_ALIAS_COLL(recvbuf, (char*)sendbuf + displs[comm_ptr->rank]*sendtype_size, mpi_errno);
+                    }
+
                 }
                 else
                     MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, recvcount, mpi_errno);
diff --git a/src/mpi/coll/red_scat.c b/src/mpi/coll/red_scat.c
index 46dc14e..2221b04 100644
--- a/src/mpi/coll/red_scat.c
+++ b/src/mpi/coll/red_scat.c
@@ -1172,8 +1172,10 @@ int MPI_Reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[
             }
 
             MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, recvcounts[comm_ptr->rank], mpi_errno);
-	    if (comm_ptr->comm_kind == MPID_INTERCOMM) 
+            if (comm_ptr->comm_kind == MPID_INTERCOMM) {
                 MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, sum, mpi_errno);
+            } else if (sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno)
 
             MPIR_ERRTEST_USERBUFFER(recvbuf,recvcounts[comm_ptr->rank],datatype,mpi_errno);
             MPIR_ERRTEST_USERBUFFER(sendbuf,sum,datatype,mpi_errno); 
diff --git a/src/mpi/coll/red_scat_block.c b/src/mpi/coll/red_scat_block.c
index 6086115..b5cf449 100644
--- a/src/mpi/coll/red_scat_block.c
+++ b/src/mpi/coll/red_scat_block.c
@@ -1136,8 +1136,10 @@ int MPI_Reduce_scatter_block(const void *sendbuf, void *recvbuf,
             }
 
             MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, recvcount, mpi_errno);
-	    if (comm_ptr->comm_kind == MPID_INTERCOMM) 
+            if (comm_ptr->comm_kind == MPID_INTERCOMM) {
                 MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, recvcount, mpi_errno);
+            } else if (sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno)
 
             MPIR_ERRTEST_USERBUFFER(recvbuf,recvcount,datatype,mpi_errno);
             MPIR_ERRTEST_USERBUFFER(sendbuf,recvcount,datatype,mpi_errno); 
diff --git a/src/mpi/coll/scan.c b/src/mpi/coll/scan.c
index 5ff546a..ee826f6 100644
--- a/src/mpi/coll/scan.c
+++ b/src/mpi/coll/scan.c
@@ -548,6 +548,9 @@ int MPI_Scan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp
                     ( * MPIR_OP_HDL_TO_DTYPE_FN(op) )(datatype); 
             }
             if (mpi_errno != MPI_SUCCESS) goto fn_fail;
+
+            if (sendbuf != MPI_IN_PLACE)
+                MPIR_ERRTEST_ALIAS_COLL(sendbuf, recvbuf, mpi_errno);
         }
         MPID_END_ERROR_CHECKS;
     }
diff --git a/src/mpi/coll/scatter.c b/src/mpi/coll/scatter.c
index 705a456..b7278a0 100644
--- a/src/mpi/coll/scatter.c
+++ b/src/mpi/coll/scatter.c
@@ -724,10 +724,13 @@ int MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
                     MPIR_ERRTEST_SENDBUF_INPLACE(sendbuf, sendcount, mpi_errno);
 
                     /* catch common aliasing cases */
-                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && recvcount != 0)
-                        MPIR_ERRTEST_ALIAS_COLL(sendbuf,recvbuf,mpi_errno);
+                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcount == recvcount && recvcount != 0) {
+                        int sendtype_size;
+                        MPID_Datatype_get_size_macro(sendtype, sendtype_size);
+                        MPIR_ERRTEST_ALIAS_COLL(recvbuf, (char*)sendbuf + comm_ptr->rank*sendcount*sendtype_size, mpi_errno);
+                    }
                 }
-                else 
+                else
                     MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, recvcount, mpi_errno);
 
                 if (recvbuf != MPI_IN_PLACE) {
diff --git a/src/mpi/coll/scatterv.c b/src/mpi/coll/scatterv.c
index ed1006a..1a23ec1 100644
--- a/src/mpi/coll/scatterv.c
+++ b/src/mpi/coll/scatterv.c
@@ -293,6 +293,12 @@ int MPI_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
                             break;
                         }
                     }
+                    /* catch common aliasing cases */
+                    if (recvbuf != MPI_IN_PLACE && sendtype == recvtype && sendcounts[comm_ptr->rank] != 0 && recvcount != 0) {
+                        int sendtype_size;
+                        MPID_Datatype_get_size_macro(sendtype, sendtype_size);
+                        MPIR_ERRTEST_ALIAS_COLL(recvbuf, (char*)sendbuf + displs[comm_ptr->rank]*sendtype_size, mpi_errno);
+                    }
                 }
                 else 
                     MPIR_ERRTEST_RECVBUF_INPLACE(recvbuf, recvcount, mpi_errno);

-----------------------------------------------------------------------

Summary of changes:
 src/mpi/coll/allgather.c                        |   16 +++--
 src/mpi/coll/allgatherv.c                       |   10 +++
 src/mpi/coll/allreduce.c                        |    9 ++-
 src/mpi/coll/alltoall.c                         |    7 ++
 src/mpi/coll/alltoallv.c                        |    7 ++-
 src/mpi/coll/alltoallw.c                        |    7 ++-
 src/mpi/coll/exscan.c                           |    4 +-
 src/mpi/coll/gather.c                           |    7 ++-
 src/mpi/coll/gatherv.c                          |    7 ++
 src/mpi/coll/iallgather.c                       |   10 +++-
 src/mpi/coll/iallgatherv.c                      |   26 +++++--
 src/mpi/coll/iallreduce.c                       |    4 +
 src/mpi/coll/ialltoall.c                        |    9 ++-
 src/mpi/coll/ialltoallv.c                       |    6 ++
 src/mpi/coll/ialltoallw.c                       |    7 ++-
 src/mpi/coll/iexscan.c                          |    5 +-
 src/mpi/coll/igather.c                          |    7 ++-
 src/mpi/coll/igatherv.c                         |    7 ++
 src/mpi/coll/ired_scat.c                        |    5 +-
 src/mpi/coll/ired_scat_block.c                  |    5 +-
 src/mpi/coll/ireduce.c                          |   21 ++++++-
 src/mpi/coll/iscan.c                            |    5 +-
 src/mpi/coll/iscatter.c                         |    7 ++-
 src/mpi/coll/iscatterv.c                        |    7 ++
 src/mpi/coll/red_scat.c                         |    4 +-
 src/mpi/coll/red_scat_block.c                   |    4 +-
 src/mpi/coll/scan.c                             |    3 +
 src/mpi/coll/scatter.c                          |    9 ++-
 src/mpi/coll/scatterv.c                         |    6 ++
 test/mpi/coll/Makefile.am                       |    1 +
 test/mpi/coll/allgather2.c                      |   13 +++-
 test/mpi/coll/allgatherv2.c                     |   12 +++-
 test/mpi/coll/allred6.c                         |    8 ++
 test/mpi/coll/alltoall1.c                       |    8 ++
 test/mpi/coll/alltoallv.c                       |    6 ++
 test/mpi/coll/alltoallw2.c                      |    5 ++
 test/mpi/coll/coll6.c                           |   11 ++-
 test/mpi/coll/exscan.c                          |    5 ++
 test/mpi/coll/gather.c                          |   10 +++
 test/mpi/coll/iallred.c                         |   11 +++-
 test/mpi/coll/{nonblocking.c => nonblocking4.c} |   83 +++++++++++++----------
 test/mpi/coll/red3.c                            |   10 +++
 test/mpi/coll/red_scat_block.c                  |    5 ++
 test/mpi/coll/redscat3.c                        |    6 ++
 test/mpi/coll/reduce.c                          |    9 +++
 test/mpi/coll/scantst.c                         |    7 ++
 test/mpi/coll/scatter2.c                        |    7 ++
 test/mpi/coll/testlist                          |    1 +
 48 files changed, 367 insertions(+), 82 deletions(-)
 copy test/mpi/coll/{nonblocking.c => nonblocking4.c} (58%)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list