1
1

First implementation of several PCM base functions

This commit was SVN r520.
Этот коммит содержится в:
Jeff Squyres 2004-01-22 00:35:41 +00:00
родитель 1117e272d9
Коммит b201977eab
4 изменённых файлов: 215 добавлений и 2 удалений

29
src/mca/lam/pcm/base/pcm_base_close.c Обычный файл
Просмотреть файл

@ -0,0 +1,29 @@
/*
* $HEADER$
*/
#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/lam/pcm/pcm.h"
int mca_pcm_base_close(void)
{
extern lam_list_t mca_pcm_base_modules_available;
/* Close all remaining available modules (may be one if this is a
LAM RTE program, or [possibly] multiple if this is laminfo) */
mca_base_modules_close(mca_pcm_base_output,
&mca_pcm_base_modules_available, NULL);
/* All done */
return LAM_SUCCESS;
}

51
src/mca/lam/pcm/base/pcm_base_open.c Обычный файл
Просмотреть файл

@ -0,0 +1,51 @@
/*
* $HEADER$
*/
#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/lam/pcm/pcm.h"
/*
* The following file was created by configure. It contains extern
* statements and the definition of an array of pointers to each
* module's public mca_base_module_t struct.
*/
#include "mca/lam/pcm/base/static-modules.h"
/*
* Global variables
*/
int mca_pcm_base_output = -1;
mca_pcm_t mca_pcm;
lam_list_t mca_pcm_base_modules_available;
mca_pcm_base_module_t mca_pcm_base_selected_module;
/**
* Function for finding and opening either all MCA modules, or the one
* that was specifically requested via a MCA parameter.
*/
int mca_pcm_base_open(void)
{
/* Open up all available modules */
if (LAM_SUCCESS !=
mca_base_modules_open("pcm", 0, mca_pcm_base_static_modules,
&mca_pcm_base_modules_available)) {
return LAM_ERROR;
}
/* All done */
return LAM_SUCCESS;
}

125
src/mca/lam/pcm/base/pcm_base_select.c Обычный файл
Просмотреть файл

@ -0,0 +1,125 @@
/*
* $HEADER$
*/
#include "lam_config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "lam/runtime/runtime.h"
#include "mca/mca.h"
#include "mca/lam/base/base.h"
#include "mca/lam/pcm/pcm.h"
/**
* Function for selecting one module from all those that are
* available.
*
* Call the query 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_pcm_base_select(void)
{
int priority, best_priority;
lam_list_item_t *item;
mca_base_module_list_item_t *mli;
mca_pcm_base_module_t *module, *best_module;
mca_pcm_t *actions;
extern lam_list_t mca_pcm_base_modules_available;
/* Traverse the list of available modules; call their init
functions. */
best_priority = -1;
best_module = NULL;
for (item = lam_list_get_first(&mca_pcm_base_modules_available);
lam_list_get_end(&mca_pcm_base_modules_available) != item;
item = lam_list_get_next(item)) {
mli = (mca_base_module_list_item_t *) item;
module = (mca_pcm_base_module_t *) mli->mli_module;
lam_output_verbose(10, mca_pcm_base_output,
"select: querying %s module %s",
module->pcmm_version.mca_type_name,
module->pcmm_version.mca_module_name);
if (NULL == module->pcmm_query) {
lam_output_verbose(10, mca_pcm_base_output,
"select: no querying function; ignoring module");
} else {
if (MCA_SUCCESS != module->pcmm_query(&priority)) {
lam_output_verbose(10, mca_pcm_base_output,
"select: query returned failure");
} else {
lam_output_verbose(10, mca_pcm_base_output,
"select: query returned priority %d", priority);
if (priority > best_priority) {
best_priority = priority;
best_module = module;
}
}
}
}
/* Finished querying all modules. Check for the bozo case. */
if (NULL == best_module) {
/* JMS Replace with show_help */
lam_abort(1, "No PCM module available. This shouldn't happen.");
}
/* Finalize all non-selected modules */
for (item = lam_list_get_first(&mca_pcm_base_modules_available);
lam_list_get_end(&mca_pcm_base_modules_available) != item;
item = lam_list_get_next(item)) {
mli = (mca_base_module_list_item_t *) item;
module = (mca_pcm_base_module_t *) mli->mli_module;
if (module != best_module) {
/* Finalize */
if (NULL != module->pcmm_finalize) {
/* Blatently ignore the return code (what would we do to
recover, anyway? This module is going away, so errors
don't matter anymore) */
module->pcmm_finalize();
lam_output_verbose(10, mca_pcm_base_output,
"select: module %s finalized",
module->pcmm_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_pcm_base_output, &mca_pcm_base_modules_available,
(mca_base_module_t *) best_module);
/* Invoke init on the selected module */
actions = best_module->pcmm_init();
if (NULL == actions) {
/* JMS replace with show_help */
lam_abort(1, "PCM module init function returned NULL. This shouldn't happen.");
}
mca_pcm_base_selected_module = *best_module;
mca_pcm = *actions;
lam_output_verbose(10, mca_pcm_base_output,
"select: module %s initialized",
module->pcmm_version.mca_module_name);
/* All done */
return LAM_SUCCESS;
}

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

@ -423,7 +423,8 @@ typedef mca_pcm_1_0_0_t mca_pcm_t;
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
int mca_pcm_base_open(lam_cmd_line_t *cmd);
int mca_pcm_base_open(void);
int mca_pcm_base_select(void);
int mca_pcm_base_close(void);
bool mca_pcm_base_is_checkpointable(void);
@ -437,8 +438,15 @@ extern "C" {
/*
* Global struct holding the selected module's function pointers
* Macros
*/
/*
* Globals
*/
extern int mca_pcm_base_output;
extern lam_list_t mca_pcm_base_modules_available;
extern mca_pcm_base_module_t mca_pcm_base_selected_module;
extern mca_pcm_t mca_pcm;
#endif