making changes to topo_base_select and topo.h so that they are more in conformance with the MCA framework
This commit was SVN r833.
Этот коммит содержится в:
родитель
b9536f1d5d
Коммит
539e7d182c
@ -22,19 +22,27 @@
|
||||
struct opened_module_t {
|
||||
lam_list_item_t super;
|
||||
mca_topo_base_module_t *om_module;
|
||||
mca_topo_t *om_actions;
|
||||
};
|
||||
typedef struct opened_module_t opened_module_t;
|
||||
|
||||
/*
|
||||
* Only one topo module can be attached to each communicator.
|
||||
*
|
||||
* This function calls the init function on all the modules which
|
||||
* were opened by mca_base_modules_open. init function for each
|
||||
* module returns the priority for each module and hence this
|
||||
* function is able to select on particular module from a plethora
|
||||
* of modules available to implement topology. The selected module
|
||||
* will have all its function pointers saved and returned to the
|
||||
* caller
|
||||
* This module calls the query funtion on all the modules
|
||||
* that were detected by topo_base_open. This function is
|
||||
* called on a per-communicator basis. This function has the
|
||||
* following function.
|
||||
*
|
||||
* 1. Iterate over the list of available_modules
|
||||
* 2. Call the query function on each of these modules.
|
||||
* 3. query function returns the structure containing pointers
|
||||
* to its functions and the priority of this module.
|
||||
* 4. Select the module with the highest priority
|
||||
* 5. Call the init function on its actions so that it does the
|
||||
* right setup for the communicator
|
||||
* 6. Call finalize on all the other modules which returned
|
||||
* their actions but were unfortunate to not get selected
|
||||
*/
|
||||
|
||||
int mca_topo_base_select (mca_topo_t *selected,
|
||||
@ -57,6 +65,8 @@ int mca_topo_base_select (mca_topo_t *selected,
|
||||
*/
|
||||
best_module = NULL;
|
||||
best_priority = -1;
|
||||
OBJ_CONSTRUCT(&opened, lam_list_t);
|
||||
|
||||
for (item = lam_list_get_first(&mca_topo_base_modules_available);
|
||||
item != lam_list_get_end(&mca_topo_base_modules_available);
|
||||
item = lam_list_get_next(item)) {
|
||||
@ -71,27 +81,33 @@ int mca_topo_base_select (mca_topo_t *selected,
|
||||
module->topom_version.mca_type_name,
|
||||
module->topom_version.mca_module_name);
|
||||
|
||||
if (NULL == module->topom_int) {
|
||||
/*
|
||||
* there is no initialisation function in this module
|
||||
*/
|
||||
/*
|
||||
* we can call the query function only if there is a function :-)
|
||||
*/
|
||||
if (NULL == module->topom_query) {
|
||||
lam_output_verbose(10, mca_topo_base_output,
|
||||
"select: no init, ignoring the module");
|
||||
"select: no query, ignoring the module");
|
||||
} else {
|
||||
actions = module->topom_init (&priority,
|
||||
&user_threads,
|
||||
&hidden_threads);
|
||||
/*
|
||||
* call the query function and see what it returns
|
||||
*/
|
||||
actions = module->topom_query (&priority,
|
||||
&user_threads,
|
||||
&hidden_threads);
|
||||
if (NULL == actions) {
|
||||
/*
|
||||
* query did not return any action which can be used
|
||||
*/
|
||||
lam_output_verbose(10, mca_topo_base_module,
|
||||
"select: init returned failure");
|
||||
"select: query returned failure");
|
||||
} else {
|
||||
lam_output_verbose(10, mca_topo_base_module,
|
||||
"select: init returned priority &d",
|
||||
"select: query returned priority &d",
|
||||
priority);
|
||||
/*
|
||||
* is this the best module we have found till now
|
||||
*/
|
||||
if (priority > best_priority) {
|
||||
/*
|
||||
* this module is the best we have found till now
|
||||
*/
|
||||
best_priority = priority;
|
||||
best_user_threads = user_threads;
|
||||
best_hidden_threads = hidden_threads;
|
||||
@ -99,14 +115,15 @@ int mca_topo_base_select (mca_topo_t *selected,
|
||||
}
|
||||
|
||||
om = (opened_module_t *) malloc(sizeof(opened_module_t));
|
||||
/*
|
||||
* check if we have run out of space
|
||||
*/
|
||||
if (NULL == om) {
|
||||
/*
|
||||
* out of space I guess
|
||||
*/
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
OBJ_CONSTRUCT(om, lam_list_item_t);
|
||||
om->om_module = module;
|
||||
om->om_actions = actions;
|
||||
lam_list_append(&opened, (lam_list_item_t *)om);
|
||||
} /* end else of if (NULL == actions) */
|
||||
} /* end else of if (NULL == module->topom_init) */
|
||||
@ -123,19 +140,47 @@ int mca_topo_base_select (mca_topo_t *selected,
|
||||
/*
|
||||
* This typically means that there was no module which was able
|
||||
* to run properly this time. So, we need to abort
|
||||
*
|
||||
* JMS replace with show_help
|
||||
*/
|
||||
lam_abort(1, "No topo module avaliable. This should not happen");
|
||||
}
|
||||
|
||||
/*
|
||||
* We now have a list of modules which have successfully returned
|
||||
* their priorities from the query. We now have to finalize() those
|
||||
* modules which have not been selected and init() the module which
|
||||
* was selected
|
||||
*/
|
||||
for (item = lam_list_remove_first(&opened);
|
||||
NULL != item;
|
||||
item = lam_list_remove_first(&opened)) {
|
||||
om = (opened_module_t *) item;
|
||||
if (om->om_module != best_module) {
|
||||
if (om->om_module == best_module) {
|
||||
/*
|
||||
* this is the chosen module, we have to initialise
|
||||
* the actions of this module. Also, save the actions
|
||||
* in selected since we are going to deallocate om
|
||||
* at the end of the loop. For now I am ignoring the init
|
||||
* function call of the module since I dont know what
|
||||
* it is supposed to do as of now. Someday this will have
|
||||
* arguments.
|
||||
*
|
||||
* ANJU: a module might not have all the functions defined.
|
||||
* Whereever a function pointer is null in the actions
|
||||
* structure we need to fill it in with the base structure
|
||||
* function pointers. This is yet to be done
|
||||
*/
|
||||
if (NULL != om->om_actions->init) {
|
||||
(void)om->om_actions->init();
|
||||
}
|
||||
mca_topo_base_selected_module = *best_module;
|
||||
mca_topo = *(om->om_actions);
|
||||
*selected = *(om->om_actions);
|
||||
*allow_multi_user_threads = best_user_threads;
|
||||
*have_hidden_threads = best_hidden_threads;
|
||||
} else {
|
||||
/*
|
||||
* this is not the "choosen one", discard this
|
||||
* this is not the "choosen one", finalize
|
||||
*/
|
||||
if (NULL != om->om_module->topom_finalize) {
|
||||
/* finalise the module only if they have some
|
||||
@ -152,27 +197,12 @@ int mca_topo_base_select (mca_topo_t *selected,
|
||||
free(om);
|
||||
} /* traversing through the entire list */
|
||||
|
||||
/*
|
||||
* Now we have to unload all the modules which were not selected
|
||||
* through mca_base_modules_close. After this function call, the
|
||||
* mca_topo_base_available_modules will contain only the selected
|
||||
* module
|
||||
*/
|
||||
mca_base_modules_close(mca_topo_base_output,
|
||||
&mca_topo_base_modules_available,
|
||||
(mca_base_module_t *) best_module);
|
||||
|
||||
/*
|
||||
* save the selected module
|
||||
*/
|
||||
mca_topo_base_selected_module = *best_module;
|
||||
mca_topo = *actions;
|
||||
*selected = *actions;
|
||||
*allow_multi_user_threads = best_user_threads;
|
||||
*have_hidden_threads = best_hidden_threads;
|
||||
lam_output_verbose(10, mca_topo_base_output,
|
||||
"select: module %s selected",
|
||||
module->topom_version.mca_module_name);
|
||||
lam_output_verbose(10, mca_topo_base_output,
|
||||
"select: module %s selected",
|
||||
module->topom_version.mca_module_name);
|
||||
|
||||
/*
|
||||
* I think we are done :-)
|
||||
|
@ -10,68 +10,181 @@
|
||||
#include "mpi.h"
|
||||
#include "mca/mca.h"
|
||||
#include "mca/mpi/base/base.h"
|
||||
/*
|
||||
* Topo module function prototypes
|
||||
*/
|
||||
typedef int (*mca_topo_base_init_query_fn_t)(int *thread_min,
|
||||
int *thread_max);
|
||||
|
||||
/*
|
||||
* ******************************************************************
|
||||
* ********** Use in modules that are of type topo v1.0.0 ***********
|
||||
* ******************************************************************
|
||||
*/
|
||||
#define MCA_TOPO_BASE_VERSION_1_0_0 \
|
||||
/* topo v1.0 is chained to MCA v1.0 */ \
|
||||
MCA_BASE_VERSION_1_0_0, \
|
||||
/* topo v1.0 */ \
|
||||
"topo", 1, 0, 0
|
||||
/*
|
||||
* ******************************************************************
|
||||
* **************************** Macro ends **************************
|
||||
* ******************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* These are the module function prototypes. These function pointers
|
||||
* go into the module structure. These functions (query() and finalize()
|
||||
* are called during topo_base_select(). Each module is query() ied
|
||||
* and subsequently, all the unselected modules are finalize() 'ed
|
||||
* so that any *stuff* they did during query() can be undone. By
|
||||
* similar logic, finalize() is also called on the module which
|
||||
* was selected when the communicator is being destroyed.
|
||||
*
|
||||
* So, to sum it up, every module carries 4 functions:
|
||||
* 1. open() - called during MPI_INIT
|
||||
* 2. close() - called during MPI_FINALIZE
|
||||
* 3. query() - called to select a particular module
|
||||
* 4. finalize() - called when actions taken during query have
|
||||
* to be undone
|
||||
*/
|
||||
|
||||
/*
|
||||
* **************** module struct *******************************
|
||||
* *********** These functions go in the module struct **********
|
||||
* **************** module struct *******************************
|
||||
*/
|
||||
typedef const struct mca_topo_1_0_0_t *
|
||||
(*mca_topo_base_comm_query_1_0_0_fn_t)(lam_comm_t *comm, int *priority);
|
||||
(*mca_topo_base_comm_query_1_0_0_fn_t)(int *priority,
|
||||
bool *allow_multi_user_threads,
|
||||
bool *have_hidden_threads);
|
||||
|
||||
typedef int (*mca_topo_base_comm_finalize_1_0_0_fn_t) (void);
|
||||
/*
|
||||
* asfhsfs
|
||||
*/
|
||||
typedef int (*mca_topo_base_init_1_0_0_fn_t)
|
||||
(lam_comm_t *comm, const struct mca_topo_1_0_0_t **new_topo);
|
||||
* ****************** module struct ******************************
|
||||
* Structure for topo v1.0.0 modules.This is chained to MCA v1.0.0
|
||||
* ****************** module struct ******************************
|
||||
*/
|
||||
struct mca_topo_base_module_1_0_0_t {
|
||||
mca_base_module_t topom_version;
|
||||
mca_base_module_data_1_0_0_t topom_data;
|
||||
mca_topo_base_comm_query_1_0_0_fn_t topom_query;
|
||||
mca_topo_base_comm_finalize_1_0_0_fn_t topom_finalize;
|
||||
};
|
||||
typedef struct mca_topo_base_module_1_0_0_t mca_topo_base_module_1_0_0_t;
|
||||
typedef mca_topo_base_module_1_0_0_t mca_topo_base_module_t;
|
||||
|
||||
/*
|
||||
* Topo module function typedefs
|
||||
* ******************************************************************
|
||||
* *********************** module struct ends here ******************
|
||||
* ******************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* ************************ Interface function definitions **************
|
||||
* These are the typedefs for the function pointers to various topology
|
||||
* backend functions which will be used by the various topology modules
|
||||
* ***********************************************************************
|
||||
*/
|
||||
|
||||
typedef int (*mca_topo_base_init_1_0_0_fn_t)(void);
|
||||
|
||||
typedef int (*mca_topo_base_cart_coords_fn_t)
|
||||
(lam_communicator_t* comm, int rank, int maxdims, int *coords);
|
||||
(lam_communicator_t* comm,
|
||||
int rank,
|
||||
int maxdims,
|
||||
int *coords);
|
||||
|
||||
typedef int (*mca_topo_base_cart_create_fn_t)(lam_communicator_t* old_comm, int ndims,
|
||||
int *dims, int *periods, int redorder, lam_communicator_t** comm_cart);
|
||||
typedef int (*mca_topo_base_cart_create_fn_t)
|
||||
(lam_communicator_t* old_comm,
|
||||
int ndims,
|
||||
int *dims,
|
||||
int *periods,
|
||||
int redorder,
|
||||
lam_communicator_t** comm_cart);
|
||||
|
||||
typedef int (*mca_topo_base_cart_get_fn_t)(lam_communicator_t* comm, int maxdims, int *dims,
|
||||
int *periods, int *coords);
|
||||
typedef int (*mca_topo_base_cart_get_fn_t)
|
||||
(lam_communicator_t* comm,
|
||||
int maxdims,
|
||||
int *dims,
|
||||
int *periods,
|
||||
int *coords);
|
||||
|
||||
typedef int (*mca_topo_base_cartdim_get_fn_t)(lam_communicator_t *comm,
|
||||
int *ndims);
|
||||
typedef int (*mca_topo_base_cartdim_get_fn_t)
|
||||
(lam_communicator_t *comm,
|
||||
int *ndims);
|
||||
|
||||
typedef int (*mca_topo_base_cart_map_fn_t)(lam_communicator_t* comm, int ndims, int *dims,
|
||||
int *periods, int *newrank);
|
||||
typedef int (*mca_topo_base_cart_map_fn_t)
|
||||
(lam_communicator_t* comm,
|
||||
int ndims,
|
||||
int *dims,
|
||||
int *periods,
|
||||
int *newrank);
|
||||
|
||||
typedef int (*mca_topo_base_cart_rank_fn_t)(lam_communicator_t* comm, int *coords, int *rank);
|
||||
typedef int (*mca_topo_base_cart_rank_fn_t)
|
||||
(lam_communicator_t* comm,
|
||||
int *coords,
|
||||
int *rank);
|
||||
|
||||
typedef int (*mca_topo_base_cart_shift_fn_t)(lam_communicator_t* comm, int direction, int disp,
|
||||
int *rank_source, int *rank_dest);
|
||||
typedef int (*mca_topo_base_cart_shift_fn_t)
|
||||
(lam_communicator_t* comm,
|
||||
int direction,
|
||||
int disp,
|
||||
int *rank_source,
|
||||
int *rank_dest);
|
||||
|
||||
typedef int (*mca_topo_base_cart_sub_fn_t)
|
||||
(lam_communicator_t* comm, int *remain_dims, lam_communicator_t** new_comm);
|
||||
(lam_communicator_t* comm,
|
||||
int *remain_dims,
|
||||
lam_communicator_t** new_comm);
|
||||
|
||||
typedef int (*mca_topo_base_graph_create_fn_t)(lam_communicator_t* comm_old, int nnodes,
|
||||
int *index, int *edges, int reorder, lam_communicator_t** comm_graph);
|
||||
typedef int (*mca_topo_base_graph_create_fn_t)
|
||||
(lam_communicator_t* comm_old,
|
||||
int nnodes,
|
||||
int *index,
|
||||
int *edges,
|
||||
int reorder,
|
||||
lam_communicator_t** comm_graph);
|
||||
|
||||
typedef int (*mca_topo_base_graph_get_fn_t)(lam_communicator_t* comm, int maxindex,
|
||||
int maxedges, int *index, int *edges);
|
||||
typedef int (*mca_topo_base_graph_get_fn_t)
|
||||
(lam_communicator_t* comm,
|
||||
int maxindex,
|
||||
int maxedges,
|
||||
int *index,
|
||||
int *edges);
|
||||
|
||||
typedef int (*mca_topo_base_graph_map_fn_t)(lam_communicator_t* comm, int nnodes, int *index,
|
||||
int *edges, int *newrank);
|
||||
typedef int (*mca_topo_base_graph_map_fn_t)
|
||||
(lam_communicator_t* comm,
|
||||
int nnodes,
|
||||
int *index,
|
||||
int *edges,
|
||||
int *newrank);
|
||||
|
||||
typedef int (*mca_topo_base_graph_neighbors_fn_t)(lam_communicator_t* comm, int rank,
|
||||
int maxneighbors, int *neighbors);
|
||||
typedef int (*mca_topo_base_graph_neighbors_fn_t)
|
||||
(lam_communicator_t* comm,
|
||||
int rank,
|
||||
int maxneighbors,
|
||||
int *neighbors);
|
||||
|
||||
typedef int (*mca_topo_base_graph_neighbors_count_fn_t)
|
||||
(lam_communicator_t* comm, int rank, int *nneighbors);
|
||||
(lam_communicator_t* comm,
|
||||
int rank,
|
||||
int *nneighbors);
|
||||
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* ******************** Interface function definitions end **************
|
||||
* ***********************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* ******************* module actions structure *************************
|
||||
* ***********************************************************************
|
||||
*/
|
||||
struct mca_topo_1_0_0_t {
|
||||
|
||||
/* Per-communicator initialization and finalization functions */
|
||||
|
||||
/*
|
||||
* Per-communicator initialization function. This is called only
|
||||
* on the module which is selected. The finalize corresponding to
|
||||
* this function is present on the module struct above
|
||||
*/
|
||||
mca_topo_base_init_1_0_0_fn_t topo_init;
|
||||
mca_topo_base_finalize_fn_t topo_finalize;
|
||||
|
||||
/* Graph related functions */
|
||||
mca_topo_base_cart_coords_fn_t topo_cart_coords;
|
||||
@ -90,26 +203,13 @@ struct mca_topo_1_0_0_t {
|
||||
};
|
||||
typedef struct mca_topo_1_0_0_t mca_topo_1_0_0_t;
|
||||
typedef mca_topo_1_0_0_t mca_topo_t;
|
||||
|
||||
struct mca_topo_base_module_1_0_0_t {
|
||||
mca_base_module_t topom_version;
|
||||
mca_base_module_data_1_0_0_t topom_data;
|
||||
|
||||
/* Intialization functions */
|
||||
mca_topo_base_init_query_fn_t topom_init_query;
|
||||
mca_topo_base_comm_query_1_0_0_fn_t topom_comm_query;
|
||||
};
|
||||
typedef struct mca_topo_base_module_1_0_0_t mca_topo_base_module_1_0_0_t;
|
||||
|
||||
/*
|
||||
* Macro for use in modules that are of type topo v1.0.0
|
||||
*/
|
||||
#define MCA_TOPO_BASE_VERSION_1_0_0 \
|
||||
/* topo v1.0 is chained to MCA v1.0 */ \
|
||||
MCA_BASE_VERSION_1_0_0, \
|
||||
/* topo v1.0 */ \
|
||||
"topo", 1, 0, 0
|
||||
* ***********************************************************************
|
||||
* ******************* module actions structure ends ********************
|
||||
* ***********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This function is technically part of the unity module, but since it
|
||||
* ships with LAM, and other modules may use the unity module for
|
||||
@ -119,8 +219,10 @@ typedef struct mca_topo_base_module_1_0_0_t mca_topo_base_module_1_0_0_t;
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
const mca_topo_1_0_0_t *
|
||||
mca_topo_unity_comm_query(lam_comm_t *comm, int *priority);
|
||||
const mca_topo_1_0_0_t *
|
||||
mca_topo_unity_comm_query(int *priority
|
||||
bool *allow_multi_user_threads,
|
||||
bool *have_hidden_threads);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user