1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 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
);
orte_process_name_t mca_oob_name_seed = { 0, 0, 0 };
orte_process_name_t mca_oob_name_any = { ORTE_CELLID_MAX, ORTE_JOBID_MAX, ORTE_VPID_MAX };
/**
* 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;
extern opal_list_t mca_oob_base_components;
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_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
* register their address with the seed deamon.
*/
int mca_oob_base_module_init(void)
{
opal_list_item_t* item;
/* Initialize all modules after oob/gpr/ns have initialized */
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;
}
|