diff --git a/src/mca/topo/unity/src/topo_unity.c b/src/mca/topo/unity/src/topo_unity.c index 4754cb482d..e4d5674f8d 100644 --- a/src/mca/topo/unity/src/topo_unity.c +++ b/src/mca/topo/unity/src/topo_unity.c @@ -1,17 +1,119 @@ /* * $HEADER$ + * + * These symbols are in a file by themselves to provide nice linker + * semantics. Since linkers generally pull in symbols by object fules, + * keeping these symbols as the only symbols in this file prevents + * utility programs such as "ompi_info" from having to import entire + * modules just to query their version and parameters */ +#include "ompi_config.h" + + +#include + +#include "mpi.h" +#include "communicator/communicator.h" +#include "mca/topo/topo.h" +#include "mca/topo/base/base.h" #include "mca/topo/unity/src/topo_unity.h" /* - * Init on the communicator. This function is called once the - * module has been selected for a particular communicator. As - * of now, do nothing + * ******************************************************************* + * ************************ actions structure ************************ + * ******************************************************************* */ -int mca_topo_unity_init (MPI_Comm comm, - const mca_topo_t **new_topo) { - /* - * Nothing to init on the communicator - */ +static mca_topo_t unity = { + mca_topo_unity_module_init, /* initalise after being selected */ + mca_topo_unity_module_finalize, /* close a module on a communicator */ + NULL, /* topo_cart_coords */ + NULL, /* topo_cart_create */ + NULL, /* topo_cart_get */ + NULL, /* topo_cartdim_get */ + mca_topo_unity_cart_map, + NULL, /* topo_cart_rank */ + NULL, /* topo_cart_shift */ + NULL, /* topo_cart_sub */ + NULL, /* topo_graph_create */ + NULL, /* topo_graph_get */ + mca_topo_unity_graph_map, + NULL, /* topo_graphdims_get */ + NULL, /* topo_graph_neighbors */ + NULL /* topo_graph_neighbors_count */ +}; +/* + * ******************************************************************* + * ************************* structure ends ************************** + * ******************************************************************* + */ + +int mca_topo_unity_module_init_query(bool *allow_multi_user_threads, + bool *have_hidden_threads) +{ + *allow_multi_user_threads = true; + *have_hidden_threads = false; + + /* return success */ + + return OMPI_SUCCESS; +} + +struct mca_topo_1_0_0_t * +mca_topo_unity_module_comm_query (int *priority){ + + /* this is the lowest module on the totem pole */ + *priority = 0; + + /* the check as to whether this is an inter communicator + * or and intra communicator has to be done before reaching + * here. this is my solemn opinion. Therefore I am ignoring + * the checks here */ + return &unity; +} + +int mca_topo_unity_module_comm_unquery (struct ompi_communicator_t *comm){ + + /* This function might be needed for some purposes later. for now it + * does not have anything to do since there are no steps which need + * to be undone if this module is not selected */ + + return OMPI_SUCCESS; +} + +int mca_topo_unity_module_init (struct ompi_communicator_t *comm){ + + /* This function is used to initialize the module on the communicator. We + * need to hang the data off of the communicator. For this we still use the + * same data structure which was defined in topo.h, mca_topo_comm_1_0_0_t. + * There are no additional things which we need. If some other module needs + * to hang additional data, then it has to have this structure as the first + * member and then extend. This is a must rule */ + + struct mca_topo_comm_1_0_0_t *topo_data; + + /* allocate the data */ + + comm->c_topo_comm = NULL; + topo_data = (struct mca_topo_comm_1_0_0_t *) + malloc(sizeof(struct mca_topo_comm_1_0_0_t)); + + if (NULL == topo_data) { + return OMPI_ERROR; + } + + comm->c_topo_comm = topo_data; + + return OMPI_SUCCESS; +} + + + +int mca_topo_unity_module_finalize (struct ompi_communicator_t *comm) { + + /* All we need to do for now is to remove the allocated data */ + + free (comm->c_topo_comm); + comm->c_topo = NULL; + return OMPI_SUCCESS; } diff --git a/src/mca/topo/unity/src/topo_unity.h b/src/mca/topo/unity/src/topo_unity.h index 6d72787f2b..0625351c80 100644 --- a/src/mca/topo/unity/src/topo_unity.h +++ b/src/mca/topo/unity/src/topo_unity.h @@ -38,16 +38,21 @@ extern const struct mca_topo_base_module_1_0_0_t mca_topo_unity_module; #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - int mca_topo_unity_module_open (void); + int mca_topo_unity_module_init_query (bool *allow_multi_user_threads, + bool *have_hidden_threads); - int mca_topo_unity_module_close(void); - - mca_topo_t* - mca_topo_unity_module_query (int *priority, - bool *allow_multi_user_threads, - bool *have_hidden_threads); - int mca_topo_unity_module_finalize (void); + struct mca_topo_1_0_0_t * + mca_topo_unity_module_comm_query (int *priority); + + + int mca_topo_unity_module_comm_unquery (struct ompi_communicator_t *comm); + + int mca_topo_unity_module_init (struct ompi_communicator_t *comm); + + + int mca_topo_unity_module_finalize (struct ompi_communicator_t *comm); + #if defined(__cplusplus) || defined(c_plusplus) } #endif @@ -72,9 +77,6 @@ extern const struct mca_topo_base_module_1_0_0_t mca_topo_unity_module; #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif - int mca_topo_unity_init (MPI_Comm comm, - const mca_topo_t **new_topo); - int mca_topo_unity_cart_map (MPI_Comm comm, int ndims, int *dims, diff --git a/src/mca/topo/unity/src/topo_unity_module.c b/src/mca/topo/unity/src/topo_unity_module.c index 2d9e60ed2d..302aef3382 100644 --- a/src/mca/topo/unity/src/topo_unity_module.c +++ b/src/mca/topo/unity/src/topo_unity_module.c @@ -35,79 +35,13 @@ const mca_topo_base_module_1_0_0_t mca_topo_unity_module = { MCA_topo_unity_MAJOR_VERSION, /* major version */ MCA_topo_unity_MINOR_VERSION, /* minor version */ MCA_topo_unity_RELEASE_VERSION, /* release version */ - mca_topo_unity_module_open, /* fp to open the module */ - mca_topo_unity_module_close /* fp to close the module */ + NULL, /* fp to open the module */ + NULL /* fp to close the module */ }, { false /* whether checkpoint/restart is enabled */ }, - mca_topo_unity_module_query, /* get priority and actions */ - mca_topo_unity_module_finalize /* undo actions of query */ + mca_topo_unity_module_init_query, /* get thread level */ + mca_topo_unity_module_comm_query, /* get priority and actions */ + mca_topo_unity_module_comm_unquery /* undo what was done by previous function */ }; -/* - * ******************************************************************* - * ******************** structure definition ends ******************** - * ******************************************************************* - */ - -/* - * ******************************************************************* - * ************************ actions structure ************************ - * ******************************************************************* - */ -static mca_topo_t unity = { - mca_topo_unity_init, /* initalise after being selected */ - NULL, /* topo_cart_coords */ - NULL, /* topo_cart_create */ - NULL, /* topo_cart_get */ - NULL, /* topo_cartdim_get */ - mca_topo_unity_cart_map, - NULL, /* topo_cart_rank */ - NULL, /* topo_cart_shift */ - NULL, /* topo_cart_sub */ - NULL, /* topo_graph_create */ - NULL, /* topo_graph_get */ - mca_topo_unity_graph_map, - NULL, /* topo_graphdims_get */ - NULL, /* topo_graph_neighbors */ - NULL /* topo_graph_neighbors_count */ -}; -/* - * ******************************************************************* - * ************************* structure ends ************************** - * ******************************************************************* - */ - -int mca_topo_unity_module_open (void) { - /* - * As of now do nothing - */ - return OMPI_SUCCESS; -} - -int mca_topo_unity_module_close (void) { - /* - * As of now do nothing - */ - return OMPI_SUCCESS; -} - -mca_topo_t* mca_topo_unity_module_query(int* priority, - bool *allow_multi_user_threads, - bool *have_hidden_threads) -{ - *priority = 0; - *allow_multi_user_threads = true; - *have_hidden_threads = false; - /* - * return the structure of function pointers - */ - return &unity; -} - -int mca_topo_unity_module_finalize (void) { - /* - * do nothing as of now - */ - return OMPI_SUCCESS; -}