当前位置: 首页>>代码示例>>C++>>正文


C++ opal_argv_count函数代码示例

本文整理汇总了C++中opal_argv_count函数的典型用法代码示例。如果您正苦于以下问题:C++ opal_argv_count函数的具体用法?C++ opal_argv_count怎么用?C++ opal_argv_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了opal_argv_count函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test8

static bool test8(void)
{
  char *a[] = { "aaa", "bbbbbbbb", "cccccccccc", NULL };
  int i;
  char **b;

  /* bozo case */

  if (NULL != opal_argv_copy(NULL)) {
    return false;
  }

  /* dup the a array and compare it (array length, contents, etc.) */

  b = opal_argv_copy(a);

  if (opal_argv_count(a) != opal_argv_count(b)) {
    return false;
  }
  for (i = 0; a[i] != NULL; ++i) {
    if (0 != strcmp(a[i], b[i])) {
      return false;
    }
  }

  /* All done */

  opal_argv_free(b);
  return true;
}
开发者ID:00datman,项目名称:ompi,代码行数:30,代码来源:opal_argv.c

示例2: opal_paffinity_base_slot_list_set

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;
}
开发者ID:315234,项目名称:OpenFOAM-2.2.x-OSX,代码行数:58,代码来源:paffinity_base_service.c

示例3: orte_rmgr_base_size_app_context

/*
 * APP CONTEXT
 */
int orte_rmgr_base_size_app_context(size_t *size, orte_app_context_t *src, orte_data_type_t type)
{
    int j, rc, count;
    orte_std_cntr_t i;
    size_t map_size;

    /* account for the object itself */
    *size = sizeof(orte_app_context_t);

    /* if src is NULL, then that's all we wanted */
    if (NULL == src) return ORTE_SUCCESS;

    if (NULL != src->app) {
        *size += strlen(src->app);
    }

    count = opal_argv_count(src->argv);
    if (0 < count) {
        /* account for array of char* */
        *size += count * sizeof(char*);
        for (j=0; j < count; j++) {
            *size += strlen(src->argv[j]);
        }
    }
    *size += sizeof(char**);  /* account for size of the argv pointer itself */

    count = opal_argv_count(src->env);
    if (0 < count) {
        /* account for array of char* */
        *size += count * sizeof(char*);
        for (i=0; i < count; i++) {
            *size += strlen(src->env[i]);
        }
    }
    *size += sizeof(char**);  /* account for size of the env pointer itself */

    if (NULL != src->cwd) {
        *size += strlen(src->cwd);  /* working directory */
    }

    if (0 < src->num_map) {
        for (i=0; i < src->num_map; i++) {
            if (ORTE_SUCCESS != (rc = orte_rmgr_base_size_app_context_map(&map_size, src->map_data[i], ORTE_APP_CONTEXT_MAP))) {
                ORTE_ERROR_LOG(rc);
                *size = 0;
                return rc;
            }
        }
    }

    if (NULL != src->prefix_dir) {
        *size += strlen(src->prefix_dir);
    }

    return ORTE_SUCCESS;
}
开发者ID:aosm,项目名称:openmpi,代码行数:59,代码来源:rmgr_data_type_size_fns.c

示例4: opal_argv_insert

int opal_argv_insert(char ***target, int start, char **source)
{
    int i, source_count, target_count;
    int suffix_count;

    /* Check for the bozo cases */

    if (NULL == target || NULL == *target || start < 0) {
        return OPAL_ERR_BAD_PARAM;
    } else if (NULL == source) {
        return OPAL_SUCCESS;
    }

    /* Easy case: appending to the end */

    target_count = opal_argv_count(*target);
    source_count = opal_argv_count(source);
    if (start > target_count) {
        for (i = 0; i < source_count; ++i) {
            opal_argv_append(&target_count, target, source[i]);
        }
    }

    /* Harder: insertting into the middle */

    else {

        /* Alloc out new space */

        *target = (char**) realloc(*target,
                                   sizeof(char *) * (target_count + source_count + 1));

        /* Move suffix items down to the end */

        suffix_count = target_count - start;
        for (i = suffix_count - 1; i >= 0; --i) {
            (*target)[start + source_count + i] =
                (*target)[start + i];
        }
        (*target)[start + suffix_count + source_count] = NULL;

        /* Strdup in the source argv */

        for (i = start; i < start + source_count; ++i) {
            (*target)[i] = strdup(source[i - start]);
        }
    }

    /* All done */

    return OPAL_SUCCESS;
}
开发者ID:jimmycao,项目名称:zautotools,代码行数:52,代码来源:argv.c

