2004-01-10 01:09:51 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#ifndef OMPI_COMMUNICATOR_H
|
|
|
|
#define OMPI_COMMUNICATOR_H
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "class/ompi_object.h"
|
2004-03-19 03:00:09 +03:00
|
|
|
#include "errhandler/errhandler.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "threads/mutex.h"
|
|
|
|
#include "util/output.h"
|
2004-01-11 03:13:22 +03:00
|
|
|
#include "mpi.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "group/group.h"
|
|
|
|
#include "mca/coll/coll.h"
|
2004-04-17 00:54:48 +04:00
|
|
|
#include "mca/topo/topo.h"
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "class/ompi_hash_table.h"
|
2004-03-26 23:02:42 +03:00
|
|
|
#include "attribute/attribute.h"
|
2004-05-08 03:15:10 +04:00
|
|
|
#include "request/request.h"
|
2004-02-06 07:20:13 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_class_t ompi_communicator_t_class;
|
2004-02-13 16:56:55 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#define OMPI_COMM_INTER 0x00000001
|
|
|
|
#define OMPI_COMM_CART 0x00000002
|
|
|
|
#define OMPI_COMM_GRAPH 0x00000004
|
|
|
|
#define OMPI_COMM_NAMEISSET 0x00000008
|
|
|
|
#define OMPI_COMM_ISFREED 0x00000010
|
2004-06-15 04:09:40 +04:00
|
|
|
#define OMPI_COMM_INTRINSIC 0x00000020
|
2004-02-13 16:56:55 +03:00
|
|
|
|
2004-04-21 04:16:05 +04:00
|
|
|
/* some utility #defines */
|
2004-06-07 19:33:53 +04:00
|
|
|
#define OMPI_COMM_IS_INTER(comm) ((comm)->c_flags & OMPI_COMM_INTER)
|
|
|
|
#define OMPI_COMM_IS_INTRA(comm) (!((comm)->c_flags & OMPI_COMM_INTER))
|
|
|
|
#define OMPI_COMM_IS_CART(comm) ((comm)->c_flags & OMPI_COMM_CART)
|
|
|
|
#define OMPI_COMM_IS_GRAPH(comm) ((comm)->c_flags & OMPI_COMM_GRAPH)
|
2004-06-15 04:09:40 +04:00
|
|
|
#define OMPI_COMM_IS_INTRINSIC(comm) ((comm)->c_flags & OMPI_COMM_INTRINSIC)
|
2004-04-21 04:16:05 +04:00
|
|
|
|
2004-05-21 23:36:19 +04:00
|
|
|
/**
|
|
|
|
* Modes reqquired for accquiring the new comm-id.
|
|
|
|
* The first (INTER/INTRA) indicates whether the
|
|
|
|
* input comm was an inter/intra-comm, the second
|
|
|
|
* whether the new communicator will be an inter/intra
|
|
|
|
*comm
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
#define OMPI_COMM_INTRA_INTRA 0x00000020
|
|
|
|
#define OMPI_COMM_INTRA_INTER 0x00000040
|
|
|
|
#define OMPI_COMM_INTER_INTRA 0x00000080
|
|
|
|
#define OMPI_COMM_INTER_INTER 0x00000100
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_pointer_array_t ompi_mpi_communicators;
|
2004-05-21 23:36:19 +04:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
struct ompi_communicator_t {
|
|
|
|
ompi_object_t c_base;
|
2004-03-26 23:02:42 +03:00
|
|
|
char c_name[MPI_MAX_OBJECT_NAME];
|
|
|
|
uint32_t c_contextid;
|
|
|
|
int c_my_rank;
|
|
|
|
uint32_t c_flags; /* flags, e.g. intercomm,
|
|
|
|
topology, etc. */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_group_t *c_local_group;
|
|
|
|
ompi_group_t *c_remote_group;
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-01-10 11:20:15 +03:00
|
|
|
/* Attributes */
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_hash_table_t *c_keyhash;
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-04-21 04:16:05 +04:00
|
|
|
int c_cube_dim; /**< inscribing cube dimension */
|
|
|
|
|
2004-04-17 00:54:48 +04:00
|
|
|
/* Hooks for topo module to hang things */
|
|
|
|
mca_topo_1_0_0_t c_topo; /**< structure of function pointers */
|
|
|
|
mca_topo_comm_t *c_topo_comm; /**<structure containing information
|
|
|
|
*about the topology */
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-03-19 03:00:09 +03:00
|
|
|
/* index in Fortran <-> C translation array */
|
|
|
|
|
|
|
|
int c_f_to_c_index;
|
|
|
|
|
2004-03-19 09:12:43 +03:00
|
|
|
/* Error handling. This field does not have the "c_" prefix so
|
2004-06-07 19:33:53 +04:00
|
|
|
that the OMPI_ERRHDL_* macros can find it, regardless of whether
|
2004-03-19 09:12:43 +03:00
|
|
|
it's a comm, window, or file. */
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_errhandler_t *error_handler;
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-01-10 11:20:15 +03:00
|
|
|
/* Hooks for PML to hang things */
|
2004-01-14 20:40:12 +03:00
|
|
|
struct mca_pml_comm_t* c_pml_comm;
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-01-10 11:20:15 +03:00
|
|
|
/* Hooks for collectives to hang things */
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-01-12 00:32:57 +03:00
|
|
|
mca_coll_1_0_0_t c_coll;
|
2004-01-10 11:20:15 +03:00
|
|
|
struct mca_coll_comm_t* c_coll_comm;
|
2004-05-08 03:15:10 +04:00
|
|
|
|
|
|
|
/* VPS: This will be moved in the coll module later on */
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_request_t **bcast_lin_reqs;
|
|
|
|
ompi_request_t **bcast_log_reqs;
|
2004-05-08 03:15:10 +04:00
|
|
|
|
2004-01-10 20:05:04 +03:00
|
|
|
};
|
2004-06-07 19:33:53 +04:00
|
|
|
typedef struct ompi_communicator_t ompi_communicator_t;
|
2004-01-10 01:09:51 +03:00
|
|
|
|
2004-01-11 02:12:43 +03:00
|
|
|
|
2004-03-17 00:56:19 +03:00
|
|
|
/**
|
|
|
|
* is this a valid communicator
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline int ompi_comm_invalid(ompi_communicator_t* comm)
|
2004-03-17 00:56:19 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( comm->c_flags & OMPI_COMM_ISFREED )
|
2004-05-21 23:36:19 +04:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
2004-03-17 00:56:19 +03:00
|
|
|
}
|
2004-05-21 23:36:19 +04:00
|
|
|
|
2004-03-03 19:44:41 +03:00
|
|
|
/**
|
|
|
|
* rank w/in the communicator
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline int ompi_comm_rank(ompi_communicator_t* comm)
|
2004-03-03 19:44:41 +03:00
|
|
|
{
|
|
|
|
return comm->c_my_rank;
|
|
|
|
}
|
2004-03-12 01:02:01 +03:00
|
|
|
/**
|
|
|
|
* size of the communicator
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline int ompi_comm_size(ompi_communicator_t* comm)
|
2004-03-12 01:02:01 +03:00
|
|
|
{
|
2004-03-26 23:02:42 +03:00
|
|
|
return comm->c_local_group->grp_proc_count;
|
2004-03-12 01:02:01 +03:00
|
|
|
}
|
|
|
|
|
2004-03-26 23:02:42 +03:00
|
|
|
/**
|
|
|
|
* size of the remote group for inter-communicators.
|
|
|
|
* returns zero for an intra-communicator
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline int ompi_comm_remote_size(ompi_communicator_t* comm)
|
2004-03-26 23:02:42 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
if ( comm->c_flags & OMPI_COMM_INTER )
|
2004-03-26 23:02:42 +03:00
|
|
|
return comm->c_remote_group->grp_proc_count;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2004-03-03 19:44:41 +03:00
|
|
|
|
2004-01-11 02:12:43 +03:00
|
|
|
/* return pointer to communicator associated with context id cid,
|
|
|
|
* No error checking is done*/
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline ompi_communicator_t *ompi_comm_lookup(uint32_t cid)
|
2004-01-11 02:12:43 +03:00
|
|
|
{
|
|
|
|
/* array of pointers to communicators, indexed by context ID */
|
2004-06-07 19:33:53 +04:00
|
|
|
extern ompi_pointer_array_t ompi_mpi_communicators;
|
|
|
|
return (ompi_communicator_t*)ompi_pointer_array_get_item(&ompi_mpi_communicators, cid);
|
2004-01-11 02:12:43 +03:00
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline ompi_proc_t* ompi_comm_peer_lookup(ompi_communicator_t* comm, int peer_id)
|
2004-01-12 21:47:12 +03:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_ENABLE_DEBUG
|
2004-02-12 01:55:06 +03:00
|
|
|
if(peer_id >= comm->c_remote_group->grp_proc_count) {
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_output(0, "ompi_comm_lookup_peer: invalid peer index (%d)", peer_id);
|
|
|
|
return (ompi_proc_t *) NULL;
|
2004-01-29 01:52:51 +03:00
|
|
|
}
|
2004-01-12 21:47:12 +03:00
|
|
|
#endif
|
2004-02-12 01:55:06 +03:00
|
|
|
return comm->c_remote_group->grp_proc_pointers[peer_id];
|
2004-01-12 21:47:12 +03:00
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline bool ompi_comm_peer_invalid(ompi_communicator_t* comm, int peer_id)
|
2004-03-17 00:56:19 +03:00
|
|
|
{
|
|
|
|
if(peer_id < 0 || peer_id >= comm->c_remote_group->grp_proc_count) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
static inline int ompi_cube_dim(int nprocs) {
|
2004-04-21 04:16:05 +04:00
|
|
|
int dim;
|
|
|
|
size_t size;
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
if (1 > nprocs) return OMPI_ERROR;
|
2004-04-22 00:55:54 +04:00
|
|
|
for(dim = 0, size = 1; size < (size_t)nprocs; ++dim, size <<= 1);
|
2004-04-21 04:16:05 +04:00
|
|
|
|
|
|
|
return dim;
|
|
|
|
}
|
2004-03-17 00:56:19 +03:00
|
|
|
|
2004-02-06 07:20:13 +03:00
|
|
|
|
2004-02-05 04:52:56 +03:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2004-03-26 23:02:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise MPI_COMM_WORLD and MPI_COMM_SELF
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_init(void);
|
|
|
|
int ompi_comm_link_function(void);
|
2004-03-26 23:02:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* extract the local group from a communicator
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_group ( ompi_communicator_t *comm, ompi_group_t **group );
|
2004-03-26 23:02:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* create a communicator based on a group
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_create ( ompi_communicator_t* comm, ompi_group_t *group,
|
|
|
|
ompi_communicator_t** newcomm );
|
2004-03-26 23:02:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* split a communicator based on color and key. Parameters
|
|
|
|
* are identical to the MPI-counterpart of the function.
|
|
|
|
*
|
|
|
|
* @param comm: input communicator
|
|
|
|
* @param color
|
|
|
|
* @param key
|
|
|
|
*
|
|
|
|
* @
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_split ( ompi_communicator_t *comm, int color, int key,
|
|
|
|
ompi_communicator_t** newcomm );
|
2004-03-26 23:02:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* free a communicator
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_free ( ompi_communicator_t **comm );
|
2004-03-26 23:02:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* allocate a new communicator structure
|
|
|
|
* @param local_group_size
|
|
|
|
* @param remote_group_size
|
|
|
|
*
|
|
|
|
* this routine allocates the structure, the according local and
|
|
|
|
* remote groups, the proc-arrays in the local and remote group.
|
|
|
|
* It furthermore sets the fortran index correctly,
|
|
|
|
* and sets all other elements to zero.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_communicator_t* ompi_comm_allocate ( int local_group_size,
|
2004-03-26 23:02:42 +03:00
|
|
|
int remote_group_size );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* allocate new communicator ID
|
2004-05-21 23:36:19 +04:00
|
|
|
* @param comm: original comm
|
|
|
|
* @param bridgecomm: bridge comm for intercomm_create
|
2004-03-26 23:02:42 +03:00
|
|
|
* @param mode: combination of input and output communicator
|
2004-06-07 19:33:53 +04:00
|
|
|
* OMPI_COMM_INTRA_INTRA, OMPI_COMM_INTRA_INTER,
|
|
|
|
* OMPI_COMM_INTER_INTRA, OMPI_COMM_INTER_INTER
|
2004-03-26 23:02:42 +03:00
|
|
|
*
|
|
|
|
* This routine has to be thread safe in the final version.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_nextcid ( ompi_communicator_t* comm,
|
|
|
|
ompi_communicator_t* bridgecomm,
|
2004-05-21 23:36:19 +04:00
|
|
|
int local_leader,
|
|
|
|
int remote_leader,
|
|
|
|
int mode);
|
2004-03-26 23:02:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shut down the communicator infrastructure.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_finalize (void);
|
2004-05-21 23:36:19 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is THE routine, where all the communicator stuff
|
|
|
|
* is really set.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_communicator_t* ompi_comm_set ( int mode,
|
|
|
|
ompi_communicator_t* oldcomm,
|
|
|
|
ompi_communicator_t* bridgecomm,
|
2004-05-21 23:36:19 +04:00
|
|
|
int local_size,
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_proc_t **local_procs,
|
2004-05-21 23:36:19 +04:00
|
|
|
int remote_size,
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_proc_t **remote_procs,
|
|
|
|
ompi_hash_table_t *attr,
|
|
|
|
ompi_errhandler_t *errh,
|
2004-05-21 23:36:19 +04:00
|
|
|
mca_base_module_t *collmodule,
|
|
|
|
mca_base_module_t *topomodule,
|
|
|
|
int local_leader,
|
|
|
|
int remote_leader);
|
|
|
|
/**
|
|
|
|
* This is a short-hand routine used in intercomm_create.
|
|
|
|
* The routine makes sure, that all processes have afterwards
|
2004-06-07 19:33:53 +04:00
|
|
|
* a list of ompi_proc_t pointers for the remote group.
|
2004-05-21 23:36:19 +04:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_proc_t **ompi_comm_get_rprocs ( ompi_communicator_t *local_comm,
|
|
|
|
ompi_communicator_t *bridge_comm,
|
2004-05-21 23:36:19 +04:00
|
|
|
int local_leader,
|
|
|
|
int remote_leader,
|
|
|
|
int tag,
|
|
|
|
int rsize);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a routine determining whether the local or the
|
|
|
|
* remote group will be first in the new intra-comm.
|
|
|
|
* Just used from within MPI_Intercomm_merge.
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_comm_determine_first ( ompi_communicator_t *intercomm,
|
2004-05-21 23:36:19 +04:00
|
|
|
int high );
|
|
|
|
|
2004-02-05 04:52:56 +03:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#endif /* OMPI_COMMUNICATOR_H */
|