1
1
openmpi/orte/mca/oob/base/oob_base_init.c
Ralph Castain 4fff584a68 Commit the orted-failed-to-start code. This correctly causes the system to detect the failure of an orted to start and allows the system to terminate all procs/orteds that *did* start.
The primary change that underlies all this is in the OOB. Specifically, the problem in the code until now has been that the OOB attempts to resolve an address when we call the "send" to an unknown recipient. The OOB would then wait forever if that recipient never actually started (and hence, never reported back its OOB contact info). In the case of an orted that failed to start, we would correctly detect that the orted hadn't started, but then we would attempt to order all orteds (including the one that failed to start) to die. This would cause the OOB to "hang" the system.

Unfortunately, revising how the OOB resolves addresses introduced a number of additional problems. Specifically, and most troublesome, was the fact that comm_spawn involved the immediate transmission of the rendezvous point from parent-to-child after the child was spawned. The current code used the OOB address resolution as a "barrier" - basically, the parent would attempt to send the info to the child, and then "hold" there until the child's contact info had arrived (meaning the child had started) and the send could be completed.

Note that this also caused comm_spawn to "hang" the entire system if the child never started... The app-failed-to-start helped improve that behavior - this code provides additional relief.

With this change, the OOB will return an ADDRESSEE_UNKNOWN error if you attempt to send to a recipient whose contact info isn't already in the OOB's hash tables. To resolve comm_spawn issues, we also now force the cross-sharing of connection info between parent and child jobs during spawn.

Finally, to aid in setting triggers to the right values, we introduce the "arith" API for the GPR. This function allows you to atomically change the value in a registry location (either divide, multiply, add, or subtract) by the provided operand. It is equivalent to first fetching the value using a "get", then modifying it, and then putting the result back into the registry via a "put".

This commit was SVN r14711.
2007-05-21 18:31:28 +00:00

349 строки
11 KiB
C