示例5: orte_dt_print_app_context

/*
 * APP CONTEXT
 */
int orte_dt_print_app_context(char **output, char *prefix, orte_app_context_t *src, opal_data_type_t type)
{
    char *tmp, *tmp2, *pfx2;
    int i, count;
    
    /* set default result */
    *output = NULL;
    
    /* protect against NULL prefix */
    if (NULL == prefix) {
        asprintf(&pfx2, " ");
    } else {
        asprintf(&pfx2, "%s", prefix);
    }
    
    asprintf(&tmp, "\n%sData for app_context: index %lu\tapp: %s\n%s\tNum procs: %lu",
             pfx2, (unsigned long)src->idx, src->app,
             pfx2, (unsigned long)src->num_procs);
    
    count = opal_argv_count(src->argv);
    for (i=0; i < count; i++) {
        asprintf(&tmp2, "%s\n%s\tArgv[%d]: %s", tmp, pfx2, i, src->argv[i]);
        free(tmp);
        tmp = tmp2;
    }
    
    count = opal_argv_count(src->env);
    for (i=0; i < count; i++) {
        asprintf(&tmp2, "%s\n%s\tEnv[%lu]: %s", tmp, pfx2, (unsigned long)i, src->env[i]);
        free(tmp);
        tmp = tmp2;
    }
    
    asprintf(&tmp2, "%s\n%s\tWorking dir: %s (user: %d)\n%s\tHostfile: %s\tAdd-Hostfile: %s", tmp, pfx2, src->cwd, (int) src->user_specified_cwd,
             pfx2, (NULL == src->hostfile) ? "NULL" : src->hostfile,
             (NULL == src->add_hostfile) ? "NULL" : src->add_hostfile);
    free(tmp);
    tmp = tmp2;
    
    count = opal_argv_count(src->dash_host);
    for (i=0; i < count; i++) {
        asprintf(&tmp2, "%s\n%s\tDash_host[%lu]: %s", tmp, pfx2, (unsigned long)i, src->dash_host[i]);
        free(tmp);
        tmp = tmp2;
    }
    
    /* set the return */
    *output = tmp;
    
    free(pfx2);
    return ORTE_SUCCESS;
}
开发者ID:hpc,项目名称:cce-mpi-openmpi-1.4.3,代码行数:55,代码来源:orte_dt_print_fns.c

示例6: opal_argv_prepend_nosize

/**
 * ================================
 * char **str_array_pt = NULL;

	char *str1 = "hello";
	char *str2 = "haha";
	opal_argv_prepend_nosize(&str_array_pt, str1);
	opal_argv_prepend_nosize(&str_array_pt, str2);

	while(*str_array_pt)
		puts(*str_array_pt++);
 * ===============================-
 * haha
   hello
 *
 */
int opal_argv_prepend_nosize(char ***argv, const char *arg)
{
    int argc;
    int i;

    /* Create new argv. */

    if (NULL == *argv) {
        *argv = (char**) malloc(2 * sizeof(char *));
        if (NULL == *argv) {
            return OPAL_ERR_OUT_OF_RESOURCE;
        }
        (*argv)[0] = strdup(arg);
        (*argv)[1] = NULL;
    } else {
        /* count how many entries currently exist */
        argc = opal_argv_count(*argv);

        *argv = (char**) realloc(*argv, (argc + 2) * sizeof(char *));
        if (NULL == *argv) {
            return OPAL_ERR_OUT_OF_RESOURCE;
        }
        (*argv)[argc+1] = NULL;

        /* shift all existing elements down 1 */
        for (i=argc; 0 < i; i--) {
            (*argv)[i] = (*argv)[i-1];
        }
        (*argv)[0] = strdup(arg);
    }

    return OPAL_SUCCESS;
}
开发者ID:jimmycao,项目名称:zautotools,代码行数:49,代码来源:argv.c

