1
1

Refinement of the first cut of the ns framework.

- added in selection logic for ns
- made all types consistent in ns
- made replica component match types and base selection logic; it only
  allows itself to be selected in the seed
- copied replica component to "proxy" and altered the selection logic;
  it only allows itself to be selected when *not* in the seed.  All
  of the body functions in proxy need to be implemented; this is only
  a skeleton for now so that MPI programs have a ns component to
  select (because they're not the seed) and can therefore run
  properly.
- added mca_ns_base_open/close to ompi_rte_init/finalize

This commit was SVN r1621.
Этот коммит содержится в:
Jeff Squyres 2004-07-11 04:34:47 +00:00
родитель 3dc6e1248c
Коммит 4c14a1cd7e
10 изменённых файлов: 200 добавлений и 75 удалений

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

@ -10,6 +10,7 @@ SUBDIRS = \
common \
io \
mpool \
ns \
one \
oob \
pcm \
@ -18,4 +19,4 @@ SUBDIRS = \
topo
# JMS Temporary hack to make "make dist" function properly; directories
# mentioned here will eventually be moved into SUBDIRS
DIST_SUBDIRS = $(SUBDIRS) gpr ns
DIST_SUBDIRS = $(SUBDIRS) gpr

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

@ -19,35 +19,42 @@
/*
* Global functions for MCA overall collective open and close
*/
int mca_ns_base_open(void);
int mca_ns_base_select(bool *allow_multi_user_threads,
bool *have_hidden_threads);
int mca_ns_base_close(void);
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
int mca_ns_base_open(void);
int mca_ns_base_select(bool *allow_multi_user_threads,
bool *have_hidden_threads);
int mca_ns_base_close(void);
/*
* Base functions that are common to all implementations - can be overridden
*/
ompi_process_name_t* ns_base_create_process_name(ompi_process_id_t cell,
ompi_process_id_t job, ompi_process_id_t vpid);
ompi_process_name_t* ns_base_create_process_name(ompi_process_id_t cell,
ompi_process_id_t job,
ompi_process_id_t vpid);
char* ns_base_get_proc_name_string(const ompi_process_name_t* name);
char* ns_base_get_proc_name_string(const ompi_process_name_t* name);
char* ns_base_get_vpid_string(const ompi_process_name_t* name);
char* ns_base_get_vpid_string(const ompi_process_name_t* name);
char* ns_base_get_jobid_string(const ompi_process_name_t* name);
char* ns_base_get_jobid_string(const ompi_process_name_t* name);
char* ns_base_get_cellid_string(const ompi_process_name_t* name);
char* ns_base_get_cellid_string(const ompi_process_name_t* name);
ompi_process_id_t ns_base_get_vpid(const ompi_process_name_t* name);
ompi_process_id_t ns_base_get_vpid(const ompi_process_name_t* name);
ompi_process_id_t ns_base_get_jobid(const ompi_process_name_t* name);
ompi_process_id_t ns_base_get_jobid(const ompi_process_name_t* name);
ompi_process_id_t ns_base_get_cellid(const ompi_process_name_t* name);
ompi_process_id_t ns_base_get_cellid(const ompi_process_name_t* name);
int ns_base_compare(ompi_ns_cmp_bitmask_t fields,
const ompi_process_name_t* name1,
const ompi_process_name_t* name2);
int ns_base_compare(ompi_ns_cmp_bitmask_t fields,
const ompi_process_name_t* name1,
const ompi_process_name_t* name2);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
/*
@ -56,8 +63,9 @@ int ns_base_compare(ompi_ns_cmp_bitmask_t fields,
extern int mca_ns_base_output;
extern mca_ns_t ompi_name_server; /* holds selected module's function pointers */
extern ompi_list_t mca_ns_base_modules_available;
extern mca_ns_base_module_t mca_ns_base_selected_module;
extern bool mca_ns_base_selected;
extern ompi_list_t mca_ns_base_components_available;
extern mca_ns_base_component_t mca_ns_base_selected_component;
/*
* external API functions will be documented in the mca/ns/ns.h file

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

@ -14,11 +14,17 @@
int mca_ns_base_close(void)
{
/* Close all remaining available modules (may be one if this is a
/* If we have a selected component and module, then finalize it */
if (mca_ns_base_selected) {
mca_ns_base_selected_component.ns_finalize();
}
/* Close all remaining available components (may be one if this is a
OMPI RTE program, or [possibly] multiple if this is ompi_info) */
mca_base_modules_close(mca_ns_base_output,
&mca_ns_base_modules_available, NULL);
&mca_ns_base_components_available, NULL);
/* All done */

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

