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


C++ xbt_free函数代码示例

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


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

示例1: replace_lat_ns3

static void replace_lat_ns3(char ** lat)
{
  char *temp = xbt_strdup(*lat);
  xbt_free(*lat);
  *lat = bprintf("%fs",atof(temp));
  xbt_free(temp);
}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:7,代码来源:network_ns3.c

示例2: vivaldi_get_route_and_latency

static void vivaldi_get_route_and_latency(
    AS_t rc, sg_routing_edge_t src_p, sg_routing_edge_t dst_p,
    sg_platf_route_cbarg_t route, double *lat)
{
  s_surf_parsing_link_up_down_t info;

  XBT_DEBUG("vivaldi_get_route_and_latency from '%s'[%d] '%s'[%d]",src_p->name,src_p->id,dst_p->name,dst_p->id);
  char *src = (char*)src_p->name;
  char *dst = (char*)dst_p->name;

  if(src_p->rc_type == SURF_NETWORK_ELEMENT_AS) {
    char *rp_src = ROUTER_PEER(src);
    char *rp_dst = ROUTER_PEER(dst);
    route->gw_src = xbt_lib_get_or_null(as_router_lib, rp_src,
                                        ROUTING_ASR_LEVEL);
    route->gw_dst = xbt_lib_get_or_null(as_router_lib, rp_dst,
                                        ROUTING_ASR_LEVEL);
    xbt_free(rp_src);
    xbt_free(rp_dst);
  }

  double euclidean_dist;
  xbt_dynar_t src_ctn, dst_ctn;
  char *tmp_src_name, *tmp_dst_name;

  if(src_p->rc_type == SURF_NETWORK_ELEMENT_HOST){
    tmp_src_name = HOST_PEER(src);

    if(rc->link_up_down_list){
      info = xbt_dynar_get_as(rc->link_up_down_list,src_p->id,s_surf_parsing_link_up_down_t);
      if(info.link_up) { // link up
        xbt_dynar_push_as(route->link_list,void*,info.link_up);
        if (lat)
          *lat += surf_network_model->extension.network.get_link_latency(info.link_up);
      }
开发者ID:cemsbr,项目名称:simgrid,代码行数:35,代码来源:surf_routing_vivaldi.c

示例3: crasher

int crasher(int argc, char *argv[])
{
  int i;
  xbt_os_thread_t *crashers;

  xbt_init(&argc, argv);

  /* initializations of the philosopher mecanisms */
  id = xbt_new0(int, crasher_amount);
  crashers = xbt_new(xbt_os_thread_t, crasher_amount);

  for (i = 0; i < crasher_amount; i++)
    id[i] = i;

  /* spawn threads */
  for (i = 0; i < crasher_amount; i++) {
    char *name = bprintf("thread %d", i);
    crashers[i] =
        xbt_os_thread_create(name, &crasher_thread, &id[i], NULL );
    free(name);
  }

  /* wait for them */
  for (i = 0; i < crasher_amount; i++)
    xbt_os_thread_join(crashers[i],NULL);

  xbt_free(crashers);
  xbt_free(id);

  return 0;
}
开发者ID:FlorianPO,项目名称:simgrid,代码行数:31,代码来源:parallel_log_crashtest.c

示例4: XBT_DEBUG

void AsVivaldi::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t route, double *lat)
{
  s_surf_parsing_link_up_down_t info;

  XBT_DEBUG("vivaldi_get_route_and_latency from '%s'[%d] '%s'[%d]",
		  src->getName(), src->getId(), dst->getName(), dst->getId());

  if(src->getRcType() == SURF_NETWORK_ELEMENT_AS) {
    char *src_name = ROUTER_PEER(src->getName());
    char *dst_name = ROUTER_PEER(dst->getName());
    route->gw_src = (sg_routing_edge_t) xbt_lib_get_or_null(as_router_lib, src_name, ROUTING_ASR_LEVEL);
    route->gw_dst = (sg_routing_edge_t) xbt_lib_get_or_null(as_router_lib, dst_name, ROUTING_ASR_LEVEL);
    xbt_free(src_name);
    xbt_free(dst_name);
  }

  double euclidean_dist;
  xbt_dynar_t src_ctn, dst_ctn;
  char *tmp_src_name, *tmp_dst_name;

  if(src->getRcType() == SURF_NETWORK_ELEMENT_HOST){
    tmp_src_name = HOST_PEER(src->getName());

    if(p_linkUpDownList){
      info = xbt_dynar_get_as(p_linkUpDownList, src->getId(), s_surf_parsing_link_up_down_t);
      if(info.link_up) { // link up
        xbt_dynar_push_as(route->link_list, void*, info.link_up);
        if (lat)
          *lat += static_cast<Link*>(info.link_up)->getLatency();
      }
    }
开发者ID:apargupta,项目名称:simgrid,代码行数:31,代码来源:surf_routing_vivaldi.cpp

示例5: SD_task_destroy

/**
 * \brief Destroys a task.
 *
 * The user data (if any) should have been destroyed first.
 *
 * \param task the task you want to destroy
 * \see SD_task_create()
 */
void SD_task_destroy(SD_task_t task)
{
  XBT_DEBUG("Destroying task %s...", SD_task_get_name(task));

  /* First Remove all dependencies associated with the task. */
  while (!task->predecessors->empty())
    SD_task_dependency_remove(*(task->predecessors->begin()), task);
  while (!task->inputs->empty())
    SD_task_dependency_remove(*(task->inputs->begin()), task);
  while (!task->successors->empty())
    SD_task_dependency_remove(task, *(task->successors->begin()));
  while (!task->outputs->empty())
   SD_task_dependency_remove(task, *(task->outputs->begin()));

  if (task->state == SD_SCHEDULED || task->state == SD_RUNNABLE)
    __SD_task_destroy_scheduling_data(task);

  int idx = xbt_dynar_search_or_negative(sd_global->return_set, &task);
  if (idx >=0) {
    xbt_dynar_remove_at(sd_global->return_set, idx, nullptr);
  }

  xbt_free(task->name);

  if (task->surf_action != nullptr)
    task->surf_action->unref();

  xbt_free(task->host_list);
  xbt_free(task->bytes_amount);
  xbt_free(task->flops_amount);

  xbt_mallocator_release(sd_global->task_mallocator,task);

  XBT_DEBUG("Task destroyed.");
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:43,代码来源:sd_task.cpp

示例6: SD_task_schedule

/**
 * \brief Schedules a task
 *
 * The task state must be #SD_NOT_SCHEDULED.
 * Once scheduled, a task is executed as soon as possible in \see SD_simulate, i.e. when its dependencies are satisfied.
 *
 * \param task the task you want to schedule
 * \param host_count number of hosts on which the task will be executed
 * \param workstation_list the hosts on which the task will be executed
 * \param flops_amount computation amount for each hosts (i.e., an array of host_count doubles)
 * \param bytes_amount communication amount between each pair of hosts (i.e., a matrix of host_count*host_count doubles)
 * \param rate task execution speed rate
 * \see SD_task_unschedule()
 */
void SD_task_schedule(SD_task_t task, int host_count, const sg_host_t * workstation_list,
                      const double *flops_amount, const double *bytes_amount, double rate)
{
  xbt_assert(host_count > 0, "workstation_nb must be positive");

  task->host_count = host_count;
  task->rate = rate;

  if (flops_amount) {
    task->flops_amount = static_cast<double*>(xbt_realloc(task->flops_amount, sizeof(double) * host_count));
    memcpy(task->flops_amount, flops_amount, sizeof(double) * host_count);
  } else {
    xbt_free(task->flops_amount);
    task->flops_amount = nullptr;
  }

  int communication_nb = host_count * host_count;
  if (bytes_amount) {
    task->bytes_amount = static_cast<double*>(xbt_realloc(task->bytes_amount, sizeof(double) * communication_nb));
    memcpy(task->bytes_amount, bytes_amount, sizeof(double) * communication_nb);
  } else {
    xbt_free(task->bytes_amount);
    task->bytes_amount = nullptr;
  }

  task->host_list =  static_cast<sg_host_t*>(xbt_realloc(task->host_list, sizeof(sg_host_t) * host_count));
  memcpy(task->host_list, workstation_list, sizeof(sg_host_t) * host_count);

  SD_task_do_schedule(task);
}
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:44,代码来源:sd_task.cpp

示例7: xbt_dict_free

/**
 * \brief Destructor
 * \param dict the dictionary to be freed
 *
 * Frees a dictionary with all the data
 */
void xbt_dict_free(xbt_dict_t * dict)
{
    int i;
    xbt_dictelm_t current, previous;
    int table_size;
    xbt_dictelm_t *table;

    //  if ( *dict )  xbt_dict_dump_sizes(*dict);

    if (dict != NULL && *dict != NULL) {
        table_size = (*dict)->table_size;
        table = (*dict)->table;
        /* Warning: the size of the table is 'table_size+1'...
         * This is because table_size is used as a binary mask in xbt_dict_rehash */
        for (i = 0; (*dict)->count && i <= table_size; i++) {
            current = table[i];
            while (current != NULL) {
                previous = current;
                current = current->next;
                xbt_dictelm_free(*dict, previous);
                (*dict)->count--;
            }
        }
        xbt_free(table);
        xbt_free(*dict);
        *dict = NULL;
    }
}
开发者ID:apargupta,项目名称:simgrid,代码行数:34,代码来源:dict.c

示例8: receiver

static void receiver(std::vector<std::string> args)
{
  int flow_amount = std::stoi(args.at(0));

  XBT_INFO("Receiving %d flows ...", flow_amount);

  simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::string("message"));

  if (flow_amount == 1) {
    void* res = mailbox->get();
    xbt_free(res);
  } else {
    void* data[flow_amount];

    // Start all comms in parallel, and wait for their completion in one shot
    std::vector<simgrid::s4u::CommPtr> comms;
    for (int i = 0; i < flow_amount; i++)
      comms.push_back(mailbox->get_async(&data[i]));

    simgrid::s4u::Comm::wait_all(&comms);
    for (int i = 0; i < flow_amount; i++)
      xbt_free(data[i]);
  }
  XBT_INFO("receiver done.");
}
开发者ID:mpoquet,项目名称:simgrid,代码行数:25,代码来源:s4u-energy-link.cpp

示例9: 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,代码来源:network_smpi.cpp

示例10: bprintf

void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int , int position){
  s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
  s_surf_parsing_link_up_down_t info;
  char* link_id = bprintf("%s_link_%d", cluster->id, id);

  memset(&link, 0, sizeof(link));
  link.id = link_id;
  link.bandwidth = cluster->bw;
  link.latency = cluster->lat;
  link.policy = cluster->sharing_policy;
  sg_platf_new_link(&link);

  if (link.policy == SURF_LINK_FULLDUPLEX) {
    char *tmp_link = bprintf("%s_UP", link_id);
    info.link_up = sg_link_by_name(tmp_link);
    xbt_free(tmp_link);
    tmp_link = bprintf("%s_DOWN", link_id);
    info.link_down = sg_link_by_name(tmp_link);
    xbt_free(tmp_link);
  } else {
    info.link_up = sg_link_by_name(link_id);
    info.link_down = info.link_up;
  }
  xbt_dynar_set(upDownLinks, position, &info);
  xbt_free(link_id);
}
开发者ID:adegomme,项目名称:simgrid,代码行数:26,代码来源:AsCluster.cpp

示例11: print_TICreateContainer

void print_TICreateContainer(paje_event_t event)
{
  //if we are in the mode with only one file
  static FILE *temp = nullptr;

  if (tracing_files == nullptr) {
    tracing_files = xbt_dict_new_homogeneous(nullptr);
    //generate unique run id with time
    prefix = xbt_os_time();
  }

  if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || temp == nullptr) {
    char *folder_name = bprintf("%s_files", TRACE_get_filename());
    char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name);
#ifdef WIN32
    _mkdir(folder_name);
#else
    mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO);
#endif
    temp = fopen(filename, "w");
    xbt_assert(temp, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno));
    fprintf(tracing_file, "%s\n", filename);

    xbt_free(folder_name);
    xbt_free(filename);
  }

  xbt_dict_set(tracing_files, ((createContainer_t) event->data)->container->name, (void *) temp, nullptr);
}
开发者ID:fabienchaix,项目名称:simgrid,代码行数:29,代码来源:instr_TI_trace.cpp