示例7: check_sanity

static void check_sanity(char ***if_sanity_list, const char *dev_name, int port)
{
    int i;
    char tmp[BUFSIZ], **list;
    const char *compare;

    if (NULL == if_sanity_list || NULL == *if_sanity_list) {
        return;
    }
    list = *if_sanity_list;

    /* A match is found if:
       - "dev_name" is in the list and port == -1, or
       - "dev_name:port" is in the list
       If a match is found, remove that entry from the list. */
    memset(tmp, 0, sizeof(tmp));
    if (port > 0) {
        snprintf(tmp, sizeof(tmp) - 1, "%s:%d", dev_name, port);
        compare = tmp;
    } else {
        compare = dev_name;
    }

    for (i = 0; NULL != list[i]; ++i) {
        if (0 == strcmp(list[i], compare)) {
            int count = opal_argv_count(list);
            opal_argv_delete(&count, &list, i, 1);
            *if_sanity_list = list;
            --i;
        }
    }
}
开发者ID:00datman,项目名称:ompi,代码行数:32,代码来源:common_verbs_find_ports.c

示例8: get_slurm_nodename

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;
}
开发者ID:aosm,项目名称:openmpi,代码行数:31,代码来源:sds_slurm_module.c

示例9: get_slurm_nodename

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;
}
开发者ID:315234,项目名称:OpenFOAM-2.2.x-OSX,代码行数:31,代码来源:ess_slurm_module.c

示例10: output

/*
 * Make one big string with all the lines.  This isn't the most
 * efficient method in the world, but we're going for clarity here --
 * not optimization.  :-)
 */
static int output(bool want_error_header, char **lines,
                  const char *base, const char *topic,
                  va_list arglist)
{
    int i, count;
    size_t len;
    char *concat;

    /* See how much space we need */

    len = want_error_header ? 2 * strlen(dash_line) : 0;
    count = opal_argv_count(lines);
    for (i = 0; i < count; ++i) {
        if (NULL == lines[i]) {
            break;
        }
        len += strlen(lines[i]) + 1;
    }

    /* Malloc it out */

    concat = (char*) malloc(len + 1);
    if (NULL == concat) {
        fprintf(stderr, dash_line);
        fprintf(stderr, "Sorry!  You were supposed to get help about:\n    %s\nfrom the file:\n    %s\n", topic, base);
        fprintf(stderr, "But memory seems to be exhausted.  Sorry!\n");
        fprintf(stderr, dash_line);
        return OPAL_ERR_OUT_OF_RESOURCE;
    }

    /* Fill the big string */

    *concat = '\0';
    if (want_error_header) {
        strcat(concat, dash_line);
    }
    for (i = 0; i < count; ++i) {
        if (NULL == lines[i]) {
            break;
        }
        strcat(concat, lines[i]);
        strcat(concat, "\n");
    }
    if (want_error_header) {
        strcat(concat, dash_line);
    }

    /* Apply formatting */
    vfprintf( stderr, concat, arglist );

    /* All done */

    free(concat);
    return OPAL_SUCCESS;
}
开发者ID:aosm,项目名称:openmpi,代码行数:60,代码来源:show_help.c

示例11: workflow_add_send_workflow

