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


C++ DistanceStat类代码示例

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


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

示例1: tm

void
OrderedTask::GlideSolutionPlanned(const AircraftState &aircraft,
                                  const GlidePolar &glide_polar,
                                    GlideResult &total,
                                    GlideResult &leg,
                                    DistanceStat &total_remaining_effective,
                                    DistanceStat &leg_remaining_effective,
                                    const GlideResult &solution_remaining_total,
                                    const GlideResult &solution_remaining_leg)
{
  TaskMacCreadyTotal tm(task_points, active_task_point,
                        task_behaviour.glide, glide_polar);
  total = tm.glide_solution(aircraft);
  leg = tm.get_active_solution();

  if (solution_remaining_total.IsOk())
    total_remaining_effective.SetDistance(tm.effective_distance(solution_remaining_total.time_elapsed));
  else
    total_remaining_effective.Reset();

  if (solution_remaining_leg.IsOk())
    leg_remaining_effective.SetDistance(tm.effective_leg_distance(solution_remaining_leg.time_elapsed));
  else
    leg_remaining_effective.Reset();
}
开发者ID:damianob,项目名称:xcsoar,代码行数:25,代码来源:OrderedTask.cpp

示例2: Copy

static void
Copy(DistanceStat &stat, const GlideResult &solution)
{
  if (solution.IsDefined())
    stat.set_distance(solution.vector.distance);
  else
    stat.Reset();
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:8,代码来源:AbstractTask.cpp

示例3:

void
DistanceStatComputer::CalcSpeed(DistanceStat &data, fixed time)
{
  if (positive(time) && data.IsDefined())
    data.speed = data.GetDistance() / time;
  else
    data.speed = fixed_zero;
}
开发者ID:alon,项目名称:xcsoar,代码行数:8,代码来源:DistanceStat.cpp

示例4: fixed

void
IncrementalSpeedComputer::Reset(DistanceStat &data)
{
  fixed distance = data.IsDefined() ? data.GetDistance() : fixed(0);
  fixed speed = data.IsDefined() ? data.GetSpeed() : fixed(0);

  df.Reset(distance, (is_positive ? -1 : 1) * speed);
  v_lpf.Reset((is_positive ? -1 : 1) * speed);
  data.speed_incremental = fixed(0); // data.speed;
  av_dist.Reset();

  last_time = fixed(-1);
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:13,代码来源:IncrementalSpeedComputer.cpp

示例5: if

void
DistanceStatComputer::CalcIncrementalSpeed(DistanceStat &data, const fixed dt)
{
  if ((dt + fixed_half >= fixed_one) && data.IsDefined()) {
    if (av_dist.Update(data.distance)) {
      const fixed d_av = av_dist.Average() / N_AV;
      av_dist.Reset();

      fixed v_f = fixed_zero;
      for (unsigned i = 0; i < (unsigned)(dt + fixed_half); ++i) {
        const fixed v = df.Update(d_av);
        v_f = v_lpf.Update(v);
      }
      data.speed_incremental = (is_positive ? -v_f : v_f);
    }
  } else if (!positive(dt) || !data.IsDefined()) {
    ResetIncrementalSpeed(data);
  }
}
开发者ID:alon,项目名称:xcsoar,代码行数:19,代码来源:DistanceStat.cpp

示例6: CalculatePirker

static void
CalculatePirker(DistanceStat &pirker, const DistanceStat &planned,
                const DistanceStat &remaining_effective)
{
  if (planned.IsDefined() && remaining_effective.IsDefined())
    pirker.set_distance(planned.get_distance() -
                        remaining_effective.get_distance());
  else
    pirker.Reset();
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:10,代码来源:AbstractTask.cpp

示例7: calculate_reuse_distance

void calculate_reuse_distance(AnalyseTask & task, ModelConfig & model_config, DistanceStat & stat) {
    int i;
    int fake_stamp;                         //  Record number of memory access
    WarpAccess * p_warp_access;
    int set_id;

    //  The normal latency genenrator
    NormalGenerator normal_generator(model_config.latency_mean, model_config.latency_dev);

    //  Variable to record on going requests
    //  Meant for mshr check
    std::multimap<addr_type, int> ongoing_requests;

    //  Calculate total number of accesses for each set
    std::vector<int> total_accesses_per_set;
    task.reset();
    total_accesses_per_set.resize(model_config.cache_set_size, 0);
    p_warp_access = task.next_warp_access(0);
    while (p_warp_access != NULL) {
        for (i = 0; i < p_warp_access->size; i++) {
            set_id = calculate_cache_set(p_warp_access->accesses[i], model_config);
            total_accesses_per_set[set_id] ++;
        }

        p_warp_access = task.next_warp_access(0);
    }

	// Create a tree data structure for each set (B in the Almasi et al. paper)
	std::vector<Tree> Bs;
	Bs.reserve(model_config.cache_set_size);
	for (set_id = 0; set_id < model_config.cache_set_size; set_id ++) {
		Bs.emplace_back(total_accesses_per_set[set_id] + STACK_EXTRA_SIZE);
	}

	// Create the hash data structure (P in the Almasi et al. paper)
    std::vector<std::map<addr_type, int>> Ps;
    Ps.reserve(model_config.cache_set_size);
    Ps.resize(model_config.cache_set_size);
	
    //  Record processed number of accesses per cache set
    std::vector<int> set_counters;
    set_counters.resize(model_config.cache_set_size);
    for (i = 0; i < set_counters.size(); i++)
        set_counters[i] = 0;

	
    //  Start the main loop
    fake_stamp = 0;
    task.reset();
    while (! task.is_finish()) {
        //  Process ongoing requests at eache new time stamp
        process_ongoing_requests(ongoing_requests, fake_stamp, Bs, Ps, set_counters, model_config);

        //  If all warps are jamed, get a NULL pointer, and thuns increase fake_stamp and continue
        p_warp_access = task.next_warp_access(fake_stamp);
        if (p_warp_access == NULL) {
            fake_stamp ++;
            continue;
        }

        //  Take a warptrace
        //  If MSHR check fails
        //  Increast fake_stamp to a point where more mshrs will be available
        while (p_warp_access->size + ongoing_requests.size() > model_config.num_mshrs) {
            fake_stamp = get_shortest_stamp(ongoing_requests);
            process_ongoing_requests(ongoing_requests, fake_stamp, Bs, Ps, set_counters, model_config);
        }

        //  Calculate reuse distance and access latency for each access
        int max_latency = -1;            //  max_latency of accesses int the same warp access
        int latency;
        for (i = 0; i < p_warp_access->size; i++) {
            addr_type line_addr;
            int distance;

            line_addr = p_warp_access->accesses[i];

            //  If the model is configed allocate_on_miss,
            //  Calculate reuse distance, and
            //  update the stack immediately, no matter it's a hit or miss
            if (model_config.allocate_on_miss) {
                distance = calculate_reuse_distance_update_stack_tree(line_addr, Bs, Ps, set_counters, model_config);
            }
            else {
                //  else, just calculate the reuse distance for now
                distance = calculate_reuse_distance(line_addr, Bs, Ps, model_config);
            }

            //  Update the final output DistanceStat
            stat.increase(p_warp_access->pc, distance);

            //  Calculate latency of this access
            if (distance < model_config.cache_way_size && distance >= 0) {
            //  if (distance < model_config.cache_way_size) {
                latency = 0;

                //  If the model is configed ad not allocate on miss,
                //  put the access to stack now for a cache hit
                if (! model_config.allocate_on_miss) {
                    update_stack_tree(line_addr, Bs, Ps, set_counters, model_config);
//.........这里部分代码省略.........
开发者ID:haozhigh,项目名称:model_gpu_cache,代码行数:101,代码来源:reuse_distance.cpp


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