您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xbt_dynar_length函数代码示例

51自学网 2021-06-03 10:15:27
  C++
这篇教程C++ xbt_dynar_length函数代码示例写得很实用,希望能帮到您。

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

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

示例1: Java_org_simgrid_msg_Msg_run

JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls){  /* Run everything */  XBT_DEBUG("Ready to run MSG_MAIN");  msg_error_t rv = MSG_main();  XBT_DEBUG("Done running MSG_MAIN");  jxbt_check_res("MSG_main()", rv, MSG_OK,                 xbt_strdup("unexpected error : MSG_main() failed .. please report this bug "));  XBT_INFO("MSG_main finished; Cleaning up the simulation...");  /* Cleanup java hosts */  xbt_dynar_t hosts = MSG_hosts_as_dynar();  for (unsigned long index = 0; index < xbt_dynar_length(hosts) - 1; index++) {    msg_host_t msg_host = xbt_dynar_get_as(hosts,index,msg_host_t);    jobject jhost = (jobject) msg_host->extension(JAVA_HOST_LEVEL);    if (jhost)      jhost_unref(env, jhost);  }  xbt_dynar_free(&hosts);  /* Cleanup java storages */  xbt_dynar_t storages = MSG_storages_as_dynar();  if(!xbt_dynar_is_empty(storages)){    for (unsigned long index = 0; index < xbt_dynar_length(storages) - 1; index++) {      jobject jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);      if (jstorage)        jstorage_unref(env, jstorage);    }  }  xbt_dynar_free(&storages);}
开发者ID:oar-team,项目名称:simgrid-batsim,代码行数:32,


示例2: xbt_dynar_length

/** /brief Insert /e data under all the keys contained in /e keys, providing their sizes in /e lens. * * /arg mdict: the multi-dict * /arg keys: dynar of (char *) containing all the keys * /arg lens: length of each element of /e keys * /arg data: where to put what was found in structure * /arg free_ctn: function to use to free the pushed content on need * * Dynars are not modified during the operation. */void *xbt_multidict_get_ext(xbt_dict_t mdict,                            xbt_dynar_t keys, xbt_dynar_t lens){  xbt_dict_t thislevel, nextlevel;  int i;  unsigned long int thislen;  char *thiskey;  int keys_len = xbt_dynar_length(keys);  xbt_assert(xbt_dynar_length(keys) == xbt_dynar_length(lens));  xbt_assert(!xbt_dynar_is_empty(keys),              "Can't get a zero-long key set in a multidict");  XBT_DEBUG("xbt_multidict_get(%p, %ld)", mdict, xbt_dynar_length(keys));  for (i = 0, thislevel = mdict; i < keys_len - 1;       i++, thislevel = nextlevel) {    xbt_dynar_get_cpy(keys, i, &thiskey);    xbt_dynar_get_cpy(lens, i, &thislen);    XBT_DEBUG("multi_get: at level %d (%p), len=%ld, key=%p |%*s|",           i, thislevel, thislen, thiskey, (int) thislen, thiskey);    /* search the dict of next level: let mismatch raise if not found */    nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen);  }  xbt_dynar_get_cpy(keys, i, &thiskey);  xbt_dynar_get_cpy(lens, i, &thislen);  return xbt_dict_get_ext(thislevel, thiskey, thislen);}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:44,


示例3: find_active_VMs_to_stop

/* Build the set of hosts/VMs that have to be terminated. This function selects how_many VMs from the source set of * candidates. * Remark: In the paper by Malawski et al., no details are provided about how the VMs are selected in the source set. * Moreover, there is no check w.r.t. the size of the source set. * Assumptions: * 1) If the source set is too small, display a warning and return a smaller set than expected. * 2) Straightforward selection of the VMs in the set. Just pick the how_many first ones without any consideration of *    the time remaining until the next hourly billing cycle. Just check if the VM is not currently executing a task */xbt_dynar_t find_active_VMs_to_stop(int how_many, xbt_dynar_t source){  int i, found;  long unsigned int source_size = xbt_dynar_length(source);  xbt_dynar_t to_stop = xbt_dynar_new(sizeof(sg_host_t), NULL);  sg_host_t v;  if (how_many > source_size){    XBT_WARN("Trying to terminate more VMs than what is available (%d > %lu)."        " Change the number of VMs to terminate to %lu", how_many, source_size, source_size);    how_many = source_size;  }  i = 0;  found = 0;  while(found < how_many && i < xbt_dynar_length(source)){    /* No advanced selection process. Just pick the how_many first idle VMs in the source set. */    xbt_dynar_get_cpy(source, i, &v);    HostAttribute attr = sg_host_user(v);    if (!attr->idle_busy){      xbt_dynar_push(to_stop, &v);      found++;    }    i++;  }  if (found < how_many)    XBT_WARN("Trying to terminate too many VMs, some are busy... Change the number of VMs to terminate to %d", found);  return to_stop;}
开发者ID:frs69wq,项目名称:EnsembleSched,代码行数:40,