static int workflow_add_send_workflow(opal_buffer_t *buf, char **aggregator)
{
    orte_process_name_t wf_agg;
    orte_rml_recv_cb_t *xfer = NULL;
    int rc;
    int node_index;

    for (node_index = 0; node_index < opal_argv_count(aggregator); node_index++) {

        xfer = OBJ_NEW(orte_rml_recv_cb_t);
        if (NULL == xfer) {
            return ORCM_ERR_OUT_OF_RESOURCE;
        }

        workflow_output_setup(xfer);

        OBJ_RETAIN(buf);

        if (ORCM_SUCCESS != (rc = orcm_cfgi_base_get_hostname_proc(aggregator[node_index],
                                                                   &wf_agg))) {
            orcm_octl_error("node-notfound", aggregator[node_index]);
            orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORCM_RML_TAG_ANALYTICS);
            SAFE_RELEASE(xfer);
            return rc;
        }

        rc = workflow_send_buffer(&wf_agg, buf, xfer);
        if (ORCM_SUCCESS != rc) {
            orcm_octl_error("connection-fail");
            orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORCM_RML_TAG_ANALYTICS);
            SAFE_RELEASE(xfer);
            return rc;
        }

        /* unpack workflow id */
        ORCM_WAIT_FOR_COMPLETION(xfer->active, ORCM_OCTL_WAIT_TIMEOUT, &rc);
        if (ORCM_SUCCESS != rc) {
            orcm_octl_error("connection-fail");
            orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORCM_RML_TAG_ANALYTICS);
            SAFE_RELEASE(xfer);
            return rc;
        }

        rc = workflow_add_unpack_buffer(xfer);
        if (ORCM_SUCCESS != rc) {
            orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORCM_RML_TAG_ANALYTICS);
            SAFE_RELEASE(xfer);
            return rc;
        }
        orte_rml.recv_cancel(ORTE_NAME_WILDCARD, ORCM_RML_TAG_ANALYTICS);
        SAFE_RELEASE(xfer);
    }
    return ORCM_SUCCESS;
}
开发者ID:intel-ctrlsys,项目名称:sensys,代码行数:54,代码来源:workflow.c

示例12: rte_init

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;
}
开发者ID:315234,项目名称:OpenFOAM-2.2.x-OSX,代码行数:53,代码来源:ess_portals_utcp_module.c

示例13: orte_plm_poe_component_open

/**
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;
}
开发者ID:bringhurst,项目名称:ompi,代码行数:56,代码来源:plm_poe_component.c

示例14: find_options_index

static int
find_options_index(const char *arg)
{
    int i, j;
#ifdef HAVE_REGEXEC
    int args_count;
    regex_t res;
#endif

    for (i = 0 ; i <= parse_options_idx ; ++i) {
        if (NULL == options_data[i].compiler_args) {
            continue;
        }

#ifdef HAVE_REGEXEC
        args_count = opal_argv_count(options_data[i].compiler_args);
        for (j = 0 ; j < args_count ; ++j) {
            if (0 != regcomp(&res, options_data[i].compiler_args[j], REG_NOSUB)) {
                return -1;
            }

            if (0 == regexec(&res, arg, (size_t) 0, NULL, 0)) {
                regfree(&res);
                return i;
            }

            regfree(&res);
        }
#else
        for (j = 0 ; j < opal_argv_count(options_data[i].compiler_args) ; ++j) {
            if (0 == strcmp(arg, options_data[i].compiler_args[j])) {
                return i;
            }
        }
#endif
    }

    return -1;
}
开发者ID:hpc,项目名称:cce-mpi-openmpi-1.4.3,代码行数:39,代码来源:opal_wrapper.c

示例15: opal_argv_append

/*
 * Append a string to the end of a new or existing argv array.
 * =====================================
 * char **str_array_pt = NULL;
	int argc;
	char *str1 = "hello";
	char *str2 = "haha";
	opal_argv_append(&argc, &str_array_pt, str1);
	opal_argv_append(&argc, &str_array_pt, str2);

	while(*str_array_pt)
		puts(*str_array_pt++);
	printf("argc = %d\n", argc);
 * =====================================
 * 	hello
	haha
	argc = 2
 */
int opal_argv_append(int *argc, char ***argv, const char *arg)
{
    int rc;

    /* add the new element */
    if (OPAL_SUCCESS != (rc = opal_argv_append_nosize(argv, arg))) {
        return rc;
    }

    *argc = opal_argv_count(*argv);

    return OPAL_SUCCESS;
}
开发者ID:jimmycao,项目名称:zautotools,代码行数:31,代码来源:argv.c


注:本文中的opal_argv_count函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。