1
1

Add another flag to MPI_Op's -- whether it is associative with

floating point numbers or not (e.g., MAX is, but SUM is not).

This commit was SVN r7230.
Этот коммит содержится в:
Jeff Squyres 2005-09-08 09:47:27 +00:00
родитель 67cde6c212
Коммит 1d20f800ba
2 изменённых файлов: 49 добавлений и 18 удалений

Просмотреть файл

@ -272,11 +272,17 @@ OBJ_CLASS_INSTANCE(ompi_op_t, opal_object_t,
* MPI_OP_NULL
* All types
*/
#define FLAGS_NO_FLOAT \
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE)
#define FLAGS \
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | \
OMPI_OP_FLAGS_FLOAT_ASSOC | OMPI_OP_FLAGS_COMMUTE)
ompi_op_t ompi_mpi_op_null = {
{ NULL, 0 },
"MPI_OP_NULL",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER_NULL,
FORTRAN_INTEGER_NULL,
FLOATING_POINT_NULL,
@ -295,7 +301,7 @@ ompi_op_t ompi_mpi_op_max = {
{ NULL, 0 },
"MPI_OP_MAX",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(max),
FORTRAN_INTEGER(max),
FLOATING_POINT(max),
@ -313,7 +319,7 @@ ompi_op_t ompi_mpi_op_min = {
{ NULL, 0 },
"MPI_OP_MIN",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(min),
FORTRAN_INTEGER(min),
FLOATING_POINT(min),
@ -331,7 +337,7 @@ ompi_op_t ompi_mpi_op_sum = {
{ NULL, 0 },
"MPI_OP_SUM",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS_NO_FLOAT,
{ C_INTEGER(sum),
FORTRAN_INTEGER(sum),
FLOATING_POINT(sum),
@ -349,7 +355,7 @@ ompi_op_t ompi_mpi_op_prod = {
{ NULL, 0 },
"MPI_OP_PROD",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS_NO_FLOAT,
{ C_INTEGER(prod),
FORTRAN_INTEGER(prod),
FLOATING_POINT(prod),
@ -367,7 +373,7 @@ ompi_op_t ompi_mpi_op_land = {
{ NULL, 0 },
"MPI_OP_LAND",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(land),
FORTRAN_INTEGER_NULL,
FLOATING_POINT_NULL,
@ -385,7 +391,7 @@ ompi_op_t ompi_mpi_op_band = {
{ NULL, 0 },
"MPI_OP_BAND",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(band),
FORTRAN_INTEGER(band),
FLOATING_POINT_NULL,
@ -403,7 +409,7 @@ ompi_op_t ompi_mpi_op_lor = {
{ NULL, 0 },
"MPI_OP_LOR",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(lor),
FORTRAN_INTEGER_NULL,
FLOATING_POINT_NULL,
@ -421,7 +427,7 @@ ompi_op_t ompi_mpi_op_bor = {
{ NULL, 0 },
"MPI_OP_BOR",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(bor),
FORTRAN_INTEGER(bor),
FLOATING_POINT_NULL,
@ -439,7 +445,7 @@ ompi_op_t ompi_mpi_op_lxor = {
{ NULL, 0 },
"MPI_OP_LXOR",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(lxor),
FORTRAN_INTEGER_NULL,
FLOATING_POINT_NULL,
@ -457,7 +463,7 @@ ompi_op_t ompi_mpi_op_bxor = {
{ NULL, 0 },
"MPI_OP_BXOR",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(bxor),
FORTRAN_INTEGER(bxor),
FLOATING_POINT_NULL,
@ -493,7 +499,7 @@ ompi_op_t ompi_mpi_op_minloc = {
{ NULL, 0 },
"MPI_OP_MINLOC",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER_NULL,
FORTRAN_INTEGER_NULL,
FLOATING_POINT_NULL,
@ -510,7 +516,7 @@ ompi_op_t ompi_mpi_op_replace = {
{ NULL, 0 },
"MPI_OP_REPLACE",
(OMPI_OP_FLAGS_INTRINSIC | OMPI_OP_FLAGS_ASSOC | OMPI_OP_FLAGS_COMMUTE),
FLAGS,
{ C_INTEGER(replace),
FORTRAN_INTEGER(replace),
FLOATING_POINT(replace),

Просмотреть файл

@ -181,14 +181,22 @@ typedef void (ompi_op_fortran_handler_fn_t)(void *, void *,
/*
* Flags for MPI_Op
*/
/** Set if the MPI_Op is a built-in operation */
#define OMPI_OP_FLAGS_INTRINSIC 0x0001
/**< Set if the MPI_Op is a built-in operation */
/** Set if the callback function is in Fortran */
#define OMPI_OP_FLAGS_FORTRAN_FUNC 0x0002
/**< Set if the callback function is in Fortran */
/** Set if the callback function is associative (MAX and SUM will both
have ASSOC set -- in fact, it will only *not* be set if we
implement some extensions to MPI, because MPI says that all
MPI_Op's should be associative, so this flag is really here for
future expansion) */
#define OMPI_OP_FLAGS_ASSOC 0x0004
/**< Set if the callback function is associative */
#define OMPI_OP_FLAGS_COMMUTE 0x0008
/**< Set if the callback function is communative */
/** Set if the callback function is associative for floating point
operands (e.g., MPI_SUM will have ASSOC set, but will *not* have
FLOAT_ASSOC set) */
#define OMPI_OP_FLAGS_FLOAT_ASSOC 0x0008
/** Set if the callback function is communative */
#define OMPI_OP_FLAGS_COMMUTE 0x0010
/**
@ -424,6 +432,23 @@ static inline bool ompi_op_is_commute(ompi_op_t *op)
return (bool) (0 != (op->o_flags & OMPI_OP_FLAGS_COMMUTE));
}
/**
* Check to see if an op is floating point associative or not
*
* @param op The op to check
*
* @returns true If the op is floating point associative
* @returns false If the op is not floating point associative
*
* Self-explanitory. This is needed in a few top-level MPI functions;
* this function is provided to hide the internal structure field
* names.
*/
static inline bool ompi_op_is_float_assoc(ompi_op_t *op)
{
return (bool) (0 != (op->o_flags & OMPI_OP_FLAGS_FLOAT_ASSOC));
}
/**
* Perform a reduction operation.