Commit b31a0a67 authored by Dave Goodell's avatar Dave Goodell
Browse files

tt#1763: IN_PLACE checking for MPI_Reduce_local

MPI-3.0, page 189 expressly forbids MPI_IN_PLACE as an argument to
MPI_Reduce_local.

Check suggested by Jeff Hammond.  Fixes ticket #1763.

Reviewed-by: dinan
parent a26933b1
......@@ -266,6 +266,14 @@
goto fn_fail; \
}
#define MPIR_ERRTEST_NAMED_BUF_INPLACE(buf, bufname, count, err) \
do { \
if (count > 0 && buf == MPI_IN_PLACE) { \
MPIU_ERR_SETANDJUMP1(err, MPI_ERR_BUFFER, "**buf_inplace", \
"**buf_inplace %s", bufname); \
} \
} while (0)
/*
* Check that the triple (buf,count,datatype) does not specify a null
* buffer. This does not guarantee that the buffer is valid but does
......
......@@ -170,6 +170,8 @@ int MPI_Reduce_local(const void *inbuf, void *inoutbuf, int count, MPI_Datatype
if (count != 0) {
MPIR_ERRTEST_ALIAS_COLL(inbuf, inoutbuf, mpi_errno);
}
MPIR_ERRTEST_NAMED_BUF_INPLACE(inbuf, "inbuf", count, mpi_errno);
MPIR_ERRTEST_NAMED_BUF_INPLACE(inoutbuf, "inoutbuf", count, mpi_errno);
}
MPID_END_ERROR_CHECKS;
}
......
......@@ -134,6 +134,7 @@ be in the range 0 to %d
**sendbuf_inplace:sendbuf cannot be MPI_IN_PLACE
**recvbuf_inplace:recvbuf cannot be MPI_IN_PLACE
**buf_inplace:buffer cannot be MPI_IN_PLACE
**buf_inplace %s:buffer '%s' cannot be MPI_IN_PLACE
**typematchnoclass:The value of typeclass is not one of MPI_TYPECLASS_REAL, \
MPI_TYPECLASS_INTEGER, or MPI_TYPECLASS_COMPLEX
**typematchsize:No MPI datatype available for the given typeclass and size
......
......@@ -12,5 +12,5 @@ EXTRA_DIST = testlist
## for all programs that are just built from the single corresponding source
## file, we don't need per-target _SOURCES rules, automake will infer them
## correctly
noinst_PROGRAMS = noalias rerr bcastlength
noinst_PROGRAMS = noalias rerr bcastlength reduce_local
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2013 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/* This test checks for proper error checking in MPI_Reduce_local, especially
* handling of MPI_IN_PLACE and buffer aliasing. */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "mpi.h"
#include "mpitest.h"
/* quick cop-out for now */
#define check(c_) assert(c_)
int main(int argc, char *argv[])
{
int err, errs = 0, len, i, errclass;
int rank = -1, size = -1;
int *buf;
int *recvbuf;
char msg[MPI_MAX_ERROR_STRING];
MTest_Init(&argc, &argv);
MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
buf = malloc(size * sizeof(int));
recvbuf = malloc(size * sizeof(int));
for (i = 0; i < size; ++i) {
buf[i] = i;
recvbuf[i] = -1;
}
err = MPI_Reduce_local(buf, recvbuf, size, MPI_INT, MPI_SUM);
check(err == MPI_SUCCESS);
err = MPI_Reduce_local(MPI_IN_PLACE, recvbuf, size, MPI_INT, MPI_SUM);
check(err != MPI_SUCCESS);
MPI_Error_class(err, &errclass);
check(errclass == MPI_ERR_BUFFER);
err = MPI_Reduce_local(buf, MPI_IN_PLACE, size, MPI_INT, MPI_SUM);
check(err != MPI_SUCCESS);
MPI_Error_class(err, &errclass);
check(errclass == MPI_ERR_BUFFER);
err = MPI_Reduce_local(buf, MPI_IN_PLACE, size, MPI_INT, MPI_SUM);
check(err != MPI_SUCCESS);
MPI_Error_class(err, &errclass);
check(errclass == MPI_ERR_BUFFER);
free(recvbuf);
free(buf);
MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
noalias 2
rerr 2
reduce_local 1
# MPICH currently fails the bcastlength test because it needs to do more
# checking on the receive status, so for the 1.0.5 release, we are
# commenting out this test.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment