Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

From: Andy Selle (aselle_at_[hidden])
Date: 2006-03-03 15:05:15


Sorry for the repeat from the user list, but in retrospect, it is probably
more appropriate on this list, but here goes:
I am trying to do a reduction using a bool type using the C++ bindings. I am
using this sample program to test:

---------------------------------------------
#include <mpi.h>
#include <iostream>

int main(int argc,char *argv[])
{
    MPI::Init();
    int rank=MPI::COMM_WORLD.Get_rank();

    {bool test=true;
    bool result;
    MPI::COMM_WORLD.Allreduce(&test,&result,1,MPI::BOOL,MPI::LOR);
    std::cout<<"rank "<<rank<<" got in="<<test<<" out="<<result<<std::endl;}

    MPI::Finalize();
    return 0;
}
---------------------------------------------

The result of running this on OpenMPI is:
---------------------------------------------
[div:17034] *** An error occurred in MPI_Allreduce: the reduction operation
MPI_LOR is not defined on the MPI_CXX_BOOL datatype
[div:17034] *** on communicator MPI_COMM_WORLD
[div:17034] *** MPI_ERR_OP: invalid reduce operation
[div:17034] *** MPI_ERRORS_ARE_FATAL (goodbye)
[div:17034] [0,0,0] ORTE_ERROR_LOG: Not found in file pls_base_proxy.c at line
183
---------------------------------------------

Alternatively on LAM this works fine and I get:

---------------------------------------------
aselle_at_div mpi $ mpirun -np 4 ./reduce.lam
rank 0 got in=1 out=1
rank 1 got in=1 out=1
rank 2 got in=1 out=1
rank 3 got in=1 out=1
---------------------------------------------

Looking at OpenMPI's source it doesn't seem like there is a type map entry for
the bool case in the op_predefined.c

---------
#undef current_func
#define current_func(a, b) ((a) || (b))
/* C integer */
FUNC_FUNC(lor, int, int)
FUNC_FUNC(lor, long, long)
FUNC_FUNC(lor, short, short)
FUNC_FUNC(lor, unsigned_short, unsigned short)
FUNC_FUNC(lor, unsigned, unsigned)
FUNC_FUNC(lor, unsigned_long, unsigned long)
#if HAVE_LONG_LONG
FUNC_FUNC(lor, long_long_int, long long int)
FUNC_FUNC(lor, long_long, long long)
FUNC_FUNC(lor, unsigned_long_long, unsigned long long)
#endif
/* Logical */
#if OMPI_HAVE_FORTRAN_LOGICAL
FUNC_FUNC(lor, fortran_logical, ompi_fortran_logical_t)
#endif

I am using OpenMPI 1.0.1.

-Andy