2004-01-10 11:20:36 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#ifndef OMPI_OP_H
|
|
|
|
#define OMPI_OP_H
|
2004-01-10 11:20:36 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-04-21 02:37:46 +04:00
|
|
|
|
2004-01-10 11:20:36 +03:00
|
|
|
#include "mpi.h"
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "class/ompi_object.h"
|
|
|
|
#include "class/ompi_pointer_array.h"
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These must correspond to the fortran handle indices
|
|
|
|
*/
|
2004-04-21 03:11:11 +04:00
|
|
|
#define MPI_OP_MAX_FORTRAN 0
|
|
|
|
#define MPI_OP_MIN_FORTRAN 1
|
|
|
|
#define MPI_OP_SUM_FORTRAN 2
|
|
|
|
#define MPI_OP_PROD_FORTRAN 3
|
|
|
|
#define MPI_OP_LAND_FORTRAN 4
|
|
|
|
#define MPI_OP_BAND_FORTRAN 5
|
|
|
|
#define MPI_OP_LOR_FORTRAN 6
|
|
|
|
#define MPI_OP_BOR_FORTRAN 7
|
|
|
|
#define MPI_OP_LXOR_FORTRAN 8
|
|
|
|
#define MPI_OP_BXOR_FORTRAN 9
|
|
|
|
#define MPI_OP_MAXLOC_FORTRAN 10
|
|
|
|
#define MPI_OP_MINLOC_FORTRAN 11
|
|
|
|
#define MPI_OP_REPLACE_FORTRAN 12
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Typedef for C op functions. We don't use MPI_User_function because
|
|
|
|
* this would create a confusing dependency loop between this file and
|
|
|
|
* mpi.h.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
typedef void (ompi_op_c_handler_fn_t)(void *, void *, int *, MPI_Datatype *);
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Typedef for fortran op functions
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
typedef void (ompi_op_fortran_handler_fn_t)(void *, void *, int *, MPI_Fint *);
|
2004-01-10 11:20:36 +03:00
|
|
|
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Back-end type of MPI_Op
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
struct ompi_op_t {
|
|
|
|
ompi_object_t super;
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
char o_name[MPI_MAX_OBJECT_NAME];
|
2004-01-10 11:20:36 +03:00
|
|
|
|
2004-04-21 02:37:46 +04:00
|
|
|
/* Flags about the op */
|
|
|
|
|
|
|
|
bool o_is_intrinsic;
|
|
|
|
bool o_fortran_function;
|
|
|
|
bool o_is_assoc;
|
2004-04-21 03:11:11 +04:00
|
|
|
bool o_is_commute;
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/* Function pointers */
|
|
|
|
|
|
|
|
union {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_op_c_handler_fn_t *c_fn;
|
|
|
|
ompi_op_fortran_handler_fn_t *fort_fn;
|
2004-04-21 02:37:46 +04:00
|
|
|
} o_func;
|
|
|
|
|
|
|
|
/* index in Fortran <-> C translation array */
|
|
|
|
|
|
|
|
int o_f_to_c_index;
|
2004-01-10 20:10:29 +03:00
|
|
|
};
|
2004-06-07 19:33:53 +04:00
|
|
|
typedef struct ompi_op_t ompi_op_t;
|
2004-01-10 11:20:36 +03:00
|
|
|
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_NULL
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_null;
|
|
|
|
#define OMPI_OP_NULL_FORTRAN 0
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_MAX
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_max;
|
|
|
|
#define OMPI_OP_MAX_FORTRAN 1
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_MIN
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_min;
|
|
|
|
#define OMPI_OP_MIN_FORTRAN 2
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_SUM
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_sum;
|
|
|
|
#define OMPI_OP_SUM_FORTRAN 3
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_PROD
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_prod;
|
|
|
|
#define OMPI_OP_PROD_FORTRAN 4
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_LAND
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_land;
|
|
|
|
#define OMPI_OP_LAND_FORTRAN 5
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_BAND
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_band;
|
|
|
|
#define OMPI_OP_BAND_FORTRAN 6
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_LOR
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_lor;
|
|
|
|
#define OMPI_OP_LOR_FORTRAN 7
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_BOR
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_bor;
|
|
|
|
#define OMPI_OP_BOR_FORTRAN 8
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_LXOR
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_lxor;
|
|
|
|
#define OMPI_OP_LXOR_FORTRAN 9
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_BXOR
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_bxor;
|
|
|
|
#define OMPI_OP_BXOR_FORTRAN 10
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_MAXLOC
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_maxloc;
|
|
|
|
#define OMPI_OP_MAXLOC_FORTRAN 11
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_MINLOC
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_minloc;
|
|
|
|
#define OMPI_OP_MINLOC_FORTRAN 12
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable for MPI_REPLACE
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_op_t ompi_mpi_op_replace;
|
|
|
|
#define OMPI_OP_REPLACE_FORTRAN 13
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Table for Fortran <-> C op handle conversion
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_pointer_array_t *ompi_op_f_to_c_table;
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the op interface.
|
|
|
|
*
|
2004-06-07 19:33:53 +04:00
|
|
|
* @returns OMPI_SUCCESS Upon success
|
|
|
|
* @returns OMPI_ERROR Otherwise
|
2004-04-21 02:37:46 +04:00
|
|
|
*
|
2004-06-07 19:33:53 +04:00
|
|
|
* Invoked from ompi_mpi_init(); sets up the op interface, creates
|
2004-04-21 02:37:46 +04:00
|
|
|
* the predefined MPI operations, and creates the corresopnding F2C
|
|
|
|
* translation table.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_op_init(void);
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finalize the op interface.
|
|
|
|
*
|
2004-06-07 19:33:53 +04:00
|
|
|
* @returns OMPI_SUCCESS Always
|
2004-04-21 02:37:46 +04:00
|
|
|
*
|
2004-06-07 19:33:53 +04:00
|
|
|
* Invokes from ompi_mpi_finalize(); tears down the op interface, and
|
2004-04-21 02:37:46 +04:00
|
|
|
* destroys the F2C translation table.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_op_finalize(void);
|
2004-04-21 02:37:46 +04:00
|
|
|
|
|
|
|
/**
|
2004-06-07 19:33:53 +04:00
|
|
|
* Create a ompi_op_t
|
2004-04-21 02:37:46 +04:00
|
|
|
*
|
2004-04-21 03:11:11 +04:00
|
|
|
* @param commute Boolean indicating whether the operation is
|
|
|
|
* communative or not
|
|
|
|
* @param func Function pointer of the error handler
|
|
|
|
*
|
2004-06-07 19:33:53 +04:00
|
|
|
* @returns op Pointer to the ompi_op_t that will be
|
2004-04-21 03:11:11 +04:00
|
|
|
* created and returned
|
|
|
|
*
|
|
|
|
* This function is called as the back-end of all the MPI_OP_CREATE
|
2004-06-07 19:33:53 +04:00
|
|
|
* functions. It creates a new ompi_op_t object, initializes it to
|
2004-04-21 03:11:11 +04:00
|
|
|
* the correct object type, and sets the callback function on it.
|
|
|
|
*
|
|
|
|
* The type of the function pointer is (arbitrarily) the fortran
|
|
|
|
* function handler type. Since this function has to accept 2
|
|
|
|
* different function pointer types (lest we have 2 different
|
|
|
|
* functions to create errhandlers), the fortran one was picked
|
|
|
|
* arbitrarily. Note that (void*) is not sufficient because at
|
|
|
|
* least theoretically, a sizeof(void*) may not necessarily be the
|
|
|
|
* same as sizeof(void(*)).
|
|
|
|
*
|
|
|
|
* NOTE: It *always* sets the "fortran" flag to false. The Fortran
|
|
|
|
* wrapper for MPI_OP_CREATE is expected to reset this flag to true
|
|
|
|
* manually.
|
2004-04-21 02:37:46 +04:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_op_t *ompi_op_create(bool commute, ompi_op_fortran_handler_fn_t *func);
|
2004-04-21 03:11:11 +04:00
|
|
|
|
2004-04-21 02:37:46 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-04-21 03:11:11 +04:00
|
|
|
/**
|
|
|
|
* Check to see if an op is intrinsic.
|
|
|
|
*
|
|
|
|
* @param op The op to check
|
|
|
|
*
|
|
|
|
* @returns true If the op is intrinsic
|
|
|
|
* @returns false If the op is not intrinsic
|
|
|
|
*
|
|
|
|
* Self-explanitory. This is needed in a few top-level MPI functions;
|
|
|
|
* this function is provided to hide the internal structure field
|
|
|
|
* names.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline bool ompi_op_is_intrinsic(ompi_op_t *op)
|
2004-04-21 03:11:11 +04:00
|
|
|
{
|
|
|
|
return op->o_is_intrinsic;
|
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#endif /* OMPI_OP_H */
|