From bf6e3d435541b7d3f41b816d7105b61e30c7d49d Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 22 Oct 2009 21:46:05 +0000 Subject: [PATCH] Fixes trac:2061: add MPI_OP_COMMUTATIVE. This commit was SVN r22128. The following Trac tickets were found above: Ticket 2061 --> https://svn.open-mpi.org/trac/ompi/ticket/2061 --- ompi/include/mpi.h.in | 2 + ompi/mpi/c/Makefile.am | 1 + ompi/mpi/c/op_commutative.c | 66 ++++++++++++++++++ ompi/mpi/c/profile/Makefile.am | 1 + ompi/mpi/c/profile/defines.h | 1 + ompi/mpi/cxx/op.h | 1 + ompi/mpi/cxx/op_inln.h | 9 +++ ompi/mpi/f77/Makefile.am | 1 + ompi/mpi/f77/op_commutative_f.c | 73 ++++++++++++++++++++ ompi/mpi/f77/profile/defines.h | 3 +- ompi/mpi/f77/prototypes_mpi.h | 1 + ompi/mpi/f90/scripts/mpi-f90-interfaces.h.sh | 23 ++++++ 12 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 ompi/mpi/c/op_commutative.c create mode 100644 ompi/mpi/f77/op_commutative_f.c diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index 81d48748a6..01edeaa99e 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -1265,6 +1265,7 @@ OMPI_DECLSPEC int MPI_Keyval_free(int *keyval) __mpi_interface_deprecated__("MPI_Keyval_free is superseded by MPI_Comm_keyval_free in MPI-2.0"); OMPI_DECLSPEC int MPI_Lookup_name(char *service_name, MPI_Info info, char *port_name); OMPI_DECLSPEC MPI_Fint MPI_Op_c2f(MPI_Op op); +OMPI_DECLSPEC int MPI_Op_commutative(MPI_Op op, int *commute); OMPI_DECLSPEC int MPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op); OMPI_DECLSPEC int MPI_Open_port(MPI_Info info, char *port_name); OMPI_DECLSPEC MPI_Op MPI_Op_f2c(MPI_Fint op); @@ -1791,6 +1792,7 @@ OMPI_DECLSPEC int PMPI_Keyval_free(int *keyval) __mpi_interface_deprecated__("MPI_Keyval_free is superseded by MPI_Comm_keyval_free in MPI-2.0"); OMPI_DECLSPEC int PMPI_Lookup_name(char *service_name, MPI_Info info, char *port_name); OMPI_DECLSPEC MPI_Fint PMPI_Op_c2f(MPI_Op op); +OMPI_DECLSPEC int PMPI_Op_commutative(MPI_Op op, int *commute); OMPI_DECLSPEC int PMPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op); OMPI_DECLSPEC int PMPI_Open_port(MPI_Info info, char *port_name); OMPI_DECLSPEC MPI_Op PMPI_Op_f2c(MPI_Fint op); diff --git a/ompi/mpi/c/Makefile.am b/ompi/mpi/c/Makefile.am index 17ff8efae4..9674be62aa 100644 --- a/ompi/mpi/c/Makefile.am +++ b/ompi/mpi/c/Makefile.am @@ -189,6 +189,7 @@ libmpi_c_mpi_la_SOURCES = \ keyval_free.c \ lookup_name.c \ op_c2f.c \ + op_commutative.c \ op_create.c \ op_f2c.c \ op_free.c \ diff --git a/ompi/mpi/c/op_commutative.c b/ompi/mpi/c/op_commutative.c new file mode 100644 index 0000000000..f22cd18c36 --- /dev/null +++ b/ompi/mpi/c/op_commutative.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ +#include "ompi_config.h" + +#include + +#include "ompi/mpi/c/bindings.h" +#include "ompi/runtime/params.h" +#include "ompi/communicator/communicator.h" +#include "ompi/errhandler/errhandler.h" +#include "ompi/op/op.h" + +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES +#pragma weak MPI_Op_commutative = PMPI_Op_commutative +#endif + +#if OMPI_PROFILING_DEFINES +#include "ompi/mpi/c/profile/defines.h" +#endif + +static const char FUNC_NAME[] = "MPI_Op_commutative"; + + +int MPI_Op_commutative(MPI_Op op, int *commute) +{ + OPAL_CR_NOOP_PROGRESS(); + + /* Error checking */ + + if (MPI_PARAM_CHECK) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (NULL == op || + ompi_op_is_intrinsic(op)) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OP, + FUNC_NAME); + } + if (NULL == commute) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, + FUNC_NAME); + } + } + + /* We have a valid op, get the flag */ + + *commute = (op->o_flags & OMPI_OP_FLAGS_COMMUTE) ? 1 : 0; + + /* All done */ + + return MPI_SUCCESS; +} diff --git a/ompi/mpi/c/profile/Makefile.am b/ompi/mpi/c/profile/Makefile.am index f4a4fb72a1..8fff2c8dc0 100644 --- a/ompi/mpi/c/profile/Makefile.am +++ b/ompi/mpi/c/profile/Makefile.am @@ -172,6 +172,7 @@ nodist_libmpi_c_pmpi_la_SOURCES = \ plookup_name.c \ pop_c2f.c \ pop_create.c \ + pop_commutative.c \ pop_f2c.c \ pop_free.c \ popen_port.c \ diff --git a/ompi/mpi/c/profile/defines.h b/ompi/mpi/c/profile/defines.h index 61455ec295..b791c24296 100644 --- a/ompi/mpi/c/profile/defines.h +++ b/ompi/mpi/c/profile/defines.h @@ -216,6 +216,7 @@ #define MPI_Keyval_free PMPI_Keyval_free #define MPI_Lookup_name PMPI_Lookup_name #define MPI_Op_c2f PMPI_Op_c2f +#define MPI_Op_commutative PMPI_Op_commutative #define MPI_Op_create PMPI_Op_create #define MPI_Op_f2c PMPI_Op_f2c #define MPI_Op_free PMPI_Op_free diff --git a/ompi/mpi/cxx/op.h b/ompi/mpi/cxx/op.h index faad6ca872..a0490d9e9c 100644 --- a/ompi/mpi/cxx/op.h +++ b/ompi/mpi/cxx/op.h @@ -49,6 +49,7 @@ public: virtual void Reduce_local(const void *inbuf, void *inoutbuf, int count, const MPI::Datatype& datatype) const; + virtual bool Is_commutative(void) const; #if ! 0 /* OMPI_ENABLE_MPI_PROFILING */ protected: diff --git a/ompi/mpi/cxx/op_inln.h b/ompi/mpi/cxx/op_inln.h index 062d2d3ac8..bdd5a5fcfc 100644 --- a/ompi/mpi/cxx/op_inln.h +++ b/ompi/mpi/cxx/op_inln.h @@ -138,3 +138,12 @@ MPI::Op::Reduce_local(const void *inbuf, void *inoutbuf, int count, (void)MPI_Reduce_local(const_cast(inbuf), inoutbuf, count, datatype, mpi_op); } + + +inline bool +MPI::Op::Is_commutative(void) const +{ + int commute; + (void)MPI_Op_commutative(mpi_op, &commute); + return (bool) commute; +} diff --git a/ompi/mpi/f77/Makefile.am b/ompi/mpi/f77/Makefile.am index b893b92040..e2132c286c 100644 --- a/ompi/mpi/f77/Makefile.am +++ b/ompi/mpi/f77/Makefile.am @@ -200,6 +200,7 @@ libmpi_f77_la_SOURCES += \ keyval_create_f.c \ keyval_free_f.c \ lookup_name_f.c \ + op_commutative_f.c \ op_create_f.c \ open_port_f.c \ op_free_f.c \ diff --git a/ompi/mpi/f77/op_commutative_f.c b/ompi/mpi/f77/op_commutative_f.c new file mode 100644 index 0000000000..d2e4248834 --- /dev/null +++ b/ompi/mpi/f77/op_commutative_f.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * University Research and Technology + * Corporation. All rights reserved. + * Copyright (c) 2004-2005 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, + * University of Stuttgart. All rights reserved. + * Copyright (c) 2004-2005 The Regents of the University of California. + * All rights reserved. + * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include "ompi/mpi/f77/bindings.h" + +#if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILE_LAYER +#pragma weak PMPI_OP_COMMUTATIVE = mpi_op_commutative_f +#pragma weak pmpi_op_commutative = mpi_op_commutative_f +#pragma weak pmpi_op_commutative_ = mpi_op_commutative_f +#pragma weak pmpi_op_commutative__ = mpi_op_commutative_f +#elif OMPI_PROFILE_LAYER +OMPI_GENERATE_F77_BINDINGS (PMPI_OP_COMMUTATIVE, + pmpi_op_commutative, + pmpi_op_commutative_, + pmpi_op_commutative__, + pmpi_op_commutative_f, + (MPI_Fint *op, MPI_Fint *commute, MPI_Fint *ierr), + (op, commute, ierr) ) +#endif + +#if OPAL_HAVE_WEAK_SYMBOLS +#pragma weak MPI_OP_COMMUTATIVE = mpi_op_commutative_f +#pragma weak mpi_op_commutative = mpi_op_commutative_f +#pragma weak mpi_op_commutative_ = mpi_op_commutative_f +#pragma weak mpi_op_commutative__ = mpi_op_commutative_f +#endif + +#if ! OPAL_HAVE_WEAK_SYMBOLS && ! OMPI_PROFILE_LAYER +OMPI_GENERATE_F77_BINDINGS (MPI_OP_COMMUTATIVE, + mpi_op_commutative, + mpi_op_commutative_, + mpi_op_commutative__, + mpi_op_commutative_f, + (MPI_Fint *op, MPI_Fint *commute, MPI_Fint *ierr), + (op, commute, ierr) ) +#endif + + +#if OMPI_PROFILE_LAYER && ! OPAL_HAVE_WEAK_SYMBOLS +#include "ompi/mpi/f77/profile/defines.h" +#endif + +void mpi_op_commutative_f(MPI_Fint *op, MPI_Fint *commute, MPI_Fint *ierr) +{ + MPI_Op c_op; + OMPI_SINGLE_NAME_DECL(commute); + + c_op = MPI_Op_f2c(*op); + + *ierr = OMPI_INT_2_FINT(MPI_op_commutative(c_op, + OMPI_SINGLE_NAME_CONVERT(commute)); + if (MPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) { + OMPI_SINGLE_INT_2_FINT(commute); + } +} diff --git a/ompi/mpi/f77/profile/defines.h b/ompi/mpi/f77/profile/defines.h index 23f2c533ae..ebb55c541c 100644 --- a/ompi/mpi/f77/profile/defines.h +++ b/ompi/mpi/f77/profile/defines.h @@ -1,4 +1,3 @@ - /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -198,6 +198,7 @@ #define mpi_keyval_create_f pmpi_keyval_create_f #define mpi_keyval_free_f pmpi_keyval_free_f #define mpi_lookup_name_f pmpi_lookup_name_f +#define mpi_op_commutative_f pmpi_op_commutative_f #define mpi_op_create_f pmpi_op_create_f #define mpi_open_port_f pmpi_open_port_f #define mpi_op_free_f pmpi_op_free_f diff --git a/ompi/mpi/f77/prototypes_mpi.h b/ompi/mpi/f77/prototypes_mpi.h index 13d1226e92..4c3bd5df98 100644 --- a/ompi/mpi/f77/prototypes_mpi.h +++ b/ompi/mpi/f77/prototypes_mpi.h @@ -241,6 +241,7 @@ PN(void, mpi_is_thread_main, MPI_IS_THREAD_MAIN, (ompi_fortran_logical_t *flag, PN(void, mpi_keyval_create, MPI_KEYVAL_CREATE, (ompi_mpi1_fortran_copy_attr_function* copy_fn, ompi_mpi1_fortran_delete_attr_function* delete_fn, MPI_Fint *keyval, MPI_Fint *extra_state, MPI_Fint *ierr)); PN(void, mpi_keyval_free, MPI_KEYVAL_FREE, (MPI_Fint *keyval, MPI_Fint *ierr)); PN(void, mpi_lookup_name, MPI_LOOKUP_NAME, (char *service_name, MPI_Fint *info, char *port_name, MPI_Fint *ierr, int service_name_len, int port_name_len)); +PN(void, mpi_op_commutative, MPI_OP_COMMUTATIVE, (MPI_Fint *op, MPI_Fint *commute, MPI_Fint *ierr)); PN(void, mpi_op_create, MPI_OP_CREATE, (ompi_op_fortran_handler_fn_t* function, ompi_fortran_logical_t *commute, MPI_Fint *op, MPI_Fint *ierr)); PN(void, mpi_open_port, MPI_OPEN_PORT, (MPI_Fint *info, char *port_name, MPI_Fint *ierr, int port_name_len)); PN(void, mpi_op_free, MPI_OP_FREE, (MPI_Fint *op, MPI_Fint *ierr)); diff --git a/ompi/mpi/f90/scripts/mpi-f90-interfaces.h.sh b/ompi/mpi/f90/scripts/mpi-f90-interfaces.h.sh index 69605aae15..24057dcc42 100755 --- a/ompi/mpi/f90/scripts/mpi-f90-interfaces.h.sh +++ b/ompi/mpi/f90/scripts/mpi-f90-interfaces.h.sh @@ -5912,6 +5912,29 @@ end MPI_Keyval_free #------------------------------------------------------------------------ +output_171_commutative() { + if test "$output" = "0"; then + return 0 + fi + + procedure=$1 + cat <