示例4: xbt_dynar_compare

/** @brief Compare two dynars * *  /param d1 first dynar to compare *  /param d2 second dynar to compare *  /param compar function to use to compare elements *  /return 0 if d1 and d2 are equal and 1 if not equal * *  d1 and d2 should be dynars of pointers. The compar function takes two  elements and returns 0 when they are *  considered equal, and a value different of zero when they are considered different. Finally, d2 is destroyed *  afterwards. */int xbt_dynar_compare(xbt_dynar_t d1, xbt_dynar_t d2, int(*compar)(const void *, const void *)){  int i ;  int size;  if((!d1) && (!d2)) return 0;  if((!d1) || (!d2))  {    XBT_DEBUG("NULL dynar d1=%p d2=%p",d1,d2);    xbt_dynar_free(&d2);    return 1;  }  if((d1->elmsize)!=(d2->elmsize)) {    XBT_DEBUG("Size of elmsize d1=%lu d2=%lu",d1->elmsize,d2->elmsize);    xbt_dynar_free(&d2);    return 1; // xbt_die  }  if(xbt_dynar_length(d1) != xbt_dynar_length(d2)) {    XBT_DEBUG("Size of dynar d1=%lu d2=%lu",xbt_dynar_length(d1),xbt_dynar_length(d2));    xbt_dynar_free(&d2);    return 1;  }  size = xbt_dynar_length(d1);  for(i=0;i<size;i++) {    void *data1 = xbt_dynar_get_as(d1, i, void *);    void *data2 = xbt_dynar_get_as(d2, i, void *);    XBT_DEBUG("link[%d] d1=%p d2=%p",i,data1,data2);    if(compar(data1,data2)){      xbt_dynar_free(&d2);      return 1;    }  }  xbt_dynar_free(&d2);  return 0;}
开发者ID:R7R8,项目名称:simgrid,代码行数:46,


示例5: main

int main(int argc, char **argv){  double comm_cost[] = { 0.0, 0.0, 0.0, 0.0 };  double comp_cost[] = { 1.0 };  SD_task_t taskA, taskB;  xbt_dynar_t ret;  SD_init(&argc, argv);  SD_create_environment(argv[1]);  taskA = SD_task_create("Task A", NULL, 1.0);  taskB = SD_task_create("Task B", NULL, 1.0);  SD_task_schedule(taskA, 1, SD_workstation_get_list(), comp_cost,                   comm_cost, -1.0);  SD_task_schedule(taskB, 1, SD_workstation_get_list(), comp_cost,                   comm_cost, -1.0);  ret = SD_simulate(-1.0);  xbt_assert(xbt_dynar_length(ret) == 2,      "I was expecting the terminaison of 2 tasks, but I got %lu instead",      xbt_dynar_length(ret));  xbt_dynar_free(&ret);  SD_task_destroy(taskA);  SD_task_destroy(taskB);  XBT_INFO("Simulation time: %f", SD_get_clock());  SD_exit();  return 0;}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:31,


示例6: xbt_dynar_new

/* Business methods */xbt_dynar_t AsFloyd::getOneLinkRoutes(){  xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f);  sg_platf_route_cbarg_t route =   xbt_new0(s_sg_platf_route_cbarg_t, 1);  route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);  int src,dst;  sg_routing_edge_t src_elm, dst_elm;  int table_size = xbt_dynar_length(p_indexNetworkElm);  for(src=0; src < table_size; src++) {    for(dst=0; dst< table_size; dst++) {      xbt_dynar_reset(route->link_list);      src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdgePtr);      dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdgePtr);      this->getRouteAndLatency(src_elm, dst_elm, route, NULL);      if (xbt_dynar_length(route->link_list) == 1) {        void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);        OnelinkPtr onelink;        if (p_hierarchy == SURF_ROUTING_BASE)          onelink = new Onelink(link, src_elm, dst_elm);        else if (p_hierarchy == SURF_ROUTING_RECURSIVE)          onelink = new Onelink(link, route->gw_src, route->gw_dst);        else          onelink = new Onelink(link, NULL, NULL);        xbt_dynar_push(ret, &onelink);      }    }  }  return ret;}
开发者ID:FlorianPO,项目名称:simgrid,代码行数:33,