示例12: smpi_comm_copy_buffer_callback

void smpi_comm_copy_buffer_callback(smx_synchro_t synchro, void *buff, size_t buff_size)
{
  XBT_DEBUG("Copy the data over");
  void* tmpbuff=buff;
  simgrid::simix::Comm *comm = dynamic_cast<simgrid::simix::Comm*>(synchro);

  if((smpi_privatize_global_variables) && ((char*)buff >= smpi_start_data_exe)
      && ((char*)buff < smpi_start_data_exe + smpi_size_data_exe )
    ){
       XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");


       smpi_switch_data_segment(((smpi_process_data_t)(((simdata_process_t)SIMIX_process_get_data(comm->src_proc))->data))->index);
       tmpbuff = (void*)xbt_malloc(buff_size);
       memcpy(tmpbuff, buff, buff_size);
  }

  if((smpi_privatize_global_variables) && ((char*)comm->dst_buff >= smpi_start_data_exe)
      && ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){
       XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
       smpi_switch_data_segment(((smpi_process_data_t)(((simdata_process_t)SIMIX_process_get_data(comm->dst_proc))->data))->index);
  }

  memcpy(comm->dst_buff, tmpbuff, buff_size);
  if (comm->detached) {
    // if this is a detached send, the source buffer was duplicated by SMPI
    // sender to make the original buffer available to the application ASAP
    xbt_free(buff);
    //It seems that the request is used after the call there this should be free somewhere else but where???
    //xbt_free(comm->comm.src_data);// inside SMPI the request is kept inside the user data and should be free
    comm->src_buff = NULL;
  }

  if(tmpbuff!=buff)xbt_free(tmpbuff);
}
开发者ID:krytarowski,项目名称:simgrid,代码行数:35,代码来源:smpi_global.cpp

