int opal_paffinity_base_slot_list_set(long rank, char *slot_str)
{
    char **item;
    char **socket_core;
    int item_cnt, socket_core_cnt, rc;
    bool logical_map;
    
    if (NULL == slot_str){
        return OPAL_ERR_BAD_PARAM;
    }
    
    /* if the slot string is empty, that is an error */
    if (0 == strlen(slot_str)) {
        return OPAL_ERR_BAD_PARAM;
    }
    
    /* check for diag request to avoid repeatedly doing so */
    if (4 < opal_output_get_verbosity(opal_paffinity_base_output)) {
        diag_requested = true;
    } else {
        diag_requested = false;
    }
    
    opal_output_verbose(5, opal_paffinity_base_output, "paffinity slot assignment: slot_list == %s", slot_str);
    
    if ('P' == slot_str[0] || 'p' == slot_str[0]) {
        /* user has specified physical mapping */
        logical_map = false;
        item = opal_argv_split (&slot_str[1], ',');
    } else {
        logical_map = true;  /* default to logical mapping */
        item = opal_argv_split (slot_str, ',');
    }
    
    item_cnt = opal_argv_count (item);
    socket_core = opal_argv_split (item[0], ':');
    socket_core_cnt = opal_argv_count(socket_core);
    opal_argv_free(socket_core);
    switch (socket_core_cnt) {
        case 1:  /* binding to cpu's */
            if (OPAL_SUCCESS != (rc = opal_paffinity_base_socket_to_cpu_set(item, item_cnt, rank, logical_map))) {
                opal_argv_free(item);
                return rc;
            }
            break;
        case 2: /* binding to socket/core specification */
            if (OPAL_SUCCESS != (rc = opal_paffinity_base_socket_core_to_cpu_set(item, item_cnt, rank, logical_map))) {
                opal_argv_free(item);
                return rc;
            }
            break;
        default:
            opal_argv_free(item);
            return OPAL_ERROR;
    }
    opal_argv_free(item);
    return OPAL_SUCCESS;
}
Exemplo n.º 2
0
static orte_rml_base_module_t* open_conduit(opal_list_t *attributes)
{
    char *comp_attrib = NULL;
    char **comps;
    int i;
    orte_attribute_t *attr;

    opal_output_verbose(20,orte_rml_base_framework.framework_output,
                    "%s - Entering rml_oob_open_conduit()",
                    ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));

    /* someone may require this specific component, so look for "oob" */
    if (orte_get_attribute(attributes, ORTE_RML_INCLUDE_COMP_ATTRIB, (void**)&comp_attrib, OPAL_STRING) &&
        NULL != comp_attrib) {
        /* they specified specific components - could be multiple */
        comps = opal_argv_split(comp_attrib, ',');
        for (i=0; NULL != comps[i]; i++) {
            if (0 == strcmp(comps[i], "oob")) {
                /* we are a candidate */
                opal_argv_free(comps);
                return make_module();
            }
        }
        /* we are not a candidate */
        opal_argv_free(comps);
        return NULL;
    } else if (orte_get_attribute(attributes, ORTE_RML_EXCLUDE_COMP_ATTRIB, (void**)&comp_attrib, OPAL_STRING) &&
               NULL != comp_attrib) {
        /* see if we are on the list */
        comps = opal_argv_split(comp_attrib, ',');
        for (i=0; NULL != comps[i]; i++) {
            if (0 == strcmp(comps[i], "oob")) {
                /* we cannot be a candidate */
                opal_argv_free(comps);
                return NULL;
            }
        }
    }

    /* Alternatively, check the attributes to see if we qualify - we only handle
     * "routed", "Ethernet", and "TCP" */
    OPAL_LIST_FOREACH(attr, attributes, orte_attribute_t) {

    }

    /* if we get here, we cannot handle it */
    return NULL;
}
Exemplo n.º 3
0
static int rte_init(void)
{
    int ret;
    char *error = NULL;
    char **hosts = NULL;
    char *nodelist;

    /* run the prolog */
    if (ORTE_SUCCESS != (ret = orte_ess_base_std_prolog())) {
        error = "orte_ess_base_std_prolog";
        goto error;
    }
    
    /* Start by getting a unique name */
    tm_set_name();
    
    /* if I am a daemon, complete my setup using the
     * default procedure
     */
    if (ORTE_PROC_IS_DAEMON) {
        /* get the list of nodes used for this job */
        nodelist = getenv("OMPI_MCA_orte_nodelist");
        
        if (NULL != nodelist) {
            /* split the node list into an argv array */
            hosts = opal_argv_split(nodelist, ',');
        }
        if (ORTE_SUCCESS != (ret = orte_ess_base_orted_setup(hosts))) {
            ORTE_ERROR_LOG(ret);
            error = "orte_ess_base_orted_setup";
            goto error;
        }
        opal_argv_free(hosts);
        return ORTE_SUCCESS;
    }
    
    if (ORTE_PROC_IS_TOOL) {
        /* otherwise, if I am a tool proc, use that procedure */
        if (ORTE_SUCCESS != (ret = orte_ess_base_tool_setup())) {
            ORTE_ERROR_LOG(ret);
            error = "orte_ess_base_tool_setup";
            goto error;
        }
        return ORTE_SUCCESS;
        
    }
    
    /* no other options are supported! */
    error = "ess_error";
    ret = ORTE_ERROR;
    
error:
    if (ORTE_ERR_SILENT != ret && !orte_report_silent_errors) {
        orte_show_help("help-orte-runtime.txt",
                       "orte_init:startup:internal-failure",
                       true, error, ORTE_ERROR_NAME(ret), ret);
    }

    return ret;
}
extern void
ompi_debugger_setup_dlls(void)
{
    int i;
    char **dirs, **tmp1 = NULL, **tmp2 = NULL;

    ompi_debugger_dll_path = opal_install_dirs.opallibdir;
    (void) mca_base_var_register("ompi", "ompi", "debugger", "dll_path",
                                 "List of directories where MPI_INIT should search for debugger plugins",
                                 MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
                                 OPAL_INFO_LVL_9,
                                 MCA_BASE_VAR_SCOPE_READONLY,
                                 &ompi_debugger_dll_path);

    /* Search the directory for MPI debugger DLLs */
    if (NULL != ompi_debugger_dll_path) {
        dirs = opal_argv_split(ompi_debugger_dll_path, ':');
        for (i = 0; dirs[i] != NULL; ++i) {
            check(dirs[i], OMPI_MPIHANDLES_DLL_PREFIX, tmp1);
            check(dirs[i], OMPI_MSGQ_DLL_PREFIX, tmp2);
        }
        opal_argv_free(dirs);
    }

    /* Now that we have a full list of directories, assign the argv
       arrays to the global variables (since the debugger may read the
       global variables at any time, we want to ensure that they have
       non-NULL values only when the entire array is ready). */
    mpimsgq_dll_locations = tmp1;
    mpidbg_dll_locations = tmp2;
}
Exemplo n.º 5
0
static char *
get_slurm_nodename(int nodeid)
{
    char **names = NULL;
    char *slurm_nodelist;
    char *ret;

    mca_base_param_reg_string_name("orte", "nodelist", "List of nodes in job",
                                   true, false, NULL, &slurm_nodelist);
    if (NULL == slurm_nodelist) {
        return NULL;
    }
    
    /* split the node list into an argv array */
    names = opal_argv_split(slurm_nodelist, ',');
    if (NULL == names) {  /* got an error */
        return NULL;
    }

    /* check to see if there are enough entries */
    if (nodeid > opal_argv_count(names)) {
        return NULL;
    }

    ret = strdup(names[nodeid]);

    opal_argv_free(names);

    /* All done */
    return ret;
}
Exemplo n.º 6
0
int
orte_rml_base_parse_uris(const char* uri,
                         orte_process_name_t* peer,
                         char*** uris)
{
    int rc;

    /* parse the process name */
    char* cinfo = strdup(uri);
    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_util_convert_string_to_process_name(peer, cinfo))) {
        ORTE_ERROR_LOG(rc);
        free(cinfo);
        return rc;
    }

    if (NULL != uris) {
	/* parse the remainder of the string into an array of uris */
	*uris = opal_argv_split(ptr, ';');
    }
    free(cinfo);
    return ORTE_SUCCESS;
}
Exemplo n.º 7
0
static int dlopen_component_register(void)
{
    int ret;

    mca_dl_dlopen_component.filename_suffixes_mca_storage = ".so,.dylib,.dll,.sl";
    ret =
        mca_base_component_var_register(&mca_dl_dlopen_component.base.base_version,
                                        "filename_suffixes",
                                        "Comma-delimited list of filename suffixes that the dlopen component will try",
                                        MCA_BASE_VAR_TYPE_STRING,
                                        NULL,
                                        0,
                                        MCA_BASE_VAR_FLAG_SETTABLE,
                                        OPAL_INFO_LVL_5,
                                        MCA_BASE_VAR_SCOPE_LOCAL,
                                        &mca_dl_dlopen_component.filename_suffixes_mca_storage);
    if (ret < 0) {
        return ret;
    }
    mca_dl_dlopen_component.filename_suffixes =
        opal_argv_split(mca_dl_dlopen_component.filename_suffixes_mca_storage,
                        ',');

    return OPAL_SUCCESS;
}
Exemplo n.º 8
0
int opal_compress_bzip_compress_nb(char * fname, char **cname, char **postfix, pid_t *child_pid)
{
    char **argv = NULL;
    char * base_fname = NULL;
    char * dir_fname = NULL;
    int status;
    bool is_dir;

    is_dir = is_directory(fname);

    *child_pid = fork();
    if( *child_pid == 0 ) { /* Child */
        char * cmd;

        dir_fname  = opal_dirname(fname);
        base_fname = opal_basename(fname);

        chdir(dir_fname);

        if( is_dir ) {
#if 0
            opal_compress_base_tar_create(&base_fname);
            asprintf(cname, "%s.bz2", base_fname);
            asprintf(&cmd, "bzip2 %s", base_fname);
#else
            asprintf(cname, "%s.tar.bz2", base_fname);
            asprintf(&cmd, "tar -jcf %s %s", *cname, base_fname);
#endif
        } else {
            asprintf(cname, "%s.bz2", base_fname);
            asprintf(&cmd, "bzip2 %s", base_fname);
        }

        opal_output_verbose(10, mca_compress_bzip_component.super.output_handle,
                            "compress:bzip: compress_nb(%s -> [%s])",
                            fname, *cname);
        opal_output_verbose(10, mca_compress_bzip_component.super.output_handle,
                            "compress:bzip: compress_nb() command [%s]",
                            cmd);

        argv = opal_argv_split(cmd, ' ');
        status = execvp(argv[0], argv);

        opal_output(0, "compress:bzip: compress_nb: Failed to exec child [%s] status = %d\n", cmd, status);
        exit(OPAL_ERROR);
    }
    else if( *child_pid > 0 ) {
        if( is_dir ) {
            *postfix = strdup(".tar.bz2");
        } else {
            *postfix = strdup(".bz2");
        }
        asprintf(cname, "%s%s", fname, *postfix);
    }
    else {
        return OPAL_ERROR;
    }

    return OPAL_SUCCESS;
}
Exemplo n.º 9
0
static char *
get_slurm_nodename(int nodeid)
{
    char **names = NULL;
    char *slurm_nodelist;
    char *ret;

    slurm_nodelist = getenv("OMPI_MCA_orte_slurm_nodelist");
    
    if (NULL == slurm_nodelist) {
        return NULL;
    }
    
    /* split the node list into an argv array */
    names = opal_argv_split(slurm_nodelist, ',');
    if (NULL == names) {  /* got an error */
        return NULL;
    }

    /* check to see if there are enough entries */
    if (nodeid > opal_argv_count(names)) {
        return NULL;
    }

    ret = strdup(names[nodeid]);

    opal_argv_free(names);

    /* All done */
    return ret;
}
Exemplo n.º 10
0
static struct fi_info*
select_ofi_provider(struct fi_info *providers)
{
    char **include_list = NULL;
    char **exclude_list = NULL;
    struct fi_info *prov = providers;

    opal_output_verbose(1, ompi_mtl_base_framework.framework_output,
                        "%s:%d: mtl:ofi:provider_include = \"%s\"\n",
                        __FILE__, __LINE__, prov_include);
    opal_output_verbose(1, ompi_mtl_base_framework.framework_output,
                        "%s:%d: mtl:ofi:provider_exclude = \"%s\"\n",
                        __FILE__, __LINE__, prov_exclude);

    if (NULL != prov_include) {
        include_list = opal_argv_split(prov_include, ',');
        while ((NULL != prov) &&
               (!is_in_list(include_list, prov->fabric_attr->prov_name))) {
            opal_output_verbose(1, ompi_mtl_base_framework.framework_output,
                                "%s:%d: mtl:ofi: \"%s\" not in include list\n",
                                __FILE__, __LINE__,
                                prov->fabric_attr->prov_name);
            prov = prov->next;
        }
    } else if (NULL != prov_exclude) {
        exclude_list = opal_argv_split(prov_exclude, ',');
        while ((NULL != prov) &&
               (is_in_list(exclude_list, prov->fabric_attr->prov_name))) {
            opal_output_verbose(1, ompi_mtl_base_framework.framework_output,
                                "%s:%d: mtl:ofi: \"%s\" in exclude list\n",
                                __FILE__, __LINE__,
                                prov->fabric_attr->prov_name);
            prov = prov->next;
        }
    }

    opal_argv_free(include_list);
    opal_argv_free(exclude_list);

    opal_output_verbose(1, ompi_mtl_base_framework.framework_output,
                        "%s:%d: mtl:ofi:prov: %s\n",
                        __FILE__, __LINE__,
                        (prov ? prov->fabric_attr->prov_name : "none"));

    return prov;
}
Exemplo n.º 11
0
static int enum_value_from_string_flag (mca_base_var_enum_t *self, const char *string_value, int *value_out) {
    mca_base_var_enum_flag_t *flag_enum = (mca_base_var_enum_flag_t *) self;
    int value, count, ret, flag;
    char **flags;
    bool is_int;
    char *tmp;

    ret = self->get_count(self, &count);
    if (OPAL_SUCCESS != ret) {
        return ret;
    }

    flags = opal_argv_split (string_value, ',');
    if (NULL == flags) {
        return OPAL_ERR_BAD_PARAM;
    }

    flag = 0;

    for (int i = 0 ; flags[i] ; ++i) {
        value = strtol (flags[i], &tmp, 0);
        is_int = tmp[0] == '\0';

        bool found = false, conflict = false;
        for (int j = 0 ; j < count ; ++j) {
            if ((is_int && (value & flag_enum->enum_flags[j].flag)) ||
                0 == strcasecmp (flags[i], flag_enum->enum_flags[j].string)) {
                found = true;

                if (flag & flag_enum->enum_flags[j].conflicting_flag) {
                    conflict = true;
                } else {
                    flag |= flag_enum->enum_flags[j].flag;
                }

                if (is_int) {
                    value &= ~flag_enum->enum_flags[j].flag;
                    if (0 == value) {
                        break;
                    }
                } else {
                    break;
                }
            }
        }

        if (!found || conflict || (is_int && value)) {
            opal_argv_free (flags);
            return !found ? OPAL_ERR_VALUE_OUT_OF_BOUNDS : OPAL_ERR_BAD_PARAM;
        }
    }

    opal_argv_free (flags);

    *value_out = flag;

    return OPAL_SUCCESS;
}
Exemplo n.º 12
0
static int check_modifiers(char *ck, orte_mapping_policy_t *tmp)
{
    char **ck2, *ptr;
    int i;
    bool found = false;

    opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
                        "%s rmaps:base check modifiers with %s",
                        ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                        (NULL == ck) ? "NULL" : ck);

    if (NULL == ck) {
        return ORTE_SUCCESS;
    }

    ck2 = opal_argv_split(ck, ',');
    for (i=0; NULL != ck2[i]; i++) {
        if (0 == strncasecmp(ck2[i], "span", strlen(ck2[i]))) {
            ORTE_SET_MAPPING_DIRECTIVE(*tmp, ORTE_MAPPING_SPAN);
            found = true;
        } else if (0 == strncasecmp(ck2[i], "pe", strlen("pe"))) {
            /* break this at the = sign to get the number */
            if (NULL == (ptr = strchr(ck2[i], '='))) {
                /* missing the value */
                orte_show_help("help-orte-rmaps-base.txt", "missing-value", true, "pe", ck2[i]);
                opal_argv_free(ck2);
                return ORTE_ERR_SILENT;
            }
            ptr++;
            orte_rmaps_base.cpus_per_rank = strtol(ptr, NULL, 10);
            opal_output_verbose(5, orte_rmaps_base_framework.framework_output,
                                "%s rmaps:base setting pe/rank to %d",
                                ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                                orte_rmaps_base.cpus_per_rank);
            found = true;
        } else if (0 == strncasecmp(ck2[i], "oversubscribe", strlen(ck2[i]))) {
            ORTE_UNSET_MAPPING_DIRECTIVE(*tmp, ORTE_MAPPING_NO_OVERSUBSCRIBE);
            ORTE_SET_MAPPING_DIRECTIVE(*tmp, ORTE_MAPPING_SUBSCRIBE_GIVEN);
            found = true;
        } else if (0 == strncasecmp(ck2[i], "nooversubscribe", strlen(ck2[i]))) {
            ORTE_SET_MAPPING_DIRECTIVE(*tmp, ORTE_MAPPING_NO_OVERSUBSCRIBE);
            ORTE_SET_MAPPING_DIRECTIVE(*tmp, ORTE_MAPPING_SUBSCRIBE_GIVEN);
            found = true;
        } else {
            /* unrecognized modifier */
            opal_argv_free(ck2);
            return ORTE_ERR_BAD_PARAM;
        }
    }
    opal_argv_free(ck2);
    if (found) {
        return ORTE_SUCCESS;
    }
    return ORTE_ERR_TAKE_NEXT_OPTION;
}
Exemplo n.º 13
0
static int pretty_print_migration(void)
{
    char **loc_off_nodes = NULL;
    char **loc_off_procs = NULL;
    char **loc_onto_nodes = NULL;
    int  loc_off_nodes_cnt = 0;
    int  loc_off_procs_cnt = 0;
    int  loc_onto_cnt = 0;
    int i;

    if( NULL != orte_migrate_globals.off_nodes ) {
        loc_off_nodes = opal_argv_split(orte_migrate_globals.off_nodes, ',');
        loc_off_nodes_cnt = opal_argv_count(loc_off_nodes);
    }

    if( NULL != orte_migrate_globals.off_procs ) {
        loc_off_procs     = opal_argv_split(orte_migrate_globals.off_procs, ',');
        loc_off_procs_cnt = opal_argv_count(loc_off_procs);
    }

    if( NULL != orte_migrate_globals.onto_nodes ) {
        loc_onto_nodes = opal_argv_split(orte_migrate_globals.onto_nodes, ',');
        loc_onto_cnt = opal_argv_count(loc_onto_nodes);
    }

    printf("Migrate Nodes: (%d nodes)\n", loc_off_nodes_cnt);
    for(i = 0; i < loc_off_nodes_cnt; ++i) {
        printf("\t\"%s\"\n", loc_off_nodes[i]);
    }

    printf("Migrate Ranks: (%d ranks)\n", loc_off_procs_cnt);
    for(i = 0; i < loc_off_procs_cnt; ++i) {
        printf("\t\"%s\"\n", loc_off_procs[i]);
    }

    printf("Migrate Onto : (%d nodes)\n", loc_onto_cnt);
    for(i = 0; i < loc_onto_cnt; ++i) {
        printf("\t\"%s\"\n", loc_onto_nodes[i]);
    }

    return ORTE_SUCCESS;    
}
static int rte_init(void)
{
    int rc;
    orte_vpid_t vpid;
    char *vpid_string;
    char *nidmap_string;

    vpid_string = getenv("PTL_MY_RID");
    nidmap_string = getenv("PTL_NIDMAP");
    if (NULL == vpid_string || NULL == nidmap_string ||
        NULL == getenv("PTL_PIDMAP") || NULL == getenv("PTL_IFACE")) {
        return ORTE_ERR_NOT_FOUND;
    }

    /* Get our process information */

    /* Procs in this environment are directly launched. Hence, there
     * was no mpirun to create a jobid for us, and each app proc is
     * going to have to fend for itself. For now, we assume that the
     * jobid is some arbitrary number (say, 1).
     */
    ORTE_PROC_MY_NAME->jobid = 1; /* not 0, since it has special meaning */
    
    /*  find our vpid assuming range starts at 0 */
    if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_vpid(&vpid, vpid_string))) {
        ORTE_ERROR_LOG(rc);
        return(rc);
    }
    ORTE_PROC_MY_NAME->vpid = vpid;
    
    /*
     * Get the number of procs in the job.  We assume vpids start at 0.  We
     * assume that there are <num : + 1> procs, since the nidmap is a
     * : seperated list of nids, and the utcp reference implementation
     * assumes all will be present
     */
    /* split the nidmap string */
    nidmap = opal_argv_split(nidmap_string, ':');
    orte_process_info.num_procs = (orte_std_cntr_t) opal_argv_count(nidmap);

    /* MPI_Init needs the grpcomm framework, so we have to init it */
    if (ORTE_SUCCESS != (rc = orte_grpcomm_base_open())) {
        ORTE_ERROR_LOG(rc);
        return rc;
    }
    if (ORTE_SUCCESS != (rc = orte_grpcomm_base_select())) {
        ORTE_ERROR_LOG(rc);
        return rc;
    }
    
    /* that's all we need here */
    return ORTE_SUCCESS;
}
Exemplo n.º 15
0
/**
 * Run a user-level debugger
 */
