mlogft AMPI_Reduce: Handle MPI_IN_PLACE before reading results out of the message log
authorPhil Miller <mille121@illinois.edu>
Wed, 14 Mar 2012 23:20:00 +0000 (18:20 -0500)
committerPhil Miller <mille121@illinois.edu>
Thu, 15 Mar 2012 03:04:25 +0000 (22:04 -0500)
src/libs/ck-libs/ampi/ampi.C

index f15a9ab6cb80d83d63103952e170cea998fa1aa1..24f9f453e36b561313551a29c88dcf1405b2ec4a 100644 (file)
@@ -2997,6 +2997,10 @@ int AMPI_Reduce(void *inbuf, void *outbuf, int count, int type, MPI_Op op,
 {
   AMPIAPI("AMPI_Reduce");
 
+  if (inbuf == MPI_IN_PLACE) inbuf = outbuf;
+  if (outbuf == MPI_IN_PLACE) outbuf = inbuf;
+  CmiAssert(inbuf != MPI_IN_PLACE && outbuf != MPI_IN_PLACE);
+
 #if CMK_ERROR_CHECKING
   int ret;
   ret = errorCheck(comm, 1, count, 1, type, 1, 0, 0, root, 1, inbuf, 1,
@@ -3016,10 +3020,6 @@ int AMPI_Reduce(void *inbuf, void *outbuf, int count, int type, MPI_Op op,
   }
 #endif
 
-  if (inbuf == MPI_IN_PLACE) inbuf = outbuf;
-  if (outbuf == MPI_IN_PLACE) outbuf = inbuf;
-  CmiAssert(inbuf != MPI_IN_PLACE && outbuf != MPI_IN_PLACE);
-
   ampi *ptr = getAmpiInstance(comm);
   int rootIdx=ptr->comm2CommStruct(comm).getIndexForRank(root);
   if(op == MPI_OP_NULL) CkAbort("MPI_Reduce called with MPI_OP_NULL!!!");