/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/orte_constants.h"
#include <stdio.h>
#include <string.h>
#include "orte/runtime/runtime.h"
#include "opal/util/output.h"
#include "orte/util/proc_info.h"
#include "opal/util/argv.h"
#include "opal/mca/mca.h"
#include "opal/mca/base/base.h"
#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/ns/ns.h"
#include "orte/mca/oob/oob.h"
#include "orte/mca/oob/base/base.h"
OBJ_CLASS_INSTANCE(
mca_oob_t,
opal_list_item_t,
NULL,
NULL
);
OBJ_CLASS_INSTANCE(
mca_oob_base_info_t,
opal_list_item_t,
NULL,
NULL
);
/**
* Parse contact info string into process name and list of uri strings.
*/
int mca_oob_parse_contact_info(
const char* contact_info,
orte_process_name_t* name,
char*** uri)
{
orte_process_name_t* proc_name;
int rc;
/* parse the process name */
char* cinfo = strdup(contact_info);
char* ptr = strchr(cinfo, ';');
if(NULL == ptr) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
free(cinfo);
return ORTE_ERR_BAD_PARAM;
}
*ptr = '\0';
ptr++;
if (ORTE_SUCCESS != (rc = orte_ns.convert_string_to_process_name(&proc_name, cinfo))) {
ORTE_ERROR_LOG(rc);
free(cinfo);
return rc;
}
*name = *proc_name;
free(proc_name);
if (NULL != uri) {
/* parse the remainder of the string into an array of uris */
*uri = opal_argv_split(ptr, ';');
}
free(cinfo);
return ORTE_SUCCESS;
}
/**
* Function for selecting one module from all those that are
* available.
*
* Call the init function on all available modules.
*/
int mca_oob_base_init(void)
{
opal_list_item_t *item;
mca_base_component_list_item_t *cli;
mca_oob_base_component_t *component;
mca_oob_t *module;
mca_oob_t *s_module = NULL;
int s_priority = -1;
char** include = opal_argv_split(mca_oob_base_include, ',');
char** exclude = opal_argv_split(mca_oob_base_exclude, ',');
/* Traverse the list of available modules; call their init functions. */
for (item = opal_list_get_first(&mca_oob_base_components);
item != opal_list_get_end(&mca_oob_base_components);
item = opal_list_get_next(item)) {
mca_oob_base_info_t *inited;
cli = (mca_base_component_list_item_t *) item;
component = (mca_oob_base_component_t *) cli->cli_component;
/* if there is an include list - item must be in the list to be included */
if ( NULL != include ) {
char** argv = include;
bool found = false;
while(argv && *argv) {
if(strcmp(component->oob_base.mca_component_name,*argv) == 0) {
found = true;
break;
}
argv++;
}
if(found == false) {
continue;
}
/* otherwise - check the exclude list to see if this item has been specifically excluded */
} else if ( NULL != exclude ) {
char** argv = exclude;
bool found = false;
while(argv && *argv) {
if(strcmp(component->oob_base.mca_component_name,*argv) == 0) {
found = true;
break;
}
argv++;
}
if(found == true) {
continue;
}
}
if (NULL == component->oob_init) {
opal_output_verbose(10, mca_oob_base_output, "mca_oob_base_init: no init function; ignoring component");
} else {
int priority = -1;
module = component->oob_init(&priority);
if (NULL != module) {
inited = OBJ_NEW(mca_oob_base_info_t);
inited->oob_component = component;
inited->oob_module = module;
opal_list_append(&mca_oob_base_modules, &inited->super);
/* setup highest priority oob channel */
if(priority > s_priority) {
s_priority = priority;
s_module = module;
}
}
}
}
/* set the global variable to point to the first initialize module */
if(s_module == NULL) {
opal_output_verbose(10, mca_oob_base_output, "mca_oob_base_init: no OOB modules available\n");
return ORTE_ERROR;
}
mca_oob = *s_module;
return ORTE_SUCCESS;
}
/**
* Obtains the contact info (oob implementation specific) URI strings through
* which this process can be contacted on an OOB channel.
*
* @return A null terminated string.
*
* The caller is responsible for freeing the returned string.
*/
char* mca_oob_get_my_contact_info()
{
char *proc_name=NULL;
char *proc_addr = mca_oob.oob_get_addr();
char *contact_info=NULL;
int rc;
if (ORTE_SUCCESS != (rc = orte_ns.get_proc_name_string(&proc_name,
orte_process_info.my_name))) {
ORTE_ERROR_LOG(rc);
return NULL;
}
if (0 > asprintf(&contact_info, "%s;%s", proc_name, proc_addr)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
}
free(proc_name);
free(proc_addr);
return contact_info;
}
/**
* Setup the contact information for the seed daemon - which
* is passed as an MCA parameter.
*
* @param seed
*/
int mca_oob_set_contact_info(const char* contact_info)
{
orte_process_name_t name;
char** uri;
char** ptr;
int rc = mca_oob_parse_contact_info(contact_info, &name, &uri);
if(rc != ORTE_SUCCESS)
return rc;
for(ptr = uri; ptr != NULL && *ptr != NULL; ptr++) {
opal_list_item_t* item;
for (item = opal_list_get_first(&mca_oob_base_modules);
item != opal_list_get_end(&mca_oob_base_modules);
item = opal_list_get_next(item)) {
mca_oob_base_info_t* base = (mca_oob_base_info_t *) item;
if (strncmp(base->oob_component->oob_base.mca_component_name, *ptr,
strlen(base->oob_component->oob_base.mca_component_name)) == 0)
base->oob_module->oob_set_addr(&name, *ptr);
}
}
if(uri != NULL) {
opal_argv_free(uri);
}
return ORTE_SUCCESS;
}
/**
* Called to request the selected oob components to
* initialize their connections to the HNP (if not an HNP), or
* to setup a listener for incoming connections (if an HNP)
*/
int mca_oob_base_module_init(void)
{
opal_list_item_t* item;
for (item = opal_list_get_first(&mca_oob_base_modules);
item != opal_list_get_end(&mca_oob_base_modules);
item = opal_list_get_next(item)) {
mca_oob_base_info_t* base = (mca_oob_base_info_t *) item;
if (NULL != base->oob_module->oob_init)
base->oob_module->oob_init();
}
return ORTE_SUCCESS;
}
/**
* Called to have all selected oob components register their
* contact info on the GPR
*/
int mca_oob_register_contact_info(void)
{
opal_list_item_t* item;
int rc;
for (item = opal_list_get_first(&mca_oob_base_modules);
item != opal_list_get_end(&mca_oob_base_modules);
item = opal_list_get_next(item)) {
mca_oob_base_info_t* base = (mca_oob_base_info_t *) item;
if (NULL != base->oob_module->oob_register_contact_info) {
if (ORTE_SUCCESS != (rc = base->oob_module->oob_register_contact_info())) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
return ORTE_SUCCESS;
}
/**
* Called to have all selected oob components register a subscription
* to receive their required contact info from all processes in the
* specified job when the provided trigger fires
*/
int mca_oob_register_subscription(orte_jobid_t job, char *trigger)
{
opal_list_item_t* item;
int rc;
for (item = opal_list_get_first(&mca_oob_base_modules);
item != opal_list_get_end(&mca_oob_base_modules);
item = opal_list_get_next(item)) {
mca_oob_base_info_t* base = (mca_oob_base_info_t *) item;
if (NULL != base->oob_module->oob_register_subscription) {
if (ORTE_SUCCESS != (rc = base->oob_module->oob_register_subscription(job, trigger))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
return ORTE_SUCCESS;
}
/*
* Called to get contact info for a process or job from all selected
* oob components
*/
int mca_oob_get_contact_info(orte_process_name_t *name, orte_gpr_notify_data_t **data)
{
opal_list_item_t* item;
int rc;
for (item = opal_list_get_first(&mca_oob_base_modules);
item != opal_list_get_end(&mca_oob_base_modules);
item = opal_list_get_next(item)) {
mca_oob_base_info_t* base = (mca_oob_base_info_t *) item;
if (NULL != base->oob_module->oob_get_contact_info) {
if (ORTE_SUCCESS != (rc = base->oob_module->oob_get_contact_info(name, data))) {
ORTE_ERROR_LOG(rc);
return rc;
}
}
}
return ORTE_SUCCESS;
}
/*
* Called to update contact info tables in all selected oob components
*/
void mca_oob_update_contact_info(orte_gpr_notify_data_t* data, void* cbdata)
{
opal_list_item_t* item;
for (item = opal_list_get_first(&mca_oob_base_modules);
item != opal_list_get_end(&mca_oob_base_modules);
item = opal_list_get_next(item)) {
mca_oob_base_info_t* base = (mca_oob_base_info_t *) item;
if (NULL != base->oob_module->oob_update_contact_info) {
base->oob_module->oob_update_contact_info(data, cbdata);
}
}
}