Commit 1b000f9c authored by David Goodell's avatar David Goodell
Browse files

[svn-r7178] support logical op reductions on MPI::BOOL

Embarassingly, this has been broken for a while.  This commit also
adds a regression test: "cxx/coll/reduceboolx".

No reviewer.
parent e1431a64
...@@ -4572,6 +4572,13 @@ fi ...@@ -4572,6 +4572,13 @@ fi
if test "$enable_cxx" = "yes" ; then if test "$enable_cxx" = "yes" ; then
AC_LANG_CPLUSPLUS AC_LANG_CPLUSPLUS
AC_CHECK_SIZEOF(bool) AC_CHECK_SIZEOF(bool)
if test "$ac_cv_type__Bool" = "yes" -a "$ac_cv_sizeof__Bool" = "$ac_cv_sizeof_bool" ; then
AC_DEFINE_UNQUOTED([MPIR_CXX_BOOL_CTYPE],[_Bool],[a C type used to compute C++ bool reductions])
else
AC_MSG_ERROR([unable to determine matching C type for C++ bool])
fi
AC_CHECK_HEADER(complex) AC_CHECK_HEADER(complex)
if test "$ac_cv_header_complex" = "yes" ; then if test "$ac_cv_header_complex" = "yes" ; then
# The C++ complex types are all templated. We finagle this by # The C++ complex types are all templated. We finagle this by
...@@ -4634,6 +4641,7 @@ using namespace std; ...@@ -4634,6 +4641,7 @@ using namespace std;
AC_LANG_C AC_LANG_C
# Make these available to the collective operations and other code # Make these available to the collective operations and other code
AC_DEFINE_UNQUOTED(MPIR_CXX_BOOL_VALUE,$MPIR_CXX_BOOL,[Define as the MPI Datatype handle for MPI::BOOL])
AC_DEFINE_UNQUOTED(MPIR_CXX_COMPLEX_VALUE,$MPIR_CXX_COMPLEX,[Define as the MPI Datatype handle for MPI::COMPLEX]) AC_DEFINE_UNQUOTED(MPIR_CXX_COMPLEX_VALUE,$MPIR_CXX_COMPLEX,[Define as the MPI Datatype handle for MPI::COMPLEX])
AC_DEFINE_UNQUOTED(MPIR_CXX_DOUBLE_COMPLEX_VALUE,$MPIR_CXX_DOUBLE_COMPLEX,[Define as the MPI Datatype handle for MPI::DOUBLE_COMPLEX]) AC_DEFINE_UNQUOTED(MPIR_CXX_DOUBLE_COMPLEX_VALUE,$MPIR_CXX_DOUBLE_COMPLEX,[Define as the MPI Datatype handle for MPI::DOUBLE_COMPLEX])
AC_DEFINE_UNQUOTED(MPIR_CXX_LONG_DOUBLE_COMPLEX_VALUE,$MPIR_CXX_LONG_DOUBLE_COMPLEX,[Define as the MPI Datatype handle for MPI::LONG_DOUBLE_COMPLEX]) AC_DEFINE_UNQUOTED(MPIR_CXX_LONG_DOUBLE_COMPLEX_VALUE,$MPIR_CXX_LONG_DOUBLE_COMPLEX,[Define as the MPI Datatype handle for MPI::LONG_DOUBLE_COMPLEX])
......
...@@ -66,6 +66,7 @@ MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER) ...@@ -66,6 +66,7 @@ MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
#define MPIR_OP_TYPE_MACRO_HAVE_REAL4_CTYPE(mpi_type_,c_type_) #define MPIR_OP_TYPE_MACRO_HAVE_REAL4_CTYPE(mpi_type_,c_type_)
#define MPIR_OP_TYPE_MACRO_HAVE_REAL8_CTYPE(mpi_type_,c_type_) #define MPIR_OP_TYPE_MACRO_HAVE_REAL8_CTYPE(mpi_type_,c_type_)
#define MPIR_OP_TYPE_MACRO_HAVE_REAL16_CTYPE(mpi_type_,c_type_) #define MPIR_OP_TYPE_MACRO_HAVE_REAL16_CTYPE(mpi_type_,c_type_)
#define MPIR_OP_TYPE_MACRO_HAVE_CXX(mpi_type_,c_type_)
#define MPIR_OP_TYPE_MACRO_HAVE_CXX_COMPLEX(mpi_type_,c_type_) #define MPIR_OP_TYPE_MACRO_HAVE_CXX_COMPLEX(mpi_type_,c_type_)
#define MPIR_OP_TYPE_MACRO_HAVE_CXX_LONG_DOUBLE_COMPLEX(mpi_type_,c_type_) #define MPIR_OP_TYPE_MACRO_HAVE_CXX_LONG_DOUBLE_COMPLEX(mpi_type_,c_type_)
#define MPIR_OP_TYPE_MACRO_HAVE_INT8_T(mpi_type_,c_type_) #define MPIR_OP_TYPE_MACRO_HAVE_INT8_T(mpi_type_,c_type_)
...@@ -139,6 +140,12 @@ MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER) ...@@ -139,6 +140,12 @@ MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
# define MPIR_OP_TYPE_MACRO_HAVE_REAL16_CTYPE(mpi_type_,c_type_) MPIR_OP_TYPE_MACRO(mpi_type_,c_type_) # define MPIR_OP_TYPE_MACRO_HAVE_REAL16_CTYPE(mpi_type_,c_type_) MPIR_OP_TYPE_MACRO(mpi_type_,c_type_)
#endif #endif
/* general C++ types */
#if defined(HAVE_CXX_BINDING)
# undef MPIR_OP_TYPE_MACRO_HAVE_CXX
# define MPIR_OP_TYPE_MACRO_HAVE_CXX(mpi_type_,c_type_) MPIR_OP_TYPE_MACRO(mpi_type_,c_type_)
#endif
/* C++ complex types */ /* C++ complex types */
#if defined(HAVE_CXX_COMPLEX) #if defined(HAVE_CXX_COMPLEX)
# undef MPIR_OP_TYPE_MACRO_HAVE_CXX_COMPLEX # undef MPIR_OP_TYPE_MACRO_HAVE_CXX_COMPLEX
...@@ -297,7 +304,8 @@ typedef struct { ...@@ -297,7 +304,8 @@ typedef struct {
/* FIXME Is MPI_Fint really OK here? */ /* FIXME Is MPI_Fint really OK here? */
#define MPIR_OP_TYPE_GROUP_LOGICAL \ #define MPIR_OP_TYPE_GROUP_LOGICAL \
MPIR_OP_TYPE_MACRO_HAVE_FORTRAN(MPI_LOGICAL, MPI_Fint) \ MPIR_OP_TYPE_MACRO_HAVE_FORTRAN(MPI_LOGICAL, MPI_Fint) \
MPIR_OP_TYPE_MACRO_HAVE_C_BOOL(MPI_C_BOOL, _Bool) MPIR_OP_TYPE_MACRO_HAVE_C_BOOL(MPI_C_BOOL, _Bool) \
MPIR_OP_TYPE_MACRO_HAVE_CXX(MPIR_CXX_BOOL_VALUE, MPIR_CXX_BOOL_CTYPE)
#define MPIR_OP_TYPE_GROUP_LOGICAL_EXTRA /* empty, provided for consistency */ #define MPIR_OP_TYPE_GROUP_LOGICAL_EXTRA /* empty, provided for consistency */
/* complex group */ /* complex group */
......
...@@ -21,6 +21,7 @@ icallreducex_SOURCES = icallreducex.cxx ...@@ -21,6 +21,7 @@ icallreducex_SOURCES = icallreducex.cxx
icreducex_SOURCES = icreducex.cxx icreducex_SOURCES = icreducex.cxx
icalltoallx_SOURCES = icalltoallx.cxx icalltoallx_SOURCES = icalltoallx.cxx
alltoallw2x_SOURCES = alltoallw2x.cxx alltoallw2x_SOURCES = alltoallw2x.cxx
reduceboolx_SOURCES = reduceboolx.cxx
../util/mtest.o: ../util/mtest.o:
(cd ../util && $(MAKE) mtest.o) (cd ../util && $(MAKE) mtest.o)
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
*
* (C) 2010 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/* Sanity check that logical operations can be performed on C++ bool types
* via MPI::BOOL. */
#include "mpi.h"
#include "mpitestconf.h"
#ifdef HAVE_IOSTREAM
// Not all C++ compilers have iostream instead of iostream.h
#include <iostream>
#ifdef HAVE_NAMESPACE_STD
// Those that do often need the std namespace; otherwise, a bare "cout"
// is likely to fail to compile
using namespace std;
#endif
#else
#include <iostream.h>
#endif
#include "mpitestcxx.h"
int main( int argc, char **argv )
{
MPI::Intracomm comm = MPI::COMM_WORLD;
int errs = 0;
int size, i, count, root, rank;
MTest_Init( );
size = comm.Get_size();
rank = comm.Get_rank();
for (count = 1; count < 66000; count = count * 2) {
bool *vin, *vout;
vin = new bool[count];
vout = new bool[count];
for (root = 0; root < size; root++) {
for (i=0; i<count; i++) {
// only rank 0's elements are set to true
vin[i] = (rank ? false : true);
vout[i] = false;
}
comm.Reduce(vin, vout, count, MPI::BOOL, MPI::LOR, root);
if (rank == root) {
for (i=0; i<count; i++) {
if (vout[i] != true) {
errs++;
if (errs < 10)
cerr << rank << ": " << "count=" << count
<< " root=" << root
<< " vout[" << i << "]=" << vout[i] << endl;
}
}
}
}
delete[] vin;
delete[] vout;
}
MTest_Finalize( errs );
MPI::Finalize();
return 0;
}
...@@ -17,3 +17,4 @@ icallgathervx 5 ...@@ -17,3 +17,4 @@ icallgathervx 5
icgathervx 5 icgathervx 5
icscattervx 5 icscattervx 5
icalltoallx 5 icalltoallx 5
reduceboolx 5
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