void orte_run_debugger(char *basename, opal_cmd_line_t *cmd_line,
                       int argc, char *argv[])
{
    int i, id;
    char **new_argv = NULL;
    char *value, **lines;

    /* Get the orte_base_debug MCA parameter and search for a debugger
       that can run */
    
    id = mca_base_param_find("orte", NULL, "base_user_debugger");
    if (id < 0) {
        opal_show_help("help-orterun.txt", "debugger-mca-param-not-found", 
                       true);
        exit(1);
    }
    value = NULL;
    mca_base_param_lookup_string(id, &value);
    if (NULL == value) {
        opal_show_help("help-orterun.txt", "debugger-orte_base_user_debugger-empty",
                       true);
        exit(1);
    }

    /* Look through all the values in the MCA param */

    lines = opal_argv_split(value, ':');
    free(value);
    for (i = 0; NULL != lines[i]; ++i) {
        if (ORTE_SUCCESS == process(lines[i], basename, cmd_line, argc, argv, 
                                    &new_argv)) {
            break;
        }
    }

    /* If we didn't find one, abort */

    if (NULL == lines[i]) {
        opal_show_help("help-orterun.txt", "debugger-not-found", true);
        exit(1);
    }
    opal_argv_free(lines);

    /* We found one */

    execvp(new_argv[0], new_argv);
    value = opal_argv_join(new_argv, ' ');
    opal_show_help("help-orterun.txt", "debugger-exec-failed",
                   true, basename, value, new_argv[0]);
    free(value);
    opal_argv_free(new_argv);
    exit(1);
}
static int parse_requested(int mca_param, bool *include_mode,
                           char ***requested_component_names)
{
    int i;
    char *requested, *requested_orig;

    *requested_component_names = NULL;
    *include_mode = true;

    /* See if the user requested anything */

    if (OPAL_ERROR == mca_base_param_lookup_string(mca_param, &requested)) {
        return OPAL_ERROR;
    }
    if (NULL == requested || 0 == strlen(requested)) {
        return OPAL_SUCCESS;
    }
    requested_orig = requested;

    /* Are we including or excluding?  We only allow the negate
       character to be the *first* character of the value (but be nice
       and allow any number of negate characters in the beginning). */

    while (negate == requested[0] && '\0' != requested[0]) {
        *include_mode = false;
        ++requested;
    }

    /* Double check to ensure that the user did not specify the negate
       character anywhere else in the value. */

    i = 0;
    while ('\0' != requested[i]) {
        if (negate == requested[i]) {
            opal_show_help("help-mca-base.txt",
                           "framework-param:too-many-negates",
                           true, requested_orig);
            free(requested_orig);
            return OPAL_ERROR;
        }
        ++i;
    }

    /* Split up the value into individual component names */

    *requested_component_names = opal_argv_split(requested, ',');

    /* All done */

    free(requested_orig);
    return OPAL_SUCCESS;
}
Exemplo n.º 17
0
/**
orte_plm_poe_component_open - open component and register all parameters
@return error number
*/
int orte_plm_poe_component_open(void)
{
    char *param;
    mca_base_component_t *c = &mca_plm_poe_component.super.base_version;

    mca_base_param_reg_int(c, "mp_retry",
                           "specifies the interval (in seconds) to wait before repeating the node request",
                           true, false, 0, &mca_plm_poe_component.mp_retry);
    mca_base_param_reg_int(c, "mp_retrycount",
                           "specifies the number of times the Partition Manager should make the request before returning",
                           true, false, 0, &mca_plm_poe_component.mp_retrycount);
    mca_base_param_reg_int(c, "mp_infolevel",
                           "specify the level of messages you want from POE (0-6)",
                           true, false, 0, &mca_plm_poe_component.mp_infolevel);
    mca_base_param_reg_string(c, "mp_labelio",
                           "Whether or not to label message output with task identifiers (yes or no)",
                           true, false, "no", &mca_plm_poe_component.mp_labelio);
    mca_base_param_reg_string(c, "mp_stdoutmode",
                           "standard output mode (ordered, unordered or taskID)",
                           true, false, "unordered", &mca_plm_poe_component.mp_stdoutmode);

    mca_base_param_reg_int(c, "debug",
                           "Whether or not to enable debugging output for the poe plm component (0 or 1)",
                           false, false, 0, &mca_plm_poe_component.debug);
    mca_base_param_reg_int(c, "priority",
                           "Priority of the poe plm component",
                           false , false, 0, &mca_plm_poe_component.priority);
    mca_base_param_reg_string(c, "class",
                           "class (interactive or batch)",
                           true, false, "interactive", &mca_plm_poe_component.class);
    mca_base_param_reg_string(c, "resource_allocation",
                           "resource_allocation mode (hostfile or automatic)",
                           false, false, "hostfile", &mca_plm_poe_component.resource_allocation);
    mca_base_param_reg_string(c, "progenv",
                           "The command name that setup environment",
                           false, false, "env", &mca_plm_poe_component.env);
    mca_base_param_reg_string(c, "progpoe",
                           "The POE command",
                           false, false, "poe", &param);
    mca_plm_poe_component.argv = opal_argv_split(param, ' ');
    mca_plm_poe_component.argc = opal_argv_count(mca_plm_poe_component.argv);
    if (mca_plm_poe_component.argc > 0) {
        mca_plm_poe_component.path = strdup(mca_plm_poe_component.argv[0]);
        return ORTE_SUCCESS;
    } else {
        mca_plm_poe_component.path = NULL;
        return ORTE_ERR_BAD_PARAM;
    }


    return ORTE_SUCCESS;
}
Exemplo n.º 18
0
static bool test4(void)
{
  size_t i, count;
  char *a = strdup("the quick  brown fox jumped over  the lazy  dog a_really_long_argument_to_force_a_long_copy_zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
  char **b;
  char *start;

  /* split a string into an argv, and compare it against the original
     string.  Add double spaces into the string; opal_argv_split()
     should skip them. */

  b = opal_argv_split(a, ' ');

  for (count = i = 1; i < strlen(a); ++i) {
    if (a[i] != ' ' && a[i - 1] == ' ') {
      ++count;
    }
  }
  for (i = 0; b[i] != NULL; ++i) {
    continue;
  }
  if (i != count) {
    return false;
  }

  /* now do the same thing and compare each token in b */

  for (start = a, count = i = 0; i < strlen(a); ++i) {
    if (a[i] == ' ' && a[i - 1] != ' ') {
      a[i] = '\0';
      if (strcmp(start, b[count]) != 0) {
        return false;
      }
      ++count;
      a[i] = ' ';
    }
    if (a[i] == ' ' && a[i + 1] != ' ') {
      start = a + i + 1;
    }
  }
  if (strcmp(start, b[count]) != 0) {
    return false;
  }

  /* all done */

  opal_argv_free(b);
  free(a);
  return true;
}
Exemplo n.º 19
0
static size_t orte_ras_bjs_node_slots(char* node_name)
{
    static char** nodelist = NULL;
    char** ptr;
    size_t count = 0;
    if(nodelist == NULL)
        nodelist = opal_argv_split(getenv("NODELIST"), ',');
    ptr = nodelist;
    while(ptr && *ptr) {
        if(strcmp(*ptr, node_name) == 0)
            count++;
        ptr++;
    }
    return count;
}
Exemplo n.º 20
0
Arquivo: net.c Projeto: anandhis/ompi
int
opal_net_init(void)
{
    char **args, *arg;
    uint32_t a, b, c, d, bits, addr;
    int i, count, found_bad = 0;

    args = opal_argv_split( opal_net_private_ipv4, ';' );
    if( NULL != args ) {
        count = opal_argv_count(args);
        private_ipv4 = (private_ipv4_t*)malloc( (count + 1) * sizeof(private_ipv4_t));
        if( NULL == private_ipv4 ) {
            opal_output(0, "Unable to allocate memory for the private addresses array" );
            opal_argv_free(args);
            goto do_local_init;
        }
        for( i = 0; i < count; i++ ) {
            arg = args[i];

            (void)sscanf( arg, "%u.%u.%u.%u/%u", &a, &b, &c, &d, &bits );

            if( (a > 255) || (b > 255) || (c > 255) ||
                (d > 255) || (bits > 32) ) {
                if (0 == found_bad) {
                    opal_show_help("help-opal-util.txt",
                                   "malformed net_private_ipv4",
                                   true, args[i]);
                    found_bad = 1;
                }
                continue;
            }
            addr = (a << 24) | (b << 16) | (c << 8) | d;
            private_ipv4[i].addr = htonl(addr);
            private_ipv4[i].netmask_bits = bits;
        }
        private_ipv4[i].addr         = 0;
        private_ipv4[i].netmask_bits = 0;
        opal_argv_free(args);
    }

 do_local_init:
#if OPAL_ENABLE_IPV6
    return opal_tsd_key_create(&hostname_tsd_key, hostname_cleanup);
#else
    return OPAL_SUCCESS;
#endif
}
Exemplo n.º 21
0
int orte_session_setup_base(orte_process_name_t *proc)
{
    int rc;

    /* Ensure that system info is set */
    orte_proc_info();

    /* setup job and proc session directories */
    if( ORTE_SUCCESS != (rc = _setup_job_session_dir(proc)) ){
        return rc;
    }

    if( ORTE_SUCCESS != (rc = _setup_proc_session_dir(proc)) ){
        return rc;
    }

    /* BEFORE doing anything else, check to see if this prefix is
     * allowed by the system
     */
    if (NULL != orte_prohibited_session_dirs ||
            NULL != orte_process_info.tmpdir_base ) {
        char **list;
        int i, len;
        /* break the string into tokens - it should be
         * separated by ','
         */
        list = opal_argv_split(orte_prohibited_session_dirs, ',');
        len = opal_argv_count(list);
        /* cycle through the list */
        for (i=0; i < len; i++) {
            /* check if prefix matches */
            if (0 == strncmp(orte_process_info.tmpdir_base, list[i], strlen(list[i]))) {
                /* this is a prohibited location */
                orte_show_help("help-orte-runtime.txt",
                               "orte:session:dir:prohibited",
                               true, orte_process_info.tmpdir_base,
                               orte_prohibited_session_dirs);
                opal_argv_free(list);
                return ORTE_ERR_FATAL;
            }
        }
        opal_argv_free(list);  /* done with this */
    }
    return ORTE_SUCCESS;
}
Exemplo n.º 22
0
static int mrhnp_query(mca_base_module_t **module, int *priority)
{
    mca_iof_mr_hnp_component.input_files = NULL;

    /* select if we are HNP and map-reduce mode is operational */
    if (ORTE_PROC_IS_HNP && orte_map_reduce) {
        *priority = 1000;
        *module = (mca_base_module_t *) &orte_iof_mrhnp_module;
        if (NULL != orte_iof_base.input_files) {
            mca_iof_mr_hnp_component.input_files = opal_argv_split(orte_iof_base.input_files, ',');
        }
        return ORTE_SUCCESS;
    }
        
    *priority = -1;
    *module = NULL;
    return ORTE_ERROR;
}
Exemplo n.º 23
0
/* get list of subgrouping coponents to use */
static int mca_bcol_base_set_components_to_use(opal_list_t *bcol_components_avail,
                opal_list_t *bcol_components_in_use)
{
    /* local variables */
    const mca_base_component_t *b_component;

    mca_base_component_list_item_t *b_cli;
    mca_base_component_list_item_t *b_clj;

    char **bcols_requested;
    const char *b_component_name;

    /* split the requst for the bcol modules */
    bcols_requested = opal_argv_split(ompi_bcol_bcols_string, ',');
    if (NULL == bcols_requested) {
        return OMPI_ERROR;
    }

    /* Initialize list */
    OBJ_CONSTRUCT(bcol_components_in_use, opal_list_t);

    /* figure out basic collective modules to use */
    /* loop over list of components requested */
    for (int i = 0 ; bcols_requested[i] ; ++i) {
        /* loop over discovered components */
        OPAL_LIST_FOREACH(b_cli, bcol_components_avail, mca_base_component_list_item_t) {
            b_component = b_cli->cli_component;
            b_component_name = b_component->mca_component_name;

            if (0 == strcmp (b_component_name, bcols_requested[i])) {
                /* found selected component */
                b_clj = OBJ_NEW(mca_base_component_list_item_t);
                if (NULL == b_clj) {
                    return OPAL_ERR_OUT_OF_RESOURCE;
                }

                b_clj->cli_component = b_component;
                opal_list_append(bcol_components_in_use,
                                (opal_list_item_t *) b_clj);
                break;
             } /* end check for bcol component */
         }
     }
Exemplo n.º 24
0
/* get key/value from line */
static opal_value_t *oflow_parse_next_line(FILE *fp)
{
    char *ret, *ptr;
    char **tokens = NULL;
    char input[ORCM_MAX_LINE_LENGTH];
    size_t i;
    opal_value_t *tokenized;
    int array_length;
    
    ret = fgets(input, ORCM_MAX_LINE_LENGTH, fp);
    if (NULL != ret) {
        /* remove newline */
        input[strlen(input)-1] = '\0';
        /* strip leading spaces */
        ptr = input;
        for (i=0; i < strlen(input)-1; i++) {
            if (' ' != input[i]) {
                ptr = &input[i];
                break;
            }
        }
        tokens = opal_argv_split(ptr, ':');
        array_length = opal_argv_count(tokens);
        if (2 == array_length) {
            tokenized = (opal_value_t *)malloc(sizeof(opal_value_t));
            if (!tokenized) {
                opal_argv_free(tokens);
                return NULL;
            }
            tokenized->type = OPAL_STRING;
            tokenized->key = tokens[0];
            tokenized->data.string = tokens[1];
            opal_argv_free(tokens);
            return tokenized;
        }
        opal_argv_free(tokens);
    }
    
    return NULL;
}
Exemplo n.º 25
0
int opal_event_init(void)
{
    char **includes=NULL;
    bool dumpit=false;
    int i, j;

    if (opal_output_get_verbosity(opal_event_base_framework.framework_output) > 4) {
        event_enable_debug_mode();
        dumpit = true;
    }

    if (NULL == event_module_include) {
        /* Shouldn't happen, but... */
        event_module_include = strdup("select");
    }
    includes = opal_argv_split(event_module_include,',');

    /* get a configuration object */
    config = event_config_new();
    /* cycle thru the available subsystems */
    for (i = 0 ; NULL != eventops[i] ; ++i) {
        /* if this module isn't included in the given ones,
         * then exclude it
         */
        dumpit = true;
        for (j=0; NULL != includes[j]; j++) {
            if (0 == strcmp("all", includes[j]) ||
                0 == strcmp(eventops[i]->name, includes[j])) {
                dumpit = false;
                break;
            }
        }
        if (dumpit) {
            event_config_avoid_method(config, eventops[i]->name);
        }
    }
    opal_argv_free(includes);

    return OPAL_SUCCESS;
}
Exemplo n.º 26
0
static void
add_extra_includes(const char *includes, const char* includedir)
{
    int i;
    char **values = opal_argv_split(includes, ' ');

    for (i = 0 ; i < opal_argv_count(values) ; ++i) {
        char *line, *include_directory;

        include_directory = opal_os_path(false, includedir, values[i], NULL);

#if defined(__WINDOWS__)
        asprintf(&line, OPAL_INCLUDE_FLAG"\"%s\"", include_directory);
#else
        asprintf(&line, OPAL_INCLUDE_FLAG"%s", include_directory);
#endif  /* defined(__WINDOWS__) */

        opal_argv_append_nosize(&options_data[parse_options_idx].preproc_flags, line);
        free(include_directory);
        free(line);
    }
}
Exemplo n.º 27
0
static bool test6(void)
{
  char *a = "the quick brown fox jumped over the lazy dog a_really_long_argument_to_force_a_long_copy_zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
  char **b;
  char *c;

  /* split the string above and then join it -- the joined version
     should be just like the original */

  b = opal_argv_split(a, ' ');
  c = opal_argv_join(b, ' ');

  if (strcmp(a, c) != 0) {
    return false;
  }

  /* All done */

  free(c);
  opal_argv_free(b);
  return true;
}
Exemplo n.º 28
0
static void
options_data_expand(const char *value)
{
    /* make space for the new set of args */
    parse_options_idx++;
    options_data = (struct options_data_t *) realloc(options_data, sizeof(struct options_data_t) * (parse_options_idx + 1));
    options_data_init(&(options_data[parse_options_idx]));

    /* if there are values, this is not the default case.
       Otherwise, it's the default case... */
    if (NULL != value && 0 != strcmp(value, "")) {
        char **values = opal_argv_split(value, ';');
        opal_argv_insert(&(options_data[parse_options_idx].compiler_args),
                         opal_argv_count(options_data[parse_options_idx].compiler_args),
                         values);
        opal_argv_free(values);
    } else {
        free(options_data[parse_options_idx].compiler_args);
        options_data[parse_options_idx].compiler_args = NULL;
        /* this is a default */
        default_data_idx = parse_options_idx;
    }
}
Exemplo n.º 29
0
static void
load_env_data_argv(const char *project, const char *flag, char ***data)
{
    char *envname;
    char *envvalue;

    if (NULL == project || NULL == flag) return;

    asprintf(&envname, "%s_MPI%s", project, flag);
    if (NULL == (envvalue = getenv(envname))) {
        free(envname);
        asprintf(&envname, "%s_%s", project, flag);
        if (NULL == (envvalue = getenv(envname))) {
            free(envname);
            return;
        }
    } 
    free(envname);

    if (NULL != *data) opal_argv_free(*data);

    *data = opal_argv_split(envvalue, ' ');
}
Exemplo n.º 30
0
static char* get_node_list(orte_app_context_t *app)
{
    int j;
    char **total_host = NULL;
    char *nodes;
    char **dash_host, *dh;

    if (!orte_get_attribute(&app->attributes, ORTE_APP_DASH_HOST, (void**)&dh, OPAL_STRING)) {
        return NULL;
    }
    dash_host = opal_argv_split(dh, ',');
    free(dh);
    for (j=0; NULL != dash_host[j]; j++) {
        opal_argv_append_unique_nosize(&total_host, dash_host[j], false);
    }
    opal_argv_free(dash_host);
    if (NULL == total_host) {
        return NULL;
    }

    nodes = opal_argv_join(total_host, ',');
    opal_argv_free(total_host);
    return nodes;
}