Exemple #1
0
int orcm_init(orcm_proc_type_t flags)
{
    int ret;
    char *error;
    int spin;
    opal_output_stream_t lds;

    if (0 < orcm_initialized) {
        /* track number of times we have been called */
        orcm_initialized++;
        return ORCM_SUCCESS;
    }
    orcm_initialized++;

    if (NULL != getenv("ORCM_MCA_spin")) {
        spin = 1;
        /* spin until a debugger can attach */
        while (0 != spin) {
            ret = 0;
            while (ret < 10000) {
                ret++;
            };
        }
    }
    
    /* initialize the opal layer */
    if (ORTE_SUCCESS != (ret = opal_init(NULL, NULL))) {
        error = "opal_init";
        goto error;
    }
    
    orcm_debug_verbosity = -1;
    (void) mca_base_var_register ("orcm", "orcm", NULL, "debug_verbose",
                                  "Verbosity level for ORCM debug messages (default: 1)",
                                  MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
                                  OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL,
                                  &orcm_debug_verbosity);
    if (0 <= orcm_debug_verbosity) {
        /* get a debug output channel */
        OBJ_CONSTRUCT(&lds, opal_output_stream_t);
        lds.lds_want_stdout = true;
        orcm_debug_output = opal_output_open(&lds);
        OBJ_DESTRUCT(&lds);
        /* set the verbosity */
        opal_output_set_verbosity(orcm_debug_output, orcm_debug_verbosity);
    }

    /* ensure we know the type of proc for when we finalize */
    orte_process_info.proc_type = flags;

    /* setup the locks */
    if (ORTE_SUCCESS != (ret = orte_locks_init())) {
        error = "orte_locks_init";
        goto error;
    }
    
    /* register handler for errnum -> string conversion */
    opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);

    /* Ensure the rest of the process info structure is initialized */
    if (ORTE_SUCCESS != (ret = orte_proc_info())) {
        error = "orte_proc_info";
        goto error;
    }

    /* register handler for errnum -> string conversion */
    opal_error_register("ORCM", ORCM_ERR_BASE, ORCM_ERR_MAX, orcm_err2str);

    /* register handler for attr key -> string conversion */
    if (ORTE_SUCCESS != (ret = orte_attr_register("orcm", ORCM_ATTR_KEY_BASE, ORCM_ATTR_KEY_MAX,
                                                  orcm_attr_key_print))) {
        error = "register attr print";
        goto error;
    }
    
    /* we don't need a progress thread as all our tools loop inside themselves,
     * so define orte_event_base to be the base opal_event_base
     */
    orte_event_base = opal_sync_event_base;

    /* setup the globals */
    orcm_clusters = OBJ_NEW(opal_list_t);
    orcm_schedulers = OBJ_NEW(opal_list_t);

    /* everyone must open the cfgi framework */
    if (ORCM_SUCCESS != (ret = mca_base_framework_open(&orcm_cfgi_base_framework, 0))) {
        error = "orcm_cfgi_base_open";
        goto error;
    }
    if (ORCM_SUCCESS != (ret = orcm_cfgi_base_select())) {
        error = "orcm_cfgi_select";
        goto error;
    }

    /* everyone must open the sst framework */
    if (ORCM_SUCCESS != (ret = mca_base_framework_open(&orcm_sst_base_framework, 0))) {
        error = "orcm_sst_base_open";
        goto error;
    }
    if (ORCM_SUCCESS != (ret = orcm_sst_base_select())) {
        error = "orcm_sst_select";
        goto error;
    }

    /* open the ESS and select the correct module for this environment - the
     * orcm module is basically a no-op, but we need the framework defined
     * as other parts of ORTE will want to call it
     */
    if (ORTE_SUCCESS != (ret = mca_base_framework_open(&orte_ess_base_framework, 0))) {
        ORTE_ERROR_LOG(ret);
        error = "orte_ess_base_open";
        goto error;
    }
    if (ORTE_SUCCESS != (ret = orte_ess_base_select())) {
        error = "orte_ess_base_select";
        goto error;
    }
    if (ORTE_SUCCESS != (ret = orte_ess.init())) {
        error = "orte_ess_init";
        goto error;
    }

    /* initialize us - we will register the ORTE-level MCA params in there */
    if (ORTE_SUCCESS != (ret = orcm_sst.init())) {
        error = "orte_init";
        goto error;
    }
    
    /* setup the orte_show_help system - don't do this until the
     * end as otherwise show_help messages won't appear
     */
    if (ORTE_SUCCESS != (ret = orte_show_help_init())) {
        error = "opal_output_init";
        goto error;
    }

    /* initialize orcm datatype support */
    if (ORCM_SUCCESS != (ret = orcm_dt_init())) {
        error = "orcm_dt_init";
        goto error;
    }
    
    /* flag that orte is initialized so things can work */
    orte_initialized = true;

    return ORCM_SUCCESS;

 error:
    if (ORCM_ERR_SILENT != ret) {
        opal_show_help("help-orcm-runtime.txt",
                       "orcm_init:startup:internal-failure",
                       true, error, ORTE_ERROR_NAME(ret), ret);
    }
    
    return ret;
}
Exemple #2
0
int orcm_init(orcm_proc_type_t flags)
{
    int ret;
    char *error, *envar;
    int spin;
    opal_output_stream_t lds;

    if (0 < orcm_initialized) {
        /* track number of times we have been called */
        orcm_initialized++;
        return ORCM_SUCCESS;
    }
    orcm_initialized++;

    if (NULL != getenv("ORCM_MCA_spin")) {
        spin = 1;
        /* spin until a debugger can attach */
        while (0 != spin) {
            ret = 0;
            while (ret < 10000) {
                ret++;
            };
        }
    }

    /* prior to initializing the OPAL layer, check to see
     * if the OPAL (and friends) install location has been
     * moved. In order to avoid conflicts with any other
     * OPAL-using software, the relocation point will have
     * been expressed as a set of "ORCM_foo" envars. We
     * therefore check for the ORCM_foo values, and name-shift
     * any we find to OPAL_foo so that OPAL will find them.
     * Since all ORCM tools will have already copied their
     * local environment, these name-shifted vars will not
     * appear in the environment of any launched processes */
    if (NULL != (envar = getenv("ORCM_PREFIX"))) {
        opal_unsetenv("ORCM_PREFIX", &environ);
        opal_setenv("OPAL_PREFIX", envar, true, &environ);
    }
    if (NULL != (envar = getenv("ORCM_LIBDIR"))) {
        opal_unsetenv("ORCM_LIBDIR", &environ);
        opal_setenv("OPAL_LIBDIR", envar, true, &environ);
    }
    if (NULL != (envar = getenv("ORCM_DATADIR"))) {
        opal_unsetenv("ORCM_DATADIR", &environ);
        opal_setenv("OPAL_DATADIR", envar, true, &environ);
    }
    /* initialize the opal layer */
    if (ORTE_SUCCESS != (ret = opal_init(NULL, NULL))) {
        error = "opal_init";
        goto error;
    }

    orcm_debug_verbosity = -1;
    (void) mca_base_var_register ("orcm", "orcm", NULL, "debug_verbose",
                                  "Verbosity level for ORCM debug messages (default: 1)",
                                  MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
                                  OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_ALL,
                                  &orcm_debug_verbosity);
    if (0 <= orcm_debug_verbosity) {
        /* get a debug output channel */
        OBJ_CONSTRUCT(&lds, opal_output_stream_t);
        lds.lds_want_stdout = true;
        orcm_debug_output = opal_output_open(&lds);
        OBJ_DESTRUCT(&lds);
        /* set the verbosity */
        opal_output_set_verbosity(orcm_debug_output, orcm_debug_verbosity);
    }

    /* ensure we know the type of proc for when we finalize */
    orte_process_info.proc_type = flags;

    /* setup the locks */
    if (ORTE_SUCCESS != (ret = orte_locks_init())) {
        error = "orte_locks_init";
        goto error;
    }

    /* register handler for errnum -> string conversion */
    opal_error_register("ORTE", ORTE_ERR_BASE, ORTE_ERR_MAX, orte_err2str);

    /* Ensure the rest of the process info structure is initialized */
    if (ORTE_SUCCESS != (ret = orte_proc_info())) {
        error = "orte_proc_info";
        goto error;
    }

    /* register handler for errnum -> string conversion */
    opal_error_register("ORCM", ORCM_ERR_BASE, ORCM_ERR_MAX, orcm_err2str);

    /* register handler for attr key -> string conversion */
    if (ORTE_SUCCESS != (ret = orte_attr_register("orcm", ORCM_ATTR_KEY_BASE, ORCM_ATTR_KEY_MAX,
                                                  orcm_attr_key_print))) {
        error = "register attr print";
        goto error;
    }

    /* we don't need a progress thread as all our tools loop inside themselves,
     * so define orte_event_base to be the base opal_event_base
     */
    orte_event_base = opal_sync_event_base;

    /* setup the globals */
    orcm_clusters = OBJ_NEW(opal_list_t);
    orcm_schedulers = OBJ_NEW(opal_list_t);

    if (ORTE_SUCCESS != (ret = mca_base_framework_open(&orcm_parser_base_framework, 0))) {
        ORTE_ERROR_LOG(ret);
        error = "orcm_parser_base_open";
        goto error;
    }
    if (ORTE_SUCCESS != (ret = orcm_parser_base_select())) {
        ORTE_ERROR_LOG(ret);
        error = "orcm_parser_select";
        goto error;
    }

    /* everyone must open the cfgi framework */
    if (ORCM_SUCCESS != (ret = mca_base_framework_open(&orcm_cfgi_base_framework, 0))) {
        error = "orcm_cfgi_base_open";
        goto error;
    }
    if (ORCM_SUCCESS != (ret = orcm_cfgi_base_select())) {
        error = "orcm_cfgi_select";
        goto error;
    }

    envar = getenv("ORCM_MCA_logical_group_config_file");
    if (ORCM_SUCCESS != (ret = orcm_logical_group_load_to_memory(envar))) {
        error = "orcm_logical_group_load_to_memory";
        goto error;
    }

    if (ORCM_SCHED == flags) {
        if (NULL == (envar = getenv("ORCM_MCA_event_exec_path"))) {
            asprintf(&orcm_event_exec_path, "%s/bin", opal_install_dirs.prefix);
        } else {
            orcm_event_exec_path = strdup(envar);
        }
        if (NULL == orcm_event_exec_path) {
            error = "orcm_event_exec_path";
            goto error;
        }
    }

    /* everyone must open the sst framework */
    if (ORCM_SUCCESS != (ret = mca_base_framework_open(&orcm_sst_base_framework, 0))) {
        error = "orcm_sst_base_open";
        goto error;
    }
    if (ORCM_SUCCESS != (ret = orcm_sst_base_select())) {
        error = "orcm_sst_select";
        goto error;
    }

    /* open the ESS and select the correct module for this environment - the
     * orcm module is basically a no-op, but we need the framework defined
     * as other parts of ORTE will want to call it
     */
    if (ORTE_SUCCESS != (ret = mca_base_framework_open(&orte_ess_base_framework, 0))) {
        ORTE_ERROR_LOG(ret);
        error = "orte_ess_base_open";
        goto error;
    }
    if (ORTE_SUCCESS != (ret = orte_ess_base_select())) {
        error = "orte_ess_base_select";
        goto error;
    }
    if (ORTE_SUCCESS != (ret = orte_ess.init())) {
        error = "orte_ess_init";
        goto error;
    }

    /* initialize us - we will register the ORTE-level MCA params in there */
    if (ORTE_SUCCESS != (ret = orcm_sst.init())) {
        error = "orte_init";
        goto error;
    }

    /* setup the orte_show_help system - don't do this until the
     * end as otherwise show_help messages won't appear
     */
    if (ORTE_SUCCESS != (ret = orte_show_help_init())) {
        error = "opal_output_init";
        goto error;
    }

    /* initialize orcm datatype support */
    if (ORCM_SUCCESS != (ret = orcm_dt_init())) {
        error = "orcm_dt_init";
        goto error;
    }

    /* flag that orte is initialized so things can work */
    orte_initialized = true;
    orte_help_want_aggregate = false;

    return ORCM_SUCCESS;

 error:
    if (ORCM_ERR_SILENT != ret) {
        opal_show_help("help-orcm-runtime.txt",
                       "orcm_init:startup:internal-failure",
                       true, error, ORTE_ERROR_NAME(ret), ret);
    }

    return ret;
}