示例7: xbt_dict_dump_sizes

/** @brief shows some debugging info about the bucklet repartition */void xbt_dict_dump_sizes(xbt_dict_t dict){    int i;    unsigned int count;    unsigned int size;    xbt_dictelm_t element;    xbt_dynar_t sizes = xbt_dynar_new(sizeof(int), NULL);    printf("Dict %p: %d bucklets, %d used cells (of %d) ", dict, dict->count,           dict->fill, dict->table_size);    if (dict != NULL) {        for (i = 0; i < dict->table_size; i++) {            element = dict->table[i];            size = 0;            if (element) {                while (element != NULL) {                    size++;                    element = element->next;                }            }            if (xbt_dynar_length(sizes) <= size) {                int prevsize = 1;                xbt_dynar_set(sizes, size, &prevsize);            } else {                int prevsize;                xbt_dynar_get_cpy(sizes, size, &prevsize);                prevsize++;                xbt_dynar_set(sizes, size, &prevsize);            }        }        if (!all_sizes)            all_sizes = xbt_dynar_new(sizeof(int), NULL);        xbt_dynar_foreach(sizes, count, size) {            /* Copy values of this one into all_sizes */            int prevcount;            if (xbt_dynar_length(all_sizes) <= count) {                prevcount = size;                xbt_dynar_set(all_sizes, count, &prevcount);            } else {                xbt_dynar_get_cpy(all_sizes, count, &prevcount);                prevcount += size;                xbt_dynar_set(all_sizes, count, &prevcount);            }            /* Report current sizes */            if (count == 0)                continue;            if (size == 0)                continue;            printf("%uelm x %u cells; ", count, size);        }    }
开发者ID:apargupta,项目名称:simgrid,代码行数:55,


示例8: malloc

inline unsigned int *rankId_to_coords(int rankId, xbt_dynar_t dimensions){  unsigned int i = 0, cur_dim_size = 1, dim_size_product = 1;  unsigned int *coords = (unsigned int *) malloc(xbt_dynar_length(dimensions) * sizeof(unsigned int));  for (i = 0; i < xbt_dynar_length(dimensions); i++) {    cur_dim_size = xbt_dynar_get_as(dimensions, i, int);    coords[i] = (rankId / dim_size_product) % cur_dim_size;    dim_size_product *= cur_dim_size;  }  return coords;}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:13,


示例9: action_finalize

static void action_finalize(const char *const *action){  smpi_replay_globals_t globals =      (smpi_replay_globals_t) smpi_process_get_user_data();  if (globals){    XBT_DEBUG("There are %lu isends and %lu irecvs in the dynars",         xbt_dynar_length(globals->isends),xbt_dynar_length(globals->irecvs));    xbt_dynar_free_container(&(globals->isends));    xbt_dynar_free_container(&(globals->irecvs));  }  free(globals);}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:13,


示例10: Seal

void AsFull::Seal() {  int i;  sg_platf_route_cbarg_t e_route;  /* set utils vars */  int table_size = (int)xbt_dynar_length(vertices_);  /* Create table if necessary */  if (!routingTable_)    routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);  /* Add the loopback if needed */  if (routing_platf->loopback_ && hierarchy_ == RoutingMode::base) {    for (i = 0; i < table_size; i++) {      e_route = TO_ROUTE_FULL(i, i);      if (!e_route) {        e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);        e_route->gw_src = NULL;        e_route->gw_dst = NULL;        e_route->link_list = new std::vector<Link*>();        e_route->link_list->push_back(routing_platf->loopback_);        TO_ROUTE_FULL(i, i) = e_route;      }    }  }}
开发者ID:adegomme,项目名称:simgrid,代码行数:26,


示例11: suspend