@ -12,7 +12,7 @@
/*
* 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.
* component's public mca_base_module_t struct.
*/
#include "mca/ns/base/static-modules.h"
@ -46,22 +46,23 @@ OBJ_CLASS_INSTANCE(
*/
int mca_ns_base_output = -1;
mca_ns_t ompi_name_server;
ompi_list_t mca_ns_base_modules_available;
mca_ns_base_module_t mca_ns_base_selected_module;
bool mca_ns_base_selected = false;
ompi_list_t mca_ns_base_components_available;
mca_ns_base_component_t mca_ns_base_selected_component;
/**
* Function for finding and opening either all MCA modules, or the one
* Function for finding and opening either all MCA components, or the one
* that was specifically requested via a MCA parameter.
*/
int mca_ns_base_open(void)
{
/* Open up all available modules */
/* Open up all available components */
if (OMPI_SUCCESS !=
mca_base_modules_open("ns", 0, mca_ns_base_static_modules,
&mca_ns_base_modules_available)) {
&mca_ns_base_components_available)) {
return OMPI_ERROR;
}

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

@ -15,29 +15,83 @@
#include "util/proc_info.h"
#include "mca/mca.h"
#include "mca/base/base.h"
#include "mca/ns/ns.h"
#include "mca/ns/base/base.h"
#include "mca/ns/replica/src/ns_replica.h"
/**
* Function for selecting one module from all those that are
* Function for selecting one component from all those that are
* available.
*
* Decide whether or not to be a replica, then call appropriate
* component to init module.
*/
int mca_ns_base_select(bool *allow_multi_user_threads,
bool *have_hidden_threads)
bool *have_hidden_threads)
{
/*
* check to see if I'm supposed to be a replica
* definitely 'yes' if I'm the seed daemon
*
*/
ompi_list_item_t *item;
mca_base_module_list_item_t *mli;
mca_ns_base_component_t *component, *best_component = NULL;
mca_ns_t *module, *best_module = NULL;
bool multi, hidden;
int priority, best_priority = -1;
if (ompi_process_info.seed) { /* true if I'm the seed daemon */
ompi_name_server = *mca_ns_replica_init(allow_multi_user_threads, have_hidden_threads);
/* Iterate through all the available components */
for (item = ompi_list_get_first(&mca_ns_base_components_available);
item != ompi_list_get_end(&mca_ns_base_components_available);
item = ompi_list_get_next(item)) {
mli = (mca_base_module_list_item_t *) item;
component = (mca_ns_base_component_t *) mli->mli_module;
/* Call the component's init function and see if it wants to be
selected */
module = component->ns_init(&multi, &hidden, &priority);
/* If we got a non-NULL module back, then the component wants to
be selected. So save its multi/hidden values and save the
module with the highest priority */
if (NULL != module) {
/* If this is the best one, save it */
if (priority > best_priority) {
/* If there was a previous best one, finalize */
if (NULL != best_component) {
best_component->ns_finalize();
}
/* Save the new best one */
best_module = module;
best_component = component;
*allow_multi_user_threads = multi;
*have_hidden_threads = hidden;
}
/* If it's not the best one, finalize it */
else {
component->ns_finalize();
}
}
}
return OMPI_SUCCESS;
/* If we didn't find one to select, barf */
if (NULL == best_component) {
return OMPI_ERROR;
}
/* We have happiness -- save the component and module for later
usage */
ompi_name_server = *best_module;
mca_ns_base_selected_component = *best_component;
mca_ns_base_selected = true;
/* all done */
return OMPI_SUCCESS;
}

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

@ -5,10 +5,10 @@
*
* The Open MPI Name Server
*
* The Open MPI Name Server provides unique name ranges for processes within the
* universe. Each universe will have one name server running within the seed daemon.
* This is done to prevent the inadvertent duplication of names.
*
* The Open MPI Name Server provides unique name ranges for processes
* within the universe. Each universe will have one name server
* running within the seed daemon. This is done to prevent the
* inadvertent duplication of names.
*/
#ifndef MCA_NS_H
@ -372,27 +372,28 @@ typedef mca_ns_1_0_0_t mca_ns_t;
typedef mca_ns_t* (*mca_ns_base_init_fn_t)(
bool *allow_multi_user_threads,
bool *have_hidden_threads);
bool *have_hidden_threads,
int *priority);
typedef int (*mca_ns_base_finalize_fn_t)(void);
/*
* the standard component data structure
*/
struct mca_ns_base_module_1_0_0_t {
struct mca_ns_base_component_1_0_0_t {
mca_base_module_t ns_version;
mca_base_module_data_1_0_0_t ns_data;
mca_ns_base_init_fn_t ns_init;
mca_ns_base_finalize_fn_t ns_finalize;
};
typedef struct mca_ns_base_module_1_0_0_t mca_ns_base_module_1_0_0_t;
typedef mca_ns_base_module_1_0_0_t mca_ns_base_module_t;
typedef struct mca_ns_base_component_1_0_0_t mca_ns_base_component_1_0_0_t;
typedef mca_ns_base_component_1_0_0_t mca_ns_base_component_t;
/*
* Macro for use in modules that are of type ns v1.0.0
* Macro for use in components that are of type ns v1.0.0
*/
#define MCA_NS_BASE_VERSION_1_0_0 \
/* ns v1.0 is chained to MCA v1.0 */ \

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

@ -44,7 +44,7 @@ int mca_ns_replica_close(void);
/*
* Startup / Shutdown
*/
mca_ns_t* mca_ns_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads);
mca_ns_t* mca_ns_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority);
int mca_ns_replica_finalize(void);
/*

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

@ -6,17 +6,19 @@
*
* The Open MPI Name Server
*
* The Open MPI Name Server provides unique name ranges for processes within the
* universe. Each universe will have one name server running within the seed daemon.
* This is done to prevent the inadvertent duplication of names.
*
* The Open MPI Name Server provides unique name ranges for processes
* within the universe. Each universe will have one name server
* running within the seed daemon. This is done to prevent the
* inadvertent duplication of names.
*/
/*
* includes
*/
#include "ompi_config.h"
#include "include/constants.h"
#include "util/proc_info.h"
#include "mca/mca.h"
#include "mca/ns/base/base.h"
#include "ns_replica.h"
@ -25,7 +27,7 @@
/*
* Struct of function pointers that need to be initialized
*/
mca_ns_base_module_t mca_ns_replica_module = {
mca_ns_base_component_t mca_ns_replica_module = {
{
MCA_NS_BASE_VERSION_1_0_0,
@ -46,7 +48,7 @@ mca_ns_base_module_t mca_ns_replica_module = {
/*
* setup the function pointers for the module
*/
mca_ns_t mca_ns_replica = {
static mca_ns_t mca_ns_replica = {
ns_replica_create_cellid,
ns_replica_create_jobid,
ns_base_create_process_name,
@ -62,6 +64,11 @@ mca_ns_t mca_ns_replica = {
ns_base_compare
};
/*
* Whether or not we allowed this component to be selected
*/
static bool initialized = false;
/* constructor - used to initialize state of name_tracker instance */
static void ompi_name_tracker_construct(ompi_name_tracker_t* name_tracker)
@ -93,8 +100,7 @@ ompi_list_t ompi_name_tracker;
* don't really need this function - could just put NULL in the above structure
* Just holding the place in case we decide there is something we need to do
*/
int
mca_ns_replica_open(void)
int mca_ns_replica_open(void)
{
return OMPI_SUCCESS;
}
@ -102,31 +108,60 @@ mca_ns_replica_open(void)
/*
* ditto for this one
*/
int
mca_ns_replica_close(void)
int mca_ns_replica_close(void)
{
return OMPI_SUCCESS;
}
mca_ns_t* mca_ns_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads)
mca_ns_t* mca_ns_replica_init(bool *allow_multi_user_threads, bool *have_hidden_threads, int *priority)
{
last_used_cellid = 0;
last_used_jobid = 0;
/* If we're the seed, then we want to be selected, so do all the
setup and return the module */
/* initialize the name tracker */
OBJ_CONSTRUCT(&ompi_name_tracker, ompi_list_t);
if (ompi_process_info.seed) {
return &mca_ns_replica;
last_used_cellid = 0;
last_used_jobid = 0;
/* Return a module (choose an arbitrary, positive priority --
it's only relevant compared to other ns components). If
we're not the seed, then we don't want to be selected, so
return NULL. */
*priority = 50;
/* We allow multi user threads but don't have any hidden threads */
*allow_multi_user_threads = true;
*have_hidden_threads = false;
/* initialize the name tracker */
OBJ_CONSTRUCT(&ompi_name_tracker, ompi_list_t);
/* Return the module */
initialized = true;
return &mca_ns_replica;
} else {
return NULL;
}
}
/*
* finalize routine
*/
int
mca_ns_replica_finalize(void)
int mca_ns_replica_finalize(void)
{
/* free all tracking storage */
/* free all tracking storage, but only if this component was initialized */
/* return OMPI_SUCCESS */
return OMPI_SUCCESS;
if (initialized) {
OBJ_DESTRUCT(&ompi_name_tracker);
initialized = false;
}
/* All done */
return OMPI_SUCCESS;
}

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

@ -12,6 +12,7 @@
#include "threads/mutex.h"
#include "mca/pcm/base/base.h"
#include "mca/oob/base/base.h"
#include "mca/ns/base/base.h"
/**
@ -26,6 +27,7 @@ int ompi_rte_finalize(void)
{
mca_oob_base_close();
mca_pcm_base_close();
mca_ns_base_close();
/* All done */

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

@ -12,6 +12,7 @@
#include "threads/mutex.h"
#include "mca/pcm/base/base.h"
#include "mca/oob/base/base.h"
#include "mca/ns/base/base.h"
/**
@ -30,6 +31,21 @@ int ompi_rte_init(bool *allow_multi_user_threads, bool *have_hidden_threads)
*allow_multi_user_threads = true;
*have_hidden_threads = false;
/* Added by JMS: I *think* ns has to come first; feel free to move
around */
if (OMPI_SUCCESS != (ret = mca_ns_base_open())) {
/* JMS show_help */
return ret;
}
if (OMPI_SUCCESS != (ret = mca_ns_base_select(&user_threads,
&hidden_threads))) {
/* JMS show_help */
return ret;
}
*allow_multi_user_threads &= user_threads;
*have_hidden_threads |= hidden_threads;
/* Added by JMS -- feel free to move around */
if (OMPI_SUCCESS != (ret = mca_pcm_base_open())) {
@ -37,7 +53,7 @@ int ompi_rte_init(bool *allow_multi_user_threads, bool *have_hidden_threads)
return ret;
}
if (OMPI_SUCCESS != (ret = mca_pcm_base_select(&user_threads,
&hidden_threads))) {
&hidden_threads))) {
/* JMS show_help */
return ret;
}
@ -48,7 +64,8 @@ int ompi_rte_init(bool *allow_multi_user_threads, bool *have_hidden_threads)
/* JMS show_help */
return ret;
}
if (OMPI_SUCCESS != (ret = mca_oob_base_init(&user_threads, &hidden_threads))) {
if (OMPI_SUCCESS != (ret = mca_oob_base_init(&user_threads,
&hidden_threads))) {
/* JMS show_help */
return ret;
}