1
1
openmpi/src/mpi/communicator/communicator.h

94 строки
2.1 KiB
C
Исходник Обычный вид История

/*
* $HEADER$
*/
#ifndef LAM_COMMUNICATOR_H
#define LAM_COMMUNICATOR_H
#include "lam/stdint.h"
#include "lam/lfc/lam_object.h"
#include "lam/threads/mutex.h"
#include "lam/util/output.h"
#include "mpi.h"
#include "mpi/group/group.h"
#include "mca/mpi/coll/coll.h"
extern lam_class_t lam_communicator_t_class;
struct lam_communicator_t {
lam_object_t c_base;
char c_name[MPI_MAX_OBJECT_NAME];
uint32_t c_contextid;
int c_my_rank;
lam_group_t *c_local_group;
lam_group_t *c_remote_group;
/* Attributes */
/* Topology information */
/* Error handling */
MPI_Errhandler c_error_handler;
/* Hooks for PML to hang things */
struct mca_pml_comm_t* c_pml_comm;
/* Hooks for collectives to hang things */
mca_coll_1_0_0_t c_coll;
struct mca_coll_comm_t* c_coll_comm;
};
typedef struct lam_communicator_t lam_communicator_t;
/**
* rank w/in the communicator
*/
static inline int lam_comm_rank(lam_communicator_t* comm)
{
return comm->c_my_rank;
}
/* return pointer to communicator associated with context id cid,
* No error checking is done*/
static inline lam_communicator_t *lam_comm_lookup(uint32_t cid)
{
/* array of pointers to communicators, indexed by context ID */
extern lam_communicator_t **lam_mpi_comm_array;
#if LAM_ENABLE_DEBUG
extern uint32_t lam_mpi_comm_array_size;
if (cid >= lam_mpi_comm_array_size) {
lam_output(0, "lam_comm_lookup: invalid communicator index (%d)", cid);
return (lam_communicator_t *) NULL;
}
#endif
return lam_mpi_comm_array[cid];
}
static inline lam_proc_t* lam_comm_lookup_peer(lam_communicator_t* comm, int peer_id)
{
#if LAM_ENABLE_DEBUG
if(peer_id >= comm->c_remote_group->grp_proc_count) {
lam_output(0, "lam_comm_lookup_peer: invalid peer index (%d)", peer_id);
return (lam_proc_t *) NULL;
}
#endif
return comm->c_remote_group->grp_proc_pointers[peer_id];
}
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
int lam_comm_init(void);
int lam_comm_link_function(void);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* LAM_COMMUNICATOR_H */