void BoostSerialContext::suspend(){  /* determine the next context */  BoostSerialContext* next_context = nullptr;  unsigned long int i = process_index_++;  if (i < xbt_dynar_length(simix_global->process_to_run)) {    /* execute the next process */    XBT_DEBUG("Run next process");    next_context = static_cast<BoostSerialContext*>(xbt_dynar_get_as(        simix_global->process_to_run, i, smx_process_t)->context);  }  else {    /* all processes were run, return to maestro */    XBT_DEBUG("No more process to run");    next_context = static_cast<BoostSerialContext*>(      maestro_context_);  }  SIMIX_context_set_current((smx_context_t) next_context);  #if HAVE_BOOST_CONTEXTS == 1  boost::context::jump_fcontext(    this->fc_, next_context->fc_, (intptr_t) next_context);  #else  boost::context::jump_fcontext(    &this->fc_, next_context->fc_, (intptr_t) next_context);  #endif}
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:27,


示例12: parse_factor

static xbt_dynar_t parse_factor(const char *smpi_coef_string){  char *value = NULL;  unsigned int iter = 0;  s_smpi_factor_t fact;  xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL;  smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL);  radical_elements = xbt_str_split(smpi_coef_string, ";");  xbt_dynar_foreach(radical_elements, iter, value) {    radical_elements2 = xbt_str_split(value, ":");    surf_parse_assert(xbt_dynar_length(radical_elements2) == 2,        "Malformed radical '%s' for smpi factor. I was expecting something like 'a:b'", value);    char *errmsg = bprintf("Invalid factor in chunk #%d: %%s", iter+1);    fact.factor = xbt_str_parse_int(xbt_dynar_get_as(radical_elements2, 0, char *), errmsg);    xbt_free(errmsg);    fact.value = xbt_str_parse_double(xbt_dynar_get_as(radical_elements2, 1, char *), errmsg);    errmsg = bprintf("Invalid factor value in chunk #%d: %%s", iter+1);    xbt_free(errmsg);    xbt_dynar_push_as(smpi_factor, s_smpi_factor_t, fact);    XBT_DEBUG("smpi_factor:/t%ld : %f", fact.factor, fact.value);    xbt_dynar_free(&radical_elements2);  }
开发者ID:adegomme,项目名称:simgrid,代码行数:26,


示例13: main

int main(int argc, char **argv){  int i;  msg_error_t res = MSG_OK;  MSG_init(&argc, argv);  surf_parse = surf_parse_bypass_platform;  MSG_create_environment(NULL);  MSG_function_register("host", host);  xbt_dynar_t hosts = MSG_hosts_as_dynar();  nb_hosts =  xbt_dynar_length(hosts);  XBT_INFO("Number of host '%d'",nb_hosts);  for(i = 0 ; i<nb_hosts; i++)  {    char* name_host = bprintf("%d",i);    MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t) );    free(name_host);  }  xbt_dynar_free(&hosts);  res = MSG_main();  XBT_INFO("Simulation time %g", MSG_get_clock());  if (res == MSG_OK)    return 0;  else    return 1;}
开发者ID:tempbottle,项目名称:simgrid,代码行数:32,


示例14: smx_ctx_boost_suspend_serial

static void smx_ctx_boost_suspend_serial(smx_context_t context){  /* determine the next context */  smx_ctx_boost_t next_context;  unsigned long int i = boost_process_index++;  if (i < xbt_dynar_length(simix_global->process_to_run)) {    /* execute the next process */    XBT_DEBUG("Run next process");    next_context = (smx_ctx_boost_t) xbt_dynar_get_as(        simix_global->process_to_run, i, smx_process_t)->context;  }  else {    /* all processes were run, return to maestro */    XBT_DEBUG("No more process to run");    next_context = (smx_ctx_boost_t) boost_maestro_context;  }  SIMIX_context_set_current((smx_context_t) next_context);#if HAVE_BOOST_CONTEXT == 1  boost::context::jump_fcontext(    ((smx_ctx_boost_t)context)->fc, next_context->fc, (intptr_t)next_context);#else  boost::context::jump_fcontext(    &((smx_ctx_boost_t)context)->fc, next_context->fc, (intptr_t)next_context);#endif}
开发者ID:apargupta,项目名称:simgrid,代码行数:26,


示例15: main

int main(int argc, char **argv){  int i,res;  MSG_init(&argc, argv);  MSG_create_environment(argv[1]);  xbt_dynar_t hosts =  MSG_hosts_as_dynar();  MSG_function_register("host", host);  unsigned long nb_hosts = xbt_dynar_length(hosts);  XBT_INFO("Number of host '%lu'",nb_hosts);  for(i = 0 ; i<nb_hosts; i++)  {    char* name_host = bprintf("%d",i);    MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t) );    free(name_host);  }  xbt_dynar_free(&hosts);  res = MSG_main();  XBT_INFO("Simulation time %g", MSG_get_clock());  if (res == MSG_OK)    return 0;  else    return 1;}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:25,


示例16: smx_ctx_cojava_suspend

static void smx_ctx_cojava_suspend(smx_context_t context){  smx_context_t previous_context = context;  unsigned long int i = cojava_process_index++;  jobject next_coroutine;  if (i < xbt_dynar_length(cojava_processes)) {    smx_context_t next_context = SIMIX_process_get_context(xbt_dynar_get_as(    cojava_processes,i, smx_process_t));    my_current_context = next_context;    XBT_DEBUG("Switching to %p",my_current_context);    smx_ctx_cojava_t java_context = (smx_ctx_cojava_t)(next_context);    if (!java_context->jprocess) {      java_context->super.code(java_context->super.argc, java_context->super.argv);      smx_ctx_cojava_create_coroutine(java_context);    }    else if (!java_context->bound) {      java_context->bound = 1;      smx_process_t process = SIMIX_process_self();      (*global_env)->SetLongField(global_env, java_context->jprocess,                                  jprocess_field_Process_bind,                                  (intptr_t)process);    }    next_coroutine = java_context->jcoroutine;  }  else {    //Give maestro the control back.    next_coroutine = cojava_maestro_coroutine;    my_current_context = maestro_context;  }  (*global_env)->CallStaticVoidMethod(global_env, coclass, coroutine_yieldTo, next_coroutine);  my_current_context = previous_context;}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:34,


示例17: action_wait

static void action_wait(const char *const *action){  double clock = smpi_process_simulated_elapsed();  MPI_Request request;  MPI_Status status;  smpi_replay_globals_t globals =      (smpi_replay_globals_t) smpi_process_get_user_data();  xbt_assert(xbt_dynar_length(globals->irecvs),      "action wait not preceded by any irecv: %s",      xbt_str_join_array(action," "));  request = xbt_dynar_pop_as(globals->irecvs,MPI_Request);#ifdef HAVE_TRACING  int rank = request && request->comm != MPI_COMM_NULL      ? smpi_comm_rank(request->comm)      : -1;  TRACE_smpi_computing_out(rank);  MPI_Group group = smpi_comm_group(request->comm);  int src_traced = smpi_group_rank(group, request->src);  int dst_traced = smpi_group_rank(group, request->dst);  int is_wait_for_receive = request->recv;  TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);#endif  smpi_mpi_wait(&request, &status);#ifdef HAVE_TRACING  TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);  if (is_wait_for_receive) {    TRACE_smpi_recv(rank, src_traced, dst_traced);  }  TRACE_smpi_computing_in(rank);#endif  log_timed_action (action, clock);}
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:34,


示例18: Java_org_simgrid_msg_Host_getCount

JNIEXPORT jint JNICALLJava_org_simgrid_msg_Host_getCount(JNIEnv * env, jclass cls) {  xbt_dynar_t hosts =  MSG_hosts_as_dynar();  int nb_host = xbt_dynar_length(hosts);  xbt_dynar_free(&hosts);  return (jint) nb_host;}
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:7,


示例19: Resource

Cpu::Cpu(Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint,    xbt_dynar_t speedPeakList, int core, double speedPeak) : Resource(model, host->name().c_str(), constraint) , m_core(core) , m_host(host){  p_speed.peak = speedPeak;  p_speed.scale = 1;  host->pimpl_cpu = this;  xbt_assert(p_speed.scale > 0, "Available speed has to be >0");  // Copy the power peak array:  p_speedPeakList = xbt_dynar_new(sizeof(double), nullptr);  unsigned long n = xbt_dynar_length(speedPeakList);  for (unsigned long i = 0; i != n; ++i) {    double value = xbt_dynar_get_as(speedPeakList, i, double);    xbt_dynar_push(p_speedPeakList, &value);  }  /* Currently, we assume that a VM does not have a multicore CPU. */  if (core > 1)    xbt_assert(model == surf_cpu_model_pm);  if (model->getUpdateMechanism() != UM_UNDEFINED) {  p_constraintCore = xbt_new(lmm_constraint_t, core);  p_constraintCoreId = xbt_new(void*, core);    int i;    for (i = 0; i < core; i++) {      /* just for a unique id, never used as a string. */      p_constraintCoreId[i] = bprintf("%s:%i", host->name().c_str(), i);      p_constraintCore[i] = lmm_constraint_new(model->getMaxminSystem(), p_constraintCoreId[i], p_speed.scale * p_speed.peak);    }  }
开发者ID:RockyMeadow,项目名称:simgrid,代码行数:34,


示例20: xbt_queue_length

/** @brief Get the queue size */unsigned long xbt_queue_length(const xbt_queue_t queue){  unsigned long res;  xbt_mutex_acquire(queue->mutex);  res = xbt_dynar_length(queue->data);  xbt_mutex_release(queue->mutex);  return res;}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:9,


示例21: get_group

static MPI_Group get_group(int group) {  if(group == -2) {    return MPI_GROUP_EMPTY;  } else if(group_lookup && group >= 0 && group < (int)xbt_dynar_length(group_lookup)) {    return *(MPI_Group*)xbt_dynar_get_ptr(group_lookup, group);  }  return MPI_COMM_NULL;}
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:8,


示例22: get_comm

static MPI_Comm get_comm(int comm) {  if(comm == -2) {    return MPI_COMM_SELF;  } else if(comm_lookup && comm >= 0 && comm < (int)xbt_dynar_length(comm_lookup)) {    return *(MPI_Comm*)xbt_dynar_get_ptr(comm_lookup, comm);  }  return MPI_COMM_NULL;}
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:8,


示例23: main

/** * Main function * Create the platform, list the available hosts and give them some work */int main(int argc, char **argv) {  unsigned long seed[] = {134, 233445, 865, 2634, 424242, 876543};  int connected;  int max_tries = 10;  //MSG initialization  MSG_init(&argc, argv);  //Set up the seed for the platform generation  platf_random_seed(seed);  XBT_INFO("creating nodes...");  platf_graph_uniform(50);  do {    max_tries--;    XBT_INFO("creating links...");    platf_graph_clear_links();    platf_graph_interconnect_uniform(0.07); //Unrealistic, but simple    XBT_INFO("done. Check connectedness...");    connected = platf_graph_is_connected();    XBT_INFO("Is it connected : %s", connected ? "yes" : (max_tries ? "no, retrying" : "no"));  } while(!connected && max_tries);  if(!connected && !max_tries) {    xbt_die("Impossible to connect the graph, aborting.");  }  XBT_INFO("registering callbacks...");  platf_graph_promoter(promoter_1);  platf_graph_labeler(labeler_1);  XBT_INFO("protmoting...");  platf_do_promote();  XBT_INFO("labeling...");  platf_do_label();  XBT_INFO("Putting it in surf...");  platf_generate();  XBT_INFO("Let's get the available hosts and dispatch work:");  unsigned int i;  msg_host_t host = NULL;  msg_host_t host_master = NULL;  xbt_dynar_t host_dynar = MSG_hosts_as_dynar();  char** hostname_list = xbt_malloc(sizeof(char*) * xbt_dynar_length(host_dynar));  xbt_dynar_foreach(host_dynar, i, host) {    MSG_process_create("slave", slave, NULL, host);    if(i==0) {      //The first node will also be the master      XBT_INFO("%s will be the master", MSG_host_get_name(host));      host_master = host;    }    hostname_list[i] = (char*) MSG_host_get_name(host);  }
开发者ID:apargupta,项目名称:simgrid,代码行数:62,


示例24: parse_ns3_add_cluster

static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster){  const char *cluster_prefix = cluster->prefix;  const char *cluster_suffix = cluster->suffix;  const char *cluster_radical = cluster->radical;  const char *cluster_bb_bw = bprintf("%f",cluster->bb_bw);  const char *cluster_bb_lat = bprintf("%f",cluster->bb_lat);  const char *cluster_bw = bprintf("%f",cluster->bw);  const char *cluster_lat = bprintf("%f",cluster->lat);  const char *groups = NULL;  int start, end, i;  unsigned int iter;  xbt_dynar_t radical_elements;  xbt_dynar_t radical_ends;  xbt_dynar_t tab_elements_num = xbt_dynar_new(sizeof(int), NULL);  char *router_id,*host_id;  radical_elements = xbt_str_split(cluster_radical, ",");  xbt_dynar_foreach(radical_elements, iter, groups) {    radical_ends = xbt_str_split(groups, "-");    switch (xbt_dynar_length(radical_ends)) {    case 1:      start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));      xbt_dynar_push_as(tab_elements_num, int, start);      router_id = bprintf("ns3_%s%d%s", cluster_prefix, start, cluster_suffix);      xbt_lib_set(host_lib,                  router_id,                  NS3_HOST_LEVEL,                  ns3_add_host_cluster(router_id)        );      XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);      free(router_id);      break;    case 2:      start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));      end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));      for (i = start; i <= end; i++){        xbt_dynar_push_as(tab_elements_num, int, i);        router_id = bprintf("ns3_%s%d%s", cluster_prefix, i, cluster_suffix);        xbt_lib_set(host_lib,                    router_id,                    NS3_HOST_LEVEL,                    ns3_add_host_cluster(router_id)          );        XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);        free(router_id);      }      break;    default:      XBT_DEBUG("Malformed radical");    }  }
开发者ID:Shurakai,项目名称:SimGrid,代码行数:58,


