From 2df075a1ffa42428c3651759d377befc12ed85f8 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 31 Jan 2004 21:43:26 +0000 Subject: [PATCH] - Update/revise pcm base functionality - First cut of oob/registry base functionality This commit was SVN r628. --- src/mca/lam/Makefile.am | 4 +- src/mca/lam/oob/.cvsignore | 2 + src/mca/lam/oob/Makefile.am | 9 ++ src/mca/lam/oob/base/.cvsignore | 4 + src/mca/lam/oob/base/Makefile.am | 24 ++++ src/mca/lam/oob/base/base.h | 44 ++++++ src/mca/lam/oob/base/oob_base_close.c | 27 ++++ src/mca/lam/oob/base/oob_base_open.c | 48 +++++++ src/mca/lam/oob/base/oob_base_select.c | 125 ++++++++++++++++++ src/mca/lam/oob/cofs/src/oob_cofs.h | 5 +- src/mca/lam/oob/cofs/src/oob_cofs_module.c | 16 +-- src/mca/lam/oob/oob.h | 40 ++---- src/mca/lam/pcm/base/base.h | 45 +++++++ src/mca/lam/pcm/base/pcm_base_close.c | 3 - src/mca/lam/pcm/base/pcm_base_open.c | 4 - src/mca/lam/pcm/base/pcm_base_select.c | 14 +- src/mca/lam/pcm/cofs/src/pcm_cofs.h | 4 +- src/mca/lam/pcm/cofs/src/pcm_cofs_module.c | 8 +- src/mca/lam/pcm/pcm.h | 7 +- src/mca/lam/registry/.cvsignore | 2 + src/mca/lam/registry/Makefile.am | 9 ++ src/mca/lam/registry/base/.cvsignore | 4 + src/mca/lam/registry/base/Makefile.am | 24 ++++ src/mca/lam/registry/base/base.h | 43 ++++++ .../lam/registry/base/registry_base_close.c | 27 ++++ .../lam/registry/base/registry_base_open.c | 48 +++++++ .../lam/registry/base/registry_base_select.c | 125 ++++++++++++++++++ src/mca/lam/registry/base/static-modules.h | 10 ++ src/mca/lam/registry/cofs/src/registry_cofs.h | 5 +- .../registry/cofs/src/registry_cofs_module.c | 16 +-- src/mca/lam/registry/registry.h | 38 +----- 31 files changed, 681 insertions(+), 103 deletions(-) create mode 100644 src/mca/lam/oob/base/base.h create mode 100644 src/mca/lam/oob/base/oob_base_close.c create mode 100644 src/mca/lam/oob/base/oob_base_open.c create mode 100644 src/mca/lam/oob/base/oob_base_select.c create mode 100644 src/mca/lam/pcm/base/base.h create mode 100644 src/mca/lam/registry/base/base.h create mode 100644 src/mca/lam/registry/base/registry_base_close.c create mode 100644 src/mca/lam/registry/base/registry_base_open.c create mode 100644 src/mca/lam/registry/base/registry_base_select.c create mode 100644 src/mca/lam/registry/base/static-modules.h diff --git a/src/mca/lam/Makefile.am b/src/mca/lam/Makefile.am index 998c301e69..62fb64b410 100644 --- a/src/mca/lam/Makefile.am +++ b/src/mca/lam/Makefile.am @@ -17,6 +17,8 @@ noinst_LTLIBRARIES = libmca_lam_convenience.la libmca_lam_convenience_la_SOURCES = libmca_lam_convenience_la_LIBADD = \ base/libmca_lam_base.la \ - pcm/libmca_pcm.la + oob/libmca_oob.la \ + pcm/libmca_pcm.la \ + registry/libmca_registry.la # Add base, common_lam, oob, pcm, registry as required libmca_lam_convenience_la_DEPENDENCIES = $(libmca_lam_convenience_la_LIBADD) diff --git a/src/mca/lam/oob/.cvsignore b/src/mca/lam/oob/.cvsignore index 3dda72986f..812be045b3 100644 --- a/src/mca/lam/oob/.cvsignore +++ b/src/mca/lam/oob/.cvsignore @@ -1,2 +1,4 @@ Makefile.in Makefile +.libs +*.la diff --git a/src/mca/lam/oob/Makefile.am b/src/mca/lam/oob/Makefile.am index adf0eb2364..ee88be6841 100644 --- a/src/mca/lam/oob/Makefile.am +++ b/src/mca/lam/oob/Makefile.am @@ -7,10 +7,19 @@ include $(top_srcdir)/config/Makefile.options SUBDIRS = base $(MCA_oob_STATIC_SUBDIRS) DIST_SUBDIRS = base $(MCA_oob_ALL_SUBDIRS) +noinst_LTLIBRARIES = libmca_oob.la + # Source code files headers = oob.h +# Library + +libmca_oob_la_SOURCES = $(headers) +libmca_oob_la_LIBADD = \ + $(MCA_oob_STATIC_LTLIBS) \ + base/libmca_oob_base.la + # Conditionally install the header files if WANT_INSTALL_HEADERS diff --git a/src/mca/lam/oob/base/.cvsignore b/src/mca/lam/oob/base/.cvsignore index b312ec8684..820428fdcf 100644 --- a/src/mca/lam/oob/base/.cvsignore +++ b/src/mca/lam/oob/base/.cvsignore @@ -1,3 +1,7 @@ Makefile.in Makefile +.deps +.libs +*.lo +*.la static-modules.h diff --git a/src/mca/lam/oob/base/Makefile.am b/src/mca/lam/oob/base/Makefile.am index 49007265cc..33dba6d1e9 100644 --- a/src/mca/lam/oob/base/Makefile.am +++ b/src/mca/lam/oob/base/Makefile.am @@ -3,3 +3,27 @@ # include $(top_srcdir)/config/Makefile.options + +noinst_LTLIBRARIES = libmca_oob_base.la + +# Source code files + +headers = \ + base.h + +# Library + +libmca_oob_base_la_SOURCES = \ + $(headers) \ + oob_base_close.c \ + oob_base_open.c \ + oob_base_select.c + +# Conditionally install the header files + +if WANT_INSTALL_HEADERS +lamdir = $(includedir)/lam/mca/lam/oob/base +lam_HEADERS = $(headers) +else +lamdir = $(includedir) +endif diff --git a/src/mca/lam/oob/base/base.h b/src/mca/lam/oob/base/base.h new file mode 100644 index 0000000000..cd7cd7e4fb --- /dev/null +++ b/src/mca/lam/oob/base/base.h @@ -0,0 +1,44 @@ +/* -*- C -*- + * + * $HEADER$ + */ + +#ifndef MCA_OOB_BASE_H_ +#define MCA_OOB_BASE_H_ + +#include "lam_config.h" + +#include "lam/types.h" +#include "mca/mca.h" +#include "mca/lam/oob/oob.h" + +/* + * Global functions for MCA overall collective open and close + */ +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif + int mca_oob_base_open(void); + int mca_oob_base_select(bool *allow_multi_user_threads, + bool *have_hidden_threads); + int mca_oob_base_close(void); + + bool mca_oob_base_is_checkpointable(void); + + int mca_oob_base_checkpoint(void); + int mca_oob_base_continue(void); + int mca_oob_base_restart(void); +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif + + +/* + * Global struct holding the selected module's function pointers + */ +extern int mca_oob_base_output; +extern lam_list_t mca_oob_base_modules_available; +extern mca_oob_base_module_t mca_oob_base_selected_module; +extern mca_oob_t mca_oob; + +#endif diff --git a/src/mca/lam/oob/base/oob_base_close.c b/src/mca/lam/oob/base/oob_base_close.c new file mode 100644 index 0000000000..56013f11c2 --- /dev/null +++ b/src/mca/lam/oob/base/oob_base_close.c @@ -0,0 +1,27 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include + +#include "lam/constants.h" +#include "mca/mca.h" +#include "mca/lam/base/base.h" +#include "mca/lam/oob/oob.h" +#include "mca/lam/oob/base/base.h" + + +int mca_oob_base_close(void) +{ + /* 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_oob_base_output, + &mca_oob_base_modules_available, NULL); + + /* All done */ + + return LAM_SUCCESS; +} diff --git a/src/mca/lam/oob/base/oob_base_open.c b/src/mca/lam/oob/base/oob_base_open.c new file mode 100644 index 0000000000..c86c1642b6 --- /dev/null +++ b/src/mca/lam/oob/base/oob_base_open.c @@ -0,0 +1,48 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include "mca/mca.h" +#include "mca/lam/base/base.h" +#include "mca/lam/oob/oob.h" +#include "mca/lam/oob/base/base.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/oob/base/static-modules.h" + + +/* + * Global variables + */ +int mca_oob_base_output = -1; +mca_oob_t mca_oob; +lam_list_t mca_oob_base_modules_available; +mca_oob_base_module_t mca_oob_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_oob_base_open(void) +{ + /* Open up all available modules */ + + if (LAM_SUCCESS != + mca_base_modules_open("oob", 0, mca_oob_base_static_modules, + &mca_oob_base_modules_available)) { + return LAM_ERROR; + } + + /* All done */ + + return LAM_SUCCESS; +} diff --git a/src/mca/lam/oob/base/oob_base_select.c b/src/mca/lam/oob/base/oob_base_select.c new file mode 100644 index 0000000000..936f316039 --- /dev/null +++ b/src/mca/lam/oob/base/oob_base_select.c @@ -0,0 +1,125 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include + +#include "lam/runtime/runtime.h" +#include "mca/mca.h" +#include "mca/lam/base/base.h" +#include "mca/lam/oob/oob.h" +#include "mca/lam/oob/base/base.h" + + +/** + * 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. + */ +int mca_oob_base_select(bool *allow_multi_user_threads, + bool *have_hidden_threads) +{ + int priority, best_priority; + bool user_threads, hidden_threads; + bool best_user_threads, best_hidden_threads; + lam_list_item_t *item; + mca_base_module_list_item_t *mli; + mca_oob_base_module_t *module, *best_module; + mca_oob_t *actions; + extern lam_list_t mca_oob_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_oob_base_modules_available); + lam_list_get_end(&mca_oob_base_modules_available) != item; + item = lam_list_get_next(item)) { + mli = (mca_base_module_list_item_t *) item; + module = (mca_oob_base_module_t *) mli->mli_module; + + lam_output_verbose(10, mca_oob_base_output, + "select: initializing %s module %s", + module->oobm_version.mca_type_name, + module->oobm_version.mca_module_name); + if (NULL == module->oobm_init) { + lam_output_verbose(10, mca_oob_base_output, + "select: no init function; ignoring module"); + } else { + if (MCA_SUCCESS != module->oobm_init(&priority, &user_threads, + &hidden_threads)) { + lam_output_verbose(10, mca_oob_base_output, + "select: init returned failure"); + } else { + lam_output_verbose(10, mca_oob_base_output, + "select: init returned priority %d", priority); + if (priority > best_priority) { + best_priority = priority; + best_user_threads = user_threads; + best_hidden_threads = hidden_threads; + 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 OOB module available. This shouldn't happen."); + } + + /* Finalize all non-selected modules */ + + for (item = lam_list_get_first(&mca_oob_base_modules_available); + lam_list_get_end(&mca_oob_base_modules_available) != item; + item = lam_list_get_next(item)) { + mli = (mca_base_module_list_item_t *) item; + module = (mca_oob_base_module_t *) mli->mli_module; + + if (module != best_module) { + + /* Finalize */ + + if (NULL != module->oobm_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->oobm_finalize(); + lam_output_verbose(10, mca_oob_base_output, + "select: module %s finalized", + module->oobm_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_oob_base_output, &mca_oob_base_modules_available, + (mca_base_module_t *) best_module); + + /* Save the winner */ + + mca_oob_base_selected_module = *best_module; + mca_oob = *actions; + *allow_multi_user_threads = best_user_threads; + *have_hidden_threads = best_hidden_threads; + lam_output_verbose(10, mca_oob_base_output, + "select: module %s initialized", + module->oobm_version.mca_module_name); + + /* All done */ + + return LAM_SUCCESS; +} diff --git a/src/mca/lam/oob/cofs/src/oob_cofs.h b/src/mca/lam/oob/cofs/src/oob_cofs.h index c26e75b705..34b094e934 100644 --- a/src/mca/lam/oob/cofs/src/oob_cofs.h +++ b/src/mca/lam/oob/cofs/src/oob_cofs.h @@ -18,8 +18,9 @@ int mca_oob_cofs_close(void); /* * Startup / Shutdown */ -int mca_oob_cofs_query(int *priority); -struct mca_oob_1_0_0_t* mca_oob_cofs_init(void); +struct mca_oob_1_0_0_t* mca_oob_cofs_init(int *priority, + bool *allow_multi_user_threads, + bool *have_hidden_threads); int mca_oob_cofs_finalize(void); diff --git a/src/mca/lam/oob/cofs/src/oob_cofs_module.c b/src/mca/lam/oob/cofs/src/oob_cofs_module.c index 1456e8f165..f6daaa6ca8 100644 --- a/src/mca/lam/oob/cofs/src/oob_cofs_module.c +++ b/src/mca/lam/oob/cofs/src/oob_cofs_module.c @@ -34,7 +34,6 @@ mca_oob_base_module_1_0_0_t mca_oob_cofs_module = { { false /* checkpoint / restart */ }, - mca_oob_cofs_query, /* module query */ mca_oob_cofs_init, /* module init */ mca_oob_cofs_finalize }; @@ -64,20 +63,17 @@ mca_oob_cofs_close(void) } -int -mca_oob_cofs_query(int *priority) -{ - *priority = 0; - return LAM_SUCCESS; -} - - struct mca_oob_1_0_0_t* -mca_oob_cofs_init(void) +mca_oob_cofs_init(int *priority, bool *allow_multi_user_threads, + bool *have_hidden_threads) { char *tmp; FILE *fp; + *priority = 0; + *allow_multi_user_threads = true; + *have_hidden_threads = true; + /* * BWB - fix me, make register the "right" way... */ diff --git a/src/mca/lam/oob/oob.h b/src/mca/lam/oob/oob.h index 85337620e8..1c576934f7 100644 --- a/src/mca/lam/oob/oob.h +++ b/src/mca/lam/oob/oob.h @@ -34,8 +34,8 @@ #include "lam_config.h" -#include "mca/mca.h" #include "lam/types.h" +#include "mca/mca.h" /* * Global constants / types @@ -55,8 +55,9 @@ typedef void (*mca_oob_base_recv_cb_t)(lam_job_handle_t job_handle, int tag, /* * Functions every module instance will have to provide */ -typedef int (*mca_oob_base_query_fn_t)(int *priority); -typedef struct mca_oob_1_0_0_t* (*mca_oob_base_init_fn_t)(void); +typedef struct mca_oob_1_0_0_t* + (*mca_oob_base_init_fn_t)(int *priority, bool *allow_multi_user_threads, + bool *have_hidden_threads); typedef int (*mca_oob_base_send_fn_t)(lam_job_handle_t job_handle, int vpid, int tag, void* data, size_t data_len); typedef int (*mca_oob_base_recv_fn_t)(lam_job_handle_t job_handle, int vpid, int* tag, @@ -75,9 +76,8 @@ struct mca_oob_base_module_1_0_0_t { mca_base_module_t oobm_version; mca_base_module_data_1_0_0_t oobm_data; - mca_oob_base_query_fn_t oobm_query; mca_oob_base_init_fn_t oobm_init; - mca_oob_base_finalize_fn_t oob_finalize; + mca_oob_base_finalize_fn_t oobm_finalize; }; typedef struct mca_oob_base_module_1_0_0_t mca_oob_base_module_1_0_0_t; @@ -89,6 +89,9 @@ struct mca_oob_1_0_0_t { }; typedef struct mca_oob_1_0_0_t mca_oob_1_0_0_t; +typedef mca_oob_base_module_1_0_0_t mca_oob_base_module_t; +typedef mca_oob_1_0_0_t mca_oob_t; + /* * Macro for use in modules that are of type coll v1.0.0 */ @@ -99,31 +102,4 @@ typedef struct mca_oob_1_0_0_t mca_oob_1_0_0_t; "oob", 1, 0, 0 -typedef mca_oob_base_module_1_0_0_t mca_oob_base_module_t; -typedef mca_oob_1_0_0_t mca_oob_t; - - -/* - * Global functions for MCA overall collective open and close - */ -#if defined(c_plusplus) || defined(__cplusplus) -extern "C" { -#endif - int mca_oob_base_open(lam_cmd_line_t *cmd); - int mca_oob_base_close(void); - - bool mca_oob_base_is_checkpointable(void); - - int mca_oob_base_checkpoint(void); - int mca_oob_base_continue(void); - int mca_oob_base_restart(void); -#if defined(c_plusplus) || defined(__cplusplus) -} -#endif - -/* - * Global struct holding the selected module's function pointers - */ -extern mca_oob_t mca_oob; - #endif diff --git a/src/mca/lam/pcm/base/base.h b/src/mca/lam/pcm/base/base.h new file mode 100644 index 0000000000..0224b36dd5 --- /dev/null +++ b/src/mca/lam/pcm/base/base.h @@ -0,0 +1,45 @@ +/* -*- C -*- + * + * $HEADER$ + */ + +#ifndef MCA_PCM_BASE_H_ +#define MCA_PCM_BASE_H_ + +#include "lam_config.h" + +#include "lam/types.h" +#include "mca/mca.h" +#include "mca/lam/pcm/pcm.h" + + +/* + * Global functions for MCA overall collective open and close + */ +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif + int mca_pcm_base_open(void); + int mca_oob_base_select(bool *allow_multi_user_threads, + bool *have_hidden_threads); + int mca_pcm_base_close(void); + + bool mca_pcm_base_is_checkpointable(void); + + int mca_pcm_base_checkpoint(void); + int mca_pcm_base_continue(void); + int mca_pcm_base_restart(void); +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif + + +/* + * 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 /* MCA_PCM_BASE_H */ diff --git a/src/mca/lam/pcm/base/pcm_base_close.c b/src/mca/lam/pcm/base/pcm_base_close.c index 87550d3997..2aec8509f0 100644 --- a/src/mca/lam/pcm/base/pcm_base_close.c +++ b/src/mca/lam/pcm/base/pcm_base_close.c @@ -5,7 +5,6 @@ #include "lam_config.h" #include -#include #include "lam/constants.h" #include "mca/mca.h" @@ -15,8 +14,6 @@ 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) */ diff --git a/src/mca/lam/pcm/base/pcm_base_open.c b/src/mca/lam/pcm/base/pcm_base_open.c index e2a119b7e4..9da9423ca2 100644 --- a/src/mca/lam/pcm/base/pcm_base_open.c +++ b/src/mca/lam/pcm/base/pcm_base_open.c @@ -4,10 +4,6 @@ #include "lam_config.h" -#include -#include -#include - #include "mca/mca.h" #include "mca/lam/base/base.h" #include "mca/lam/pcm/pcm.h" diff --git a/src/mca/lam/pcm/base/pcm_base_select.c b/src/mca/lam/pcm/base/pcm_base_select.c index c725e4765b..6198b630c9 100644 --- a/src/mca/lam/pcm/base/pcm_base_select.c +++ b/src/mca/lam/pcm/base/pcm_base_select.c @@ -5,8 +5,6 @@ #include "lam_config.h" #include -#include -#include #include "lam/runtime/runtime.h" #include "mca/mca.h" @@ -22,9 +20,12 @@ * priorities. Select the module with the highest priority. All * other modules will be closed and unloaded. */ -int mca_pcm_base_select(void) +int mca_pcm_base_select(bool *allow_multi_user_threads, + bool *have_hidden_threads) { int priority, best_priority; + bool user_threads, hidden_threads; + bool best_user_threads, best_hidden_threads; lam_list_item_t *item; mca_base_module_list_item_t *mli; mca_pcm_base_module_t *module, *best_module; @@ -50,7 +51,8 @@ int mca_pcm_base_select(void) lam_output_verbose(10, mca_pcm_base_output, "select: no init function; ignoring module"); } else { - if (MCA_SUCCESS != module->pcmm_init(&priority)) { + if (MCA_SUCCESS != module->pcmm_init(&priority, &user_threads, + &hidden_threads)) { lam_output_verbose(10, mca_pcm_base_output, "select: init returned failure"); } else { @@ -58,6 +60,8 @@ int mca_pcm_base_select(void) "select: init returned priority %d", priority); if (priority > best_priority) { best_priority = priority; + best_user_threads = user_threads; + best_hidden_threads = hidden_threads; best_module = module; } } @@ -108,6 +112,8 @@ int mca_pcm_base_select(void) mca_pcm_base_selected_module = *best_module; mca_pcm = *actions; + *allow_multi_user_threads = best_user_threads; + *have_hidden_threads = best_hidden_threads; lam_output_verbose(10, mca_pcm_base_output, "select: module %s initialized", module->pcmm_version.mca_module_name); diff --git a/src/mca/lam/pcm/cofs/src/pcm_cofs.h b/src/mca/lam/pcm/cofs/src/pcm_cofs.h index 779ad0cd83..78cda7ebb7 100644 --- a/src/mca/lam/pcm/cofs/src/pcm_cofs.h +++ b/src/mca/lam/pcm/cofs/src/pcm_cofs.h @@ -17,7 +17,9 @@ int mca_pcm_cofs_close(void); /* * Startup / Shutdown */ -struct mca_pcm_1_0_0_t* mca_pcm_cofs_init(int *priority); +struct mca_pcm_1_0_0_t* mca_pcm_cofs_init(int *priority, + bool *allow_multi_user_threads, + bool *have_hidden_threads); int mca_pcm_cofs_finalize(void); diff --git a/src/mca/lam/pcm/cofs/src/pcm_cofs_module.c b/src/mca/lam/pcm/cofs/src/pcm_cofs_module.c index a087b2488f..0c8989a28b 100644 --- a/src/mca/lam/pcm/cofs/src/pcm_cofs_module.c +++ b/src/mca/lam/pcm/cofs/src/pcm_cofs_module.c @@ -71,6 +71,8 @@ size_t mca_pcm_cofs_nprocs = 0; int mca_pcm_cofs_open(void) { + /* JMS/BWB: Register MCA params in here -- see + src/mca/lam/base/mca_base_param.h */ return LAM_SUCCESS; } @@ -83,7 +85,8 @@ mca_pcm_cofs_close(void) struct mca_pcm_1_0_0_t* -mca_pcm_cofs_init(int *priority) +mca_pcm_cofs_init(int *priority, bool *allow_multi_user_threads, + bool *have_hidden_threads) { char *tmp; FILE *fp; @@ -91,8 +94,11 @@ mca_pcm_cofs_init(int *priority) char *test_ret; *priority = 0; + *allow_multi_user_threads = true; + *have_hidden_threads = false; /* BWB - remove printfs once things settle down some... */ + /* JMS: Look in src/mca/lam/base/mca_base_param.h */ test_ret = getenv("MCA_common_lam_cofs_my_vpid"); if (test_ret == NULL) { printf("COFS PCM will not be running because MCA_common_lam_cofs_my_vpid not set\n"); diff --git a/src/mca/lam/pcm/pcm.h b/src/mca/lam/pcm/pcm.h index adc0349133..d9109e25fd 100644 --- a/src/mca/lam/pcm/pcm.h +++ b/src/mca/lam/pcm/pcm.h @@ -87,7 +87,9 @@ typedef struct mca_pcm_proc_t mca_pcm_proc_t; * functions every module must provide */ -typedef struct mca_pcm_1_0_0_t* (*mca_pcm_base_init_fn_t)(int *priority); +typedef struct mca_pcm_1_0_0_t* + (*mca_pcm_base_init_fn_t)(int *priority, bool *allow_multi_user_threads, + bool *have_hidden_threads); /** * \func mca_pcm_query_get_nodes @@ -422,7 +424,8 @@ typedef mca_pcm_1_0_0_t mca_pcm_t; extern "C" { #endif int mca_pcm_base_open(void); - int mca_pcm_base_select(void); + int mca_pcm_base_select(bool *allow_multi_user_threads, + bool *have_hidden_threads); int mca_pcm_base_close(void); bool mca_pcm_base_is_checkpointable(void); diff --git a/src/mca/lam/registry/.cvsignore b/src/mca/lam/registry/.cvsignore index 3dda72986f..812be045b3 100644 --- a/src/mca/lam/registry/.cvsignore +++ b/src/mca/lam/registry/.cvsignore @@ -1,2 +1,4 @@ Makefile.in Makefile +.libs +*.la diff --git a/src/mca/lam/registry/Makefile.am b/src/mca/lam/registry/Makefile.am index 91c4ad7a37..0a15e01993 100644 --- a/src/mca/lam/registry/Makefile.am +++ b/src/mca/lam/registry/Makefile.am @@ -7,10 +7,19 @@ include $(top_srcdir)/config/Makefile.options SUBDIRS = base $(MCA_registry_STATIC_SUBDIRS) DIST_SUBDIRS = base $(MCA_registry_ALL_SUBDIRS) +noinst_LTLIBRARIES = libmca_registry.la + # Source code files headers = registry.h +# Library + +libmca_registry_la_SOURCES = $(headers) +libmca_registry_la_LIBADD = \ + $(MCA_registry_STATIC_LTLIBS) \ + base/libmca_registry_base.la + # Conditionally install the header files if WANT_INSTALL_HEADERS diff --git a/src/mca/lam/registry/base/.cvsignore b/src/mca/lam/registry/base/.cvsignore index b312ec8684..820428fdcf 100644 --- a/src/mca/lam/registry/base/.cvsignore +++ b/src/mca/lam/registry/base/.cvsignore @@ -1,3 +1,7 @@ Makefile.in Makefile +.deps +.libs +*.lo +*.la static-modules.h diff --git a/src/mca/lam/registry/base/Makefile.am b/src/mca/lam/registry/base/Makefile.am index 49007265cc..3ee9c253fe 100644 --- a/src/mca/lam/registry/base/Makefile.am +++ b/src/mca/lam/registry/base/Makefile.am @@ -3,3 +3,27 @@ # include $(top_srcdir)/config/Makefile.options + +noinst_LTLIBRARIES = libmca_registry_base.la + +# Source code files + +headers = \ + base.h + +# Library + +libmca_registry_base_la_SOURCES = \ + $(headers) \ + registry_base_close.c \ + registry_base_open.c \ + registry_base_select.c + +# Conditionally install the header files + +if WANT_INSTALL_HEADERS +lamdir = $(includedir)/lam/mca/lam/registry/base +lam_HEADERS = $(headers) +else +lamdir = $(includedir) +endif diff --git a/src/mca/lam/registry/base/base.h b/src/mca/lam/registry/base/base.h new file mode 100644 index 0000000000..17026c1cd9 --- /dev/null +++ b/src/mca/lam/registry/base/base.h @@ -0,0 +1,43 @@ +/* -*- C -*- + * + * $HEADER$ + */ + +#ifndef MCA_REGISTRY_BASE_H_ +#define MCA_REGISTRY_BASE_H_ + +#include "lam_config.h" + +#include "mca/mca.h" +#include "mca/lam/registry/registry.h" + +/* + * Global functions for MCA overall collective open and close + */ +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif + int mca_registry_base_open(void); + int mca_registry_base_select(bool *allow_multi_user_threads, + bool *have_hidden_threads); + int mca_registry_base_close(void); + + bool mca_registry_base_is_checkpointable(void); + + int mca_registry_base_checkpoint(void); + int mca_registry_base_continue(void); + int mca_registry_base_restart(void); +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif + + +/* + * Global struct holding the selected module's function pointers + */ +extern int mca_registry_base_output; +extern lam_list_t mca_registry_base_modules_available; +extern mca_registry_base_module_t mca_registry_base_selected_module; +extern mca_registry_t mca_registry; + +#endif diff --git a/src/mca/lam/registry/base/registry_base_close.c b/src/mca/lam/registry/base/registry_base_close.c new file mode 100644 index 0000000000..2b9193c291 --- /dev/null +++ b/src/mca/lam/registry/base/registry_base_close.c @@ -0,0 +1,27 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include + +#include "lam/constants.h" +#include "mca/mca.h" +#include "mca/lam/base/base.h" +#include "mca/lam/registry/registry.h" +#include "mca/lam/registry/base/base.h" + + +int mca_registry_base_close(void) +{ + /* 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_registry_base_output, + &mca_registry_base_modules_available, NULL); + + /* All done */ + + return LAM_SUCCESS; +} diff --git a/src/mca/lam/registry/base/registry_base_open.c b/src/mca/lam/registry/base/registry_base_open.c new file mode 100644 index 0000000000..4acdc2fa01 --- /dev/null +++ b/src/mca/lam/registry/base/registry_base_open.c @@ -0,0 +1,48 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include "mca/mca.h" +#include "mca/lam/base/base.h" +#include "mca/lam/registry/registry.h" +#include "mca/lam/registry/base/base.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/registry/base/static-modules.h" + + +/* + * Global variables + */ +int mca_registry_base_output = -1; +mca_registry_t mca_registry; +lam_list_t mca_registry_base_modules_available; +mca_registry_base_module_t mca_registry_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_registry_base_open(void) +{ + /* Open up all available modules */ + + if (LAM_SUCCESS != + mca_base_modules_open("registry", 0, mca_registry_base_static_modules, + &mca_registry_base_modules_available)) { + return LAM_ERROR; + } + + /* All done */ + + return LAM_SUCCESS; +} diff --git a/src/mca/lam/registry/base/registry_base_select.c b/src/mca/lam/registry/base/registry_base_select.c new file mode 100644 index 0000000000..dc1027c5c5 --- /dev/null +++ b/src/mca/lam/registry/base/registry_base_select.c @@ -0,0 +1,125 @@ +/* + * $HEADER$ + */ + +#include "lam_config.h" + +#include + +#include "lam/runtime/runtime.h" +#include "mca/mca.h" +#include "mca/lam/base/base.h" +#include "mca/lam/registry/registry.h" +#include "mca/lam/registry/base/base.h" + + +/** + * 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. + */ +int mca_registry_base_select(bool *allow_multi_user_threads, + bool *have_hidden_threads) +{ + int priority, best_priority; + bool user_threads, hidden_threads; + bool best_user_threads, best_hidden_threads; + lam_list_item_t *item; + mca_base_module_list_item_t *mli; + mca_registry_base_module_t *module, *best_module; + mca_registry_t *actions; + extern lam_list_t mca_registry_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_registry_base_modules_available); + lam_list_get_end(&mca_registry_base_modules_available) != item; + item = lam_list_get_next(item)) { + mli = (mca_base_module_list_item_t *) item; + module = (mca_registry_base_module_t *) mli->mli_module; + + lam_output_verbose(10, mca_registry_base_output, + "select: initializing %s module %s", + module->registrym_version.mca_type_name, + module->registrym_version.mca_module_name); + if (NULL == module->registrym_init) { + lam_output_verbose(10, mca_registry_base_output, + "select: no init function; ignoring module"); + } else { + if (MCA_SUCCESS != module->registrym_init(&priority, &user_threads, + &hidden_threads)) { + lam_output_verbose(10, mca_registry_base_output, + "select: init returned failure"); + } else { + lam_output_verbose(10, mca_registry_base_output, + "select: init returned priority %d", priority); + if (priority > best_priority) { + best_priority = priority; + best_user_threads = user_threads; + best_hidden_threads = hidden_threads; + 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 REGISTRY module available. This shouldn't happen."); + } + + /* Finalize all non-selected modules */ + + for (item = lam_list_get_first(&mca_registry_base_modules_available); + lam_list_get_end(&mca_registry_base_modules_available) != item; + item = lam_list_get_next(item)) { + mli = (mca_base_module_list_item_t *) item; + module = (mca_registry_base_module_t *) mli->mli_module; + + if (module != best_module) { + + /* Finalize */ + + if (NULL != module->registrym_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->registrym_finalize(); + lam_output_verbose(10, mca_registry_base_output, + "select: module %s finalized", + module->registrym_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_registry_base_output, &mca_registry_base_modules_available, + (mca_base_module_t *) best_module); + + /* Save the winner */ + + mca_registry_base_selected_module = *best_module; + mca_registry = *actions; + *allow_multi_user_threads = best_user_threads; + *have_hidden_threads = best_hidden_threads; + lam_output_verbose(10, mca_registry_base_output, + "select: module %s initialized", + module->registrym_version.mca_module_name); + + /* All done */ + + return LAM_SUCCESS; +} diff --git a/src/mca/lam/registry/base/static-modules.h b/src/mca/lam/registry/base/static-modules.h new file mode 100644 index 0000000000..e2a63193fc --- /dev/null +++ b/src/mca/lam/registry/base/static-modules.h @@ -0,0 +1,10 @@ +/* + * $HEADER$ + */ + +extern const mca_base_module_t mca_registry_cofs_module; + +const mca_base_module_t *mca_registry_base_static_modules[] = { + &mca_registry_cofs_module, + NULL +}; diff --git a/src/mca/lam/registry/cofs/src/registry_cofs.h b/src/mca/lam/registry/cofs/src/registry_cofs.h index 44996cc369..578efb62b6 100644 --- a/src/mca/lam/registry/cofs/src/registry_cofs.h +++ b/src/mca/lam/registry/cofs/src/registry_cofs.h @@ -18,8 +18,9 @@ int mca_registry_cofs_close(void); /* * Startup / Shutdown */ -int mca_registry_cofs_query(int *priority); -struct mca_registry_1_0_0_t* mca_registry_cofs_init(void); +struct mca_registry_1_0_0_t* + mca_registry_cofs_init(int *priority, bool *allow_multi_user_threads, + bool *have_hidden_user_threads); int mca_registry_cofs_finalize(void); diff --git a/src/mca/lam/registry/cofs/src/registry_cofs_module.c b/src/mca/lam/registry/cofs/src/registry_cofs_module.c index 7a103af8cc..a490ff4fc1 100644 --- a/src/mca/lam/registry/cofs/src/registry_cofs_module.c +++ b/src/mca/lam/registry/cofs/src/registry_cofs_module.c @@ -34,7 +34,6 @@ mca_registry_base_module_1_0_0_t mca_registry_cofs_module = { { false /* checkpoint / restart */ }, - mca_registry_cofs_query, /* module query */ mca_registry_cofs_init, /* module init */ mca_registry_cofs_finalize }; @@ -62,20 +61,17 @@ mca_registry_cofs_close(void) } -int -mca_registry_cofs_query(int *priority) -{ - *priority = 0; - return LAM_SUCCESS; -} - - struct mca_registry_1_0_0_t* -mca_registry_cofs_init(void) +mca_registry_cofs_init(int *priority, bool *allow_multi_user_threads, + bool *have_hidden_user_threads) { char *tmp; FILE *fp; + *priority = 0; + *allow_multi_user_threads = true; + *have_hidden_user_threads = false; + /* * BWB - fix me, make register the "right" way... */ diff --git a/src/mca/lam/registry/registry.h b/src/mca/lam/registry/registry.h index f4fadf97d9..89724097c6 100644 --- a/src/mca/lam/registry/registry.h +++ b/src/mca/lam/registry/registry.h @@ -35,8 +35,9 @@ /* * Functions every module instance will have to provide */ -typedef int (*mca_registry_base_query_fn_t)(int *priority); -typedef struct mca_registry_1_0_0_t* (*mca_registry_base_init_fn_t)(void); +typedef struct mca_registry_1_0_0_t* + (*mca_registry_base_init_fn_t)(int *priority, bool *allow_multi_user_threads, + bool *have_hidden_threads); /** * Publish a key=value piece of information @@ -95,7 +96,6 @@ struct mca_registry_base_module_1_0_0_t { mca_base_module_t registrym_version; mca_base_module_data_1_0_0_t registrym_data; - mca_registry_base_query_fn_t registrym_query; mca_registry_base_init_fn_t registrym_init; mca_registry_base_finalize_fn_t registrym_finalize; }; @@ -108,6 +108,10 @@ struct mca_registry_1_0_0_t { }; typedef struct mca_registry_1_0_0_t mca_registry_1_0_0_t; +typedef mca_registry_base_module_1_0_0_t mca_registry_base_module_t; +typedef mca_registry_1_0_0_t mca_registry_t; + + /* * Macro for use in modules that are of type registry v1.0.0 */ @@ -117,32 +121,4 @@ typedef struct mca_registry_1_0_0_t mca_registry_1_0_0_t; /* registry v1.0 */ \ "registry", 1, 0, 0 -typedef mca_registry_base_module_1_0_0_t mca_registry_base_module_t; -typedef mca_registry_1_0_0_t mca_registry_t; - - -/* - * Global functions for MCA overall collective open and close - */ -#if defined(c_plusplus) || defined(__cplusplus) -extern "C" { -#endif - int mca_registry_base_open(lam_cmd_line_t *cmd); - int mca_registry_base_close(void); - - bool mca_registry_base_is_checkpointable(void); - - int mca_registry_base_checkpoint(void); - int mca_registry_base_continue(void); - int mca_registry_base_restart(void); -#if defined(c_plusplus) || defined(__cplusplus) -} -#endif - - -/* - * Global struct holding the selected module's function pointers - */ -extern mca_registry_t mca_registry; - #endif