- Remove kruft from pml.h, move some into pml/base/base.h (pml/pml.h
is strictly public-only) - Add selection routine for pml base This commit was SVN r605.
Этот коммит содержится в:
родитель
225e9ab40c
Коммит
15a0a8e537
@ -16,7 +16,8 @@ libmca_mpi_pml_base_la_SOURCES = \
|
||||
$(headers) \
|
||||
pml_base_close.c \
|
||||
pml_base_request.c \
|
||||
pml_base_open.c
|
||||
pml_base_open.c \
|
||||
pml_base_select.c
|
||||
|
||||
# Conditionally install the header files
|
||||
|
||||
|
@ -18,26 +18,20 @@
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
int mca_pml_base_open(void);
|
||||
int mca_pml_base_select(mca_pml_t *selected);
|
||||
int mca_pml_base_close(void);
|
||||
int mca_pml_base_open(lam_cmd_line_t *cmd);
|
||||
int mca_pml_base_query(void);
|
||||
int mca_pml_base_init(void);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Public variables
|
||||
*/
|
||||
|
||||
extern lam_list_t *mca_pml_base_opened;
|
||||
extern lam_list_t *mca_pml_base_available;
|
||||
|
||||
/*
|
||||
* Global instance of array of pointers to mca_base_module_t. Will
|
||||
* effectively be filled in by configure.
|
||||
* Globals
|
||||
*/
|
||||
|
||||
extern const mca_base_module_t **mca_pml_base_modules;
|
||||
extern int mca_pml_base_output;
|
||||
extern lam_list_t mca_pml_base_modules_available;
|
||||
extern mca_pml_base_module_t mca_pml_base_selected_module;
|
||||
extern mca_pml_t mca_pml;
|
||||
|
||||
#endif /* MCA_PML_BASE_H */
|
||||
|
@ -5,12 +5,12 @@
|
||||
#include "lam_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lam/constants.h"
|
||||
#include "mca/mca.h"
|
||||
#include "mca/lam/base/base.h"
|
||||
#include "mca/mpi/pml/pml.h"
|
||||
#include "mca/mpi/pml/base/base.h"
|
||||
|
||||
|
||||
int mca_pml_base_close(void)
|
||||
|
@ -5,12 +5,11 @@
|
||||
#include "lam_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mca/mca.h"
|
||||
#include "mca/lam/base/base.h"
|
||||
#include "mca/mpi/pml/pml.h"
|
||||
#include "mca/mpi/pml/base/base.h"
|
||||
|
||||
|
||||
/*
|
||||
|
136
src/mca/mpi/pml/base/pml_base_select.c
Обычный файл
136
src/mca/mpi/pml/base/pml_base_select.c
Обычный файл
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
#include "lam/lfc/list.h"
|
||||
#include "lam/runtime/runtime.h"
|
||||
#include "mca/mca.h"
|
||||
#include "mca/lam/base/base.h"
|
||||
#include "mca/mpi/pml/pml.h"
|
||||
#include "mca/mpi/pml/base/base.h"
|
||||
|
||||
|
||||
typedef struct opened_module_t {
|
||||
mca_pml_base_module_t *om_module;
|
||||
mca_pml_t *om_actions;
|
||||
} opened_module_t;
|
||||
|
||||
/**
|
||||
* Function for selecting one module from all those that are
|
||||
* available.
|
||||
*
|
||||
* Call the init function on all available modules and get their
|
||||
* priorities. Select the module with the highest priority. All
|
||||
* other modules will be closed and unloaded. The selected module
|
||||
* will have its initialization function invoked, and all of its
|
||||
* function pointers saved.
|
||||
*/
|
||||
int mca_pml_base_select(mca_pml_t *selected)
|
||||
{
|
||||
int priority, best_priority;
|
||||
int bogus1, bogus2;
|
||||
lam_list_item_t *item;
|
||||
mca_base_module_list_item_t *mli;
|
||||
mca_pml_base_module_t *module, *best_module;
|
||||
mca_pml_t *actions;
|
||||
extern lam_list_t mca_pml_base_modules_available;
|
||||
lam_list_t opened;
|
||||
opened_module_t *om;
|
||||
|
||||
/* Traverse the list of available modules; call their init
|
||||
functions. */
|
||||
|
||||
best_priority = -1;
|
||||
best_module = NULL;
|
||||
lam_list_init(&opened);
|
||||
for (item = lam_list_get_first(&mca_pml_base_modules_available);
|
||||
lam_list_get_end(&mca_pml_base_modules_available) != item;
|
||||
item = lam_list_get_next(item)) {
|
||||
mli = (mca_base_module_list_item_t *) item;
|
||||
module = (mca_pml_base_module_t *) mli->mli_module;
|
||||
|
||||
lam_output_verbose(10, mca_pml_base_output,
|
||||
"select: initializing %s module %s",
|
||||
module->pmlm_version.mca_type_name,
|
||||
module->pmlm_version.mca_module_name);
|
||||
if (NULL == module->pmlm_init) {
|
||||
lam_output_verbose(10, mca_pml_base_output,
|
||||
"select: no init function; ignoring module");
|
||||
} else {
|
||||
/* JMS Need to change this to take bools about threads */
|
||||
actions = module->pmlm_init(&priority, &bogus1, &bogus2);
|
||||
if (NULL == actions) {
|
||||
lam_output_verbose(10, mca_pml_base_output,
|
||||
"select: init returned failure");
|
||||
} else {
|
||||
lam_output_verbose(10, mca_pml_base_output,
|
||||
"select: init returned priority %d", priority);
|
||||
if (priority > best_priority) {
|
||||
best_priority = priority;
|
||||
best_module = module;
|
||||
}
|
||||
|
||||
om = LAM_MALLOC(sizeof(opened_module_t));
|
||||
if (NULL == om) {
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
lam_list_item_init((lam_list_item_t *) om);
|
||||
om->om_module = module;
|
||||
om->om_actions = actions;
|
||||
lam_list_append(&opened, (lam_list_item_t*) om);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Finished querying all modules. Check for the bozo case. */
|
||||
|
||||
if (NULL == best_module) {
|
||||
/* JMS Replace with show_help */
|
||||
lam_abort(1, "No pml module available. This shouldn't happen.");
|
||||
}
|
||||
|
||||
/* Finalize all non-selected modules */
|
||||
|
||||
for (item = lam_list_get_first(&opened);
|
||||
lam_list_get_end(&opened) != item;
|
||||
item = lam_list_get_next(item)) {
|
||||
om = (opened_module_t *) item;
|
||||
if (om->om_module != best_module) {
|
||||
|
||||
/* Finalize */
|
||||
|
||||
if (NULL != om->om_actions->pml_fini) {
|
||||
|
||||
/* Blatently ignore the return code (what would we do to
|
||||
recover, anyway? This module is going away, so errors
|
||||
don't matter anymore) */
|
||||
|
||||
om->om_actions->pml_fini();
|
||||
lam_output_verbose(10, mca_pml_base_output,
|
||||
"select: module %s not selected / finalized",
|
||||
module->pmlm_version.mca_module_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This base function closes, unloads, and removes from the
|
||||
available list all unselected modules. The available list will
|
||||
contain only the selected module. */
|
||||
|
||||
mca_base_modules_close(mca_pml_base_output, &mca_pml_base_modules_available,
|
||||
(mca_base_module_t *) best_module);
|
||||
|
||||
/* Save the winner */
|
||||
|
||||
mca_pml_base_selected_module = *best_module;
|
||||
*selected = *actions;
|
||||
lam_output_verbose(10, mca_pml_base_output,
|
||||
"select: module %s selected",
|
||||
module->pmlm_version.mca_module_name);
|
||||
|
||||
/* All done */
|
||||
|
||||
return LAM_SUCCESS;
|
||||
}
|
@ -166,27 +166,4 @@ typedef mca_pml_1_0_0_t mca_pml_t;
|
||||
/* pml v1.0 */ \
|
||||
"pml", 1, 0, 0
|
||||
|
||||
|
||||
/*
|
||||
* Global functions for MCA: overall PML open and close
|
||||
*/
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
int mca_pml_base_open(void);
|
||||
int mca_pml_base_select(void);
|
||||
int mca_pml_base_close(void);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Globals
|
||||
*/
|
||||
extern int mca_pml_base_output;
|
||||
extern lam_list_t mca_pml_base_modules_available;
|
||||
extern mca_pml_base_module_t mca_pml_base_selected_module;
|
||||
extern mca_pml_t mca_pml;
|
||||
|
||||
#endif /* MCA_PML_H */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user