示例25: master_fun

int master_fun(int argc, char *argv[]){  msg_vm_t vm;  unsigned int i;  xbt_dynar_t worker_pms = MSG_process_get_data(MSG_process_self());  int nb_workers = xbt_dynar_length(worker_pms);  xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL);  /* Launch VMs and worker processes. One VM per PM, and one worker process per VM. */  XBT_INFO("# Launch %d VMs", nb_workers);  for (i = 0; i< nb_workers; i++) {    char *vm_name = bprintf("VM%02d", i);    char *pr_name = bprintf("WRK%02d", i);    msg_host_t pm = xbt_dynar_get_as(worker_pms, i, msg_host_t);    XBT_INFO("create %s on PM(%s)", vm_name, MSG_host_get_name(pm));    msg_vm_t vm = MSG_vm_create_core(pm, vm_name);    s_vm_params_t params;    memset(&params, 0, sizeof(params));    params.ramsize = 1L * 1024 * 1024 * 1024; // 1Gbytes    MSG_host_set_params(vm, &params);    MSG_vm_start(vm);    xbt_dynar_push(vms, &vm);    XBT_INFO("put a process (%s) on %s", pr_name, vm_name);    MSG_process_create(pr_name, worker_fun, NULL, vm);    xbt_free(vm_name);    xbt_free(pr_name);  }  /* Send a bunch of work to every one */  XBT_INFO("# Send a task to %d worker process", nb_workers);  send_tasks(nb_workers);  XBT_INFO("# Suspend all VMs");  xbt_dynar_foreach(vms, i, vm) {    const char *vm_name = MSG_host_get_name(vm);    XBT_INFO("suspend %s", vm_name);    MSG_vm_suspend(vm);  }  XBT_INFO("# Wait a while");  MSG_process_sleep(2);  XBT_INFO("# Resume all VMs");  xbt_dynar_foreach(vms, i, vm) {    MSG_vm_resume(vm);  }
开发者ID:apargupta,项目名称:simgrid,代码行数:57,


示例26: HostCLM03

HostPtr HostCLM03Model::createHost(const char *name){  HostPtr host = new HostCLM03(surf_host_model, name, NULL,		  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),		  (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL),		  static_cast<CpuPtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL)));  XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));  xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);  return host;}
开发者ID:congfairy,项目名称:simgrid,代码行数:9,


示例27: select_random

/* Randomly select a host in an array. Rely on the rand function provided by math.h * Remark: This function actually removes the selected element from the array. */sg_host_t select_random(xbt_dynar_t hosts){  unsigned long i;  sg_host_t host=NULL;  int nhosts = xbt_dynar_length(hosts);  i = (unsigned long) ((nhosts-1.)*rand()/(RAND_MAX+1.0));  xbt_dynar_remove_at(hosts, i, &host);  return host;}
开发者ID:frs69wq,项目名称:EnsembleSched,代码行数:12,


示例28: sg_host_by_name

Host *HostCLM03Model::createHost(const char *name){  sg_host_t sg_host = sg_host_by_name(name);  Host *host = new HostCLM03(surf_host_model, name, NULL,		  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),		  sg_host_edge(sg_host),		  sg_host_surfcpu(sg_host));  XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));  xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, host);  return host;}
开发者ID:tempbottle,项目名称:simgrid,代码行数:10,



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


C++ xbt_dynar_new函数代码示例
C++ xbt_die函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。