diff --git a/src/communicator/communicator.h b/src/communicator/communicator.h index f377a82075..6325fa65d2 100644 --- a/src/communicator/communicator.h +++ b/src/communicator/communicator.h @@ -24,6 +24,12 @@ extern lam_class_t lam_communicator_t_class; #define LAM_COMM_NAMEISSET 0x00000008 #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 */ #define LAM_COMM_INTRA_INTRA 0x00000020 #define LAM_COMM_INTRA_INTER 0x00000040 @@ -44,6 +50,8 @@ struct lam_communicator_t { /* Attributes */ lam_hash_table_t *c_keyhash; + int c_cube_dim; /**< inscribing cube dimension */ + /* 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; /** nprocs) return LAM_ERROR; + for(dim = 0, size = 1; size < nprocs; ++dim, size <<= 1); + + return dim; +} #if defined(c_plusplus) || defined(__cplusplus) diff --git a/src/communicator/lam_comm_init.c b/src/communicator/lam_comm_init.c index d35af53146..ae54919365 100644 --- a/src/communicator/lam_comm_init.c +++ b/src/communicator/lam_comm_init.c @@ -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_local_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); 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; } } + /* 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; } @@ -409,6 +415,7 @@ static void lam_comm_construct(lam_communicator_t* comm) comm->c_contextid = 0; comm->c_flags = 0; comm->c_my_rank = 0; + comm->c_cube_dim = 0; comm->c_local_group = NULL; comm->c_remote_group = NULL; comm->error_handler = NULL;