1
1

Pushing c_cube_dim to communicator since it is used by more than one type

This commit was SVN r1068.
Этот коммит содержится в:
Prabhanjan Kambadur 2004-04-21 00:16:05 +00:00
родитель 2b0cd649b7
Коммит a8d9e4ac7d
2 изменённых файлов: 25 добавлений и 1 удалений

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

@ -24,6 +24,12 @@ extern lam_class_t lam_communicator_t_class;
#define LAM_COMM_NAMEISSET 0x00000008 #define LAM_COMM_NAMEISSET 0x00000008
#define LAM_COMM_ISFREED 0x00000010 #define LAM_COMM_ISFREED 0x00000010
/* some utility #defines */
#define LAM_COMM_IS_INTER(comm) ((comm)->c_flags & LAM_COMM_INTER)
#define LAM_COMM_IS_INTRA(comm) (!((comm)->c_flags & LAM_COMM_INTER))
#define LAM_COMM_IS_CART(comm) ((comm)->c_flags & LAM_COMM_CART)
#define LAM_COMM_IS_GRAPH(comm) ((comm)->c_flags & LAM_COMM_GRAPH)
/* modes reqquired for accquiring the new comm-id */ /* modes reqquired for accquiring the new comm-id */
#define LAM_COMM_INTRA_INTRA 0x00000020 #define LAM_COMM_INTRA_INTRA 0x00000020
#define LAM_COMM_INTRA_INTER 0x00000040 #define LAM_COMM_INTRA_INTER 0x00000040
@ -44,6 +50,8 @@ struct lam_communicator_t {
/* Attributes */ /* Attributes */
lam_hash_table_t *c_keyhash; lam_hash_table_t *c_keyhash;
int c_cube_dim; /**< inscribing cube dimension */
/* Hooks for topo module to hang things */ /* Hooks for topo module to hang things */
mca_topo_1_0_0_t c_topo; /**< structure of function pointers */ mca_topo_1_0_0_t c_topo; /**< structure of function pointers */
mca_topo_comm_t *c_topo_comm; /**<structure containing information mca_topo_comm_t *c_topo_comm; /**<structure containing information
@ -132,6 +140,15 @@ static inline bool lam_comm_peer_invalid(lam_communicator_t* comm, int peer_id)
return false; return false;
} }
static inline int lam_cube_dim(int nprocs) {
int dim;
size_t size;
if (1 > nprocs) return LAM_ERROR;
for(dim = 0, size = 1; size < nprocs; ++dim, size <<= 1);
return dim;
}
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)

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

@ -79,6 +79,7 @@ int lam_comm_init(void)
lam_mpi_comm_world.c_my_rank = group->grp_my_rank; lam_mpi_comm_world.c_my_rank = group->grp_my_rank;
lam_mpi_comm_world.c_local_group = group; lam_mpi_comm_world.c_local_group = group;
lam_mpi_comm_world.c_remote_group = group; lam_mpi_comm_world.c_remote_group = group;
lam_mpi_comm_world.c_cube_dim = lam_cube_dim(size);
mca_pml.pml_add_comm(&lam_mpi_comm_world); mca_pml.pml_add_comm(&lam_mpi_comm_world);
lam_pointer_array_set_item(&lam_mpi_communicators, 0, &lam_mpi_comm_world); lam_pointer_array_set_item(&lam_mpi_communicators, 0, &lam_mpi_comm_world);
@ -134,8 +135,13 @@ lam_communicator_t *lam_comm_allocate ( int local_size, int remote_size )
new_comm->c_remote_group = new_comm->c_local_group; new_comm->c_remote_group = new_comm->c_local_group;
} }
} }
/* fill in the inscribing hyper-cube dimensions */
new_comm->c_cube_dim = lam_cube_dim(local_size);
if (LAM_ERROR == new_comm->c_cube_dim) {
OBJ_RELEASE(new_comm);
new_comm = NULL;
}
} }
return new_comm; return new_comm;
} }
@ -409,6 +415,7 @@ static void lam_comm_construct(lam_communicator_t* comm)
comm->c_contextid = 0; comm->c_contextid = 0;
comm->c_flags = 0; comm->c_flags = 0;
comm->c_my_rank = 0; comm->c_my_rank = 0;
comm->c_cube_dim = 0;
comm->c_local_group = NULL; comm->c_local_group = NULL;
comm->c_remote_group = NULL; comm->c_remote_group = NULL;
comm->error_handler = NULL; comm->error_handler = NULL;