示例13: MSG_task_destroy

/** \ingroup m_task_management
 * \brief Destroy a #msg_task_t.
 *
 * Destructor for #msg_task_t. Note that you should free user data, if any, \b
 * before calling this function.
 *
 * Only the process that owns the task can destroy it.
 * The owner changes after a successful send.
 * If a task is successfully sent, the receiver becomes the owner and is
 * supposed to destroy it. The sender should not use it anymore.
 * If the task failed to be sent, the sender remains the owner of the task.
 */
msg_error_t MSG_task_destroy(msg_task_t task)
{
  smx_synchro_t action = NULL;
  xbt_assert((task != NULL), "Invalid parameter");

  if (task->simdata->isused) {
    /* the task is being sent or executed: cancel it first */
    MSG_task_cancel(task);
  }
  TRACE_msg_task_destroy(task);

  xbt_free(task->name);

  action = task->simdata->compute;
  if (action)
    simcall_process_execution_destroy(action);

  /* parallel tasks only */
  xbt_free(task->simdata->host_list);

  xbt_dict_free(&task->simdata->affinity_mask_db);

  /* free main structures */
  xbt_free(task->simdata);
  xbt_free(task);

  return MSG_OK;
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:40,代码来源:msg_task.c

示例14: replace_bdw_ns3

static void replace_bdw_ns3(char ** bdw)
{
  char *temp = xbt_strdup(*bdw);
  xbt_free(*bdw);
  *bdw = bprintf("%fBps",atof(temp));
  xbt_free(temp);

}
开发者ID:Shurakai,项目名称:SimGrid,代码行数:8,代码来源:network_ns3.c

示例15: route_cache_elem_free

static void route_cache_elem_free(void *e)
{
  route_cache_element_t elm = (route_cache_element_t) e;
  if (elm) {
    xbt_free(elm->pred_arr);
    xbt_free(elm);
  }
}
开发者ID:dhascome,项目名称:simgrid,代码行数:8,代码来源:surf_routing_dijkstra.c


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