2004-07-01 14:49:54 +00:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "runtime/runtime.h"
|
|
|
|
#include "util/output.h"
|
2004-08-16 19:39:54 +00:00
|
|
|
#include "util/proc_info.h"
|
2004-07-01 14:49:54 +00:00
|
|
|
#include "mca/mca.h"
|
|
|
|
#include "mca/base/base.h"
|
2004-08-17 22:24:17 +00:00
|
|
|
#include "mca/pcmclient/pcmclient.h"
|
|
|
|
#include "mca/pcmclient/base/base.h"
|
2004-08-13 15:09:24 +00:00
|
|
|
#include "mca/ns/base/base.h"
|
2004-07-01 14:49:54 +00:00
|
|
|
#include "mca/pcm/pcm.h"
|
|
|
|
#include "mca/oob/oob.h"
|
|
|
|
#include "mca/oob/base/base.h"
|
|
|
|
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2004-08-02 21:24:00 +00:00
|
|
|
mca_oob_t,
|
2004-07-01 14:49:54 +00:00
|
|
|
ompi_list_item_t,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2004-08-02 00:24:22 +00:00
|
|
|
OBJ_CLASS_INSTANCE(
|
|
|
|
mca_oob_base_info_t,
|
|
|
|
ompi_list_item_t,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2004-07-01 14:49:54 +00:00
|
|
|
|
2004-08-02 21:24:00 +00:00
|
|
|
ompi_process_name_t mca_oob_name_seed;
|
|
|
|
ompi_process_name_t mca_oob_name_self;
|
|
|
|
ompi_process_name_t mca_oob_name_any;
|
2004-07-01 14:49:54 +00:00
|
|
|
|
2004-08-16 19:39:54 +00:00
|
|
|
/**
|
|
|
|
* Parse contact info string into process name and list of uri strings.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int mca_oob_base_parse_contact_info(
|
|
|
|
char* contact_info,
|
|
|
|
ompi_process_name_t* name,
|
|
|
|
char*** uri)
|
|
|
|
{
|
|
|
|
/* parse the process name */
|
|
|
|
char* ptr = strchr(contact_info, '=');
|
|
|
|
if(NULL == ptr)
|
|
|
|
return OMPI_ERR_BAD_PARAM;
|
|
|
|
*ptr = '\0';
|
|
|
|
ptr++;
|
|
|
|
*name = *ns_base_convert_string_to_process_name(contact_info);
|
|
|
|
|
|
|
|
/* parse the remainder of the string into an array of uris */
|
|
|
|
*uri = ompi_argv_split(ptr, ';');
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-01 14:49:54 +00:00
|
|
|
/**
|
|
|
|
* Function for selecting one module from all those that are
|
|
|
|
* available.
|
|
|
|
*
|
|
|
|
* Call the init function on all available modules.
|
|
|
|
*/
|
|
|
|
int mca_oob_base_init(bool *user_threads, bool *hidden_threads)
|
|
|
|
{
|
|
|
|
ompi_list_item_t *item;
|
2004-08-02 00:24:22 +00:00
|
|
|
mca_base_component_list_item_t *cli;
|
|
|
|
mca_oob_base_info_t * first;
|
2004-07-01 14:49:54 +00:00
|
|
|
mca_oob_base_component_t *component;
|
2004-08-02 21:24:00 +00:00
|
|
|
mca_oob_t *module;
|
2004-08-02 00:24:22 +00:00
|
|
|
extern ompi_list_t mca_oob_base_components;
|
2004-07-01 14:49:54 +00:00
|
|
|
ompi_process_name_t *self;
|
2004-08-16 19:39:54 +00:00
|
|
|
int i, id;
|
|
|
|
char* seed;
|
|
|
|
char** uri = NULL;
|
2004-07-01 14:49:54 +00:00
|
|
|
|
|
|
|
/* setup local name */
|
2004-08-17 22:24:17 +00:00
|
|
|
self = mca_pcmclient.pcmclient_get_self();
|
2004-07-01 14:49:54 +00:00
|
|
|
if(NULL == self) {
|
2004-08-17 22:24:17 +00:00
|
|
|
ompi_output(0, "mca_oob_base_init: could not get pcmclient self pointer");
|
2004-07-01 14:49:54 +00:00
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2004-08-02 21:24:00 +00:00
|
|
|
mca_oob_name_self = *self;
|
2004-07-01 14:49:54 +00:00
|
|
|
|
|
|
|
/* setup wildcard name */
|
2004-08-16 19:39:54 +00:00
|
|
|
mca_oob_name_any = *ompi_name_server.create_process_name(
|
|
|
|
MCA_NS_BASE_CELLID_MAX,
|
|
|
|
MCA_NS_BASE_JOBID_MAX,
|
|
|
|
MCA_NS_BASE_VPID_MAX);
|
2004-08-02 21:24:00 +00:00
|
|
|
|
2004-08-16 19:39:54 +00:00
|
|
|
/* setup seed daemons name and address */
|
|
|
|
id = mca_base_param_register_string("oob","base","seed",NULL,NULL);
|
|
|
|
mca_base_param_lookup_string(id,&seed);
|
|
|
|
if(seed == NULL) {
|
|
|
|
/* we are seed daemon */
|
|
|
|
mca_oob_name_seed = mca_oob_name_self;
|
|
|
|
} else {
|
|
|
|
/* resolve name of seed daemon */
|
|
|
|
mca_oob_base_parse_contact_info(seed,&mca_oob_name_seed, &uri);
|
|
|
|
if(NULL == uri || NULL == *uri) {
|
|
|
|
ompi_output(0, "mca_oob_base_init: unable to parse seed contact info.");
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2004-07-01 14:49:54 +00:00
|
|
|
|
|
|
|
/* Traverse the list of available modules; call their init functions. */
|
|
|
|
for (item = ompi_list_get_first(&mca_oob_base_components);
|
|
|
|
item != ompi_list_get_end(&mca_oob_base_components);
|
|
|
|
item = ompi_list_get_next(item)) {
|
2004-08-02 00:24:22 +00:00
|
|
|
mca_oob_base_info_t *inited;
|
2004-07-01 14:49:54 +00:00
|
|
|
|
2004-08-02 00:24:22 +00:00
|
|
|
cli = (mca_base_component_list_item_t *) item;
|
|
|
|
component = (mca_oob_base_component_t *) cli->cli_component;
|
2004-07-01 14:49:54 +00:00
|
|
|
|
|
|
|
if (NULL == component->oob_init) {
|
|
|
|
ompi_output_verbose(10, mca_oob_base_output, "mca_oob_base_init: no init function; ignoring component");
|
|
|
|
} else {
|
|
|
|
module = component->oob_init(user_threads, hidden_threads);
|
|
|
|
if (NULL == module) {
|
|
|
|
ompi_output_verbose(10, mca_oob_base_output, "mca_oob_base_init: oob_init returned failure");
|
2004-07-13 04:42:34 +00:00
|
|
|
} else {
|
2004-08-02 00:24:22 +00:00
|
|
|
inited = OBJ_NEW(mca_oob_base_info_t);
|
2004-07-13 04:42:34 +00:00
|
|
|
inited->oob_component = component;
|
|
|
|
inited->oob_module = module;
|
|
|
|
ompi_list_append(&mca_oob_base_modules, &inited->super);
|
2004-08-16 19:39:54 +00:00
|
|
|
|
|
|
|
/* lookup contact info for this component */
|
|
|
|
if(NULL != uri) {
|
|
|
|
for(i=0; NULL != uri[i]; i++) {
|
|
|
|
if(strncmp(uri[i], component->oob_base.mca_component_name,
|
|
|
|
strlen(component->oob_base.mca_component_name)) == 0) {
|
|
|
|
module->oob_set_seed(uri[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-01 14:49:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-16 19:39:54 +00:00
|
|
|
if(uri != NULL) {
|
|
|
|
ompi_argv_free(uri);
|
|
|
|
}
|
|
|
|
|
2004-07-01 14:49:54 +00:00
|
|
|
/* set the global variable to point to the first initialize module */
|
2004-07-13 04:42:34 +00:00
|
|
|
if (0 < ompi_list_get_size(&mca_oob_base_modules)) {
|
2004-08-02 00:24:22 +00:00
|
|
|
first = (mca_oob_base_info_t *) ompi_list_get_first(&mca_oob_base_modules);
|
2004-07-13 04:42:34 +00:00
|
|
|
mca_oob = *first->oob_module;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
} else {
|
|
|
|
printf("No OOB modules available!\n");
|
|
|
|
fflush(stdout);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2004-07-01 14:49:54 +00:00
|
|
|
}
|
|
|
|
|
2004-08-10 22:11:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtains the contact info (oob implementation specific) URI strings through
|
|
|
|
* which this process can be contacted on an OOB channel.
|
|
|
|
*
|
2004-08-10 22:30:21 +00:00
|
|
|
* @return A null terminated string.
|
2004-08-10 22:11:31 +00:00
|
|
|
*
|
2004-08-10 22:30:21 +00:00
|
|
|
* The caller is responsible for freeing the returned string.
|
2004-08-10 22:11:31 +00:00
|
|
|
*/
|
|
|
|
|
2004-08-10 22:30:21 +00:00
|
|
|
char* mca_oob_get_contact_info()
|
2004-08-10 22:11:31 +00:00
|
|
|
{
|
2004-08-16 19:39:54 +00:00
|
|
|
char *proc_name = ns_base_get_proc_name_string(MCA_OOB_NAME_SELF);
|
|
|
|
char *proc_addr = mca_oob.oob_get_addr();
|
|
|
|
size_t size = strlen(proc_name) + 1 + strlen(proc_addr) + 1;
|
|
|
|
char *contact_info = malloc(size);
|
|
|
|
sprintf(contact_info, "%s=%s", proc_name, proc_addr);
|
|
|
|
free(proc_name);
|
|
|
|
free(proc_addr);
|
|
|
|
return contact_info;
|
2004-08-10 22:11:31 +00:00
|
|
|
}
|
2004-08-16 19:39:54 +00:00
|
|
|
|