Exemplo n.º 1
0
int main(int argc, char* argv[]) {
    util::ParseInputArgs(argc, argv);

    int             nthreads;
    util::my_time_t tm_init, tm_start, tm_end;

#if USECONCVEC
    std::cout << "Starting TBB unbuffered push_back version of QUICK HULL algorithm" << std::endl;
#else
    std::cout << "Starting STL locked unbuffered push_back version of QUICK HULL algorithm" << std::endl;
#endif // USECONCVEC

    for(nthreads=cfg::threads.first; nthreads<=cfg::threads.last;
        ++nthreads) {
        pointVec_t      points;
        pointVec_t      hull;

        tbb::task_scheduler_init init(nthreads);
        tm_init = util::gettime();
        initialize<FillRNDPointsVector>(points);
        tm_start = util::gettime();
        std::cout << "Parallel init time on " << nthreads << " threads: " << util::time_diff(tm_init, tm_start) << "  Points in input: " << points.size() << "\n";

        tm_start = util::gettime();
        quickhull(points, hull, false);
        tm_end = util::gettime();
        std::cout << "Time on " << nthreads << " threads: " << util::time_diff(tm_start, tm_end) << "  Points in hull: " << hull.size() << "\n";
    }

#if USECONCVEC 
    std::cout << "Starting TBB buffered version of QUICK HULL algorithm" << std::endl;
#else
    std::cout << "Starting STL locked buffered version of QUICK HULL algorithm" << std::endl;
#endif

    for(nthreads=cfg::threads.first; nthreads<=cfg::threads.last;
        ++nthreads) {
        pointVec_t      points;
        pointVec_t      hull;

        tbb::task_scheduler_init init(nthreads);

        tm_init = util::gettime();
        initialize<FillRNDPointsVector_buf>(points);
        tm_start = util::gettime();
        std::cout << "Init time on " << nthreads << " threads: " << util::time_diff(tm_init, tm_start) << "  Points in input: " << points.size() << "\n";

        tm_start = util::gettime();
        quickhull(points, hull, true);
        tm_end = util::gettime();
        std::cout << "Time on " << nthreads << " threads: " << util::time_diff(tm_start, tm_end) << "  Points in hull: " << hull.size() << "\n";
    }    

    return 0;
}
Exemplo n.º 2
0
void distance(geom2d_point_list_tl_t* points1,
              geom2d_point_list_tl_t* points2,
              double owcr* d)
{
  geom2d_point_list_tl_t hull1;
  geom2d_point_list_tl_t hull2;
  double_list_tl_t       dists;
  
  quickhull(points1, &hull1);

  quickhull(points2, &hull2);
  
  all_distances(hull1, &hull2, &dists);
  
  *d = reduce_min_distance(&dists, NULL);
}
Exemplo n.º 3
0
void diameter(geom2d_point_list_tl_t* points, double owcr* d) {
  geom2d_point_list_tl_t hull;
  double_list_tl_t       dists;
  
  quickhull(points, &hull);
  
  all_distances(hull, &hull, &dists);
  
  *d = reduce_max_distance(&dists, NULL);
}
Exemplo n.º 4
0
int convexhulling(polygon_t *chull, point_list_t *points, convexhull_method_t way)
{
  int cnt;

  assert(chull);
  assert(points);
  assert(point_list_get_count(points));

  switch (way) {
  case JAVIS_MARCH: cnt = jarvismarch(chull, points); break;
  case GRAHAM_SCAN: cnt = grahamscan(chull, points); break;
  case QUICK_HULL: cnt = quickhull(chull, points); break;
  default: abort(); break;
  }

  return cnt;
}
Exemplo n.º 5
0
int main(int argc, char* argv[]) {
    util::ParseInputArgs(argc, argv);

    pointVec_t      points;
    pointVec_t      hull;
    util::my_time_t tm_init, tm_start, tm_end;

    std::cout << "Starting serial version of QUICK HULL algorithm" << std::endl;

    tm_init = util::gettime();
    serial_initialize(points);
    tm_start = util::gettime();
    std::cout << "Init time: " << util::time_diff(tm_init, tm_start) << "  Points in input: " << points.size() << "\n";
    tm_start = util::gettime();
    quickhull(points, hull);
    tm_end = util::gettime();
    std::cout << "Serial time: " << util::time_diff(tm_start, tm_end) << "  Points in hull: " << hull.size() << "\n";
}
Exemplo n.º 6
0
int main(int argc, char* argv[]) {
    util::my_time_t tm_main_begin = util::gettime();

    util::ParseInputArgs(argc, argv);

    pointVec_t      points;
    pointVec_t      hull;
    int             nthreads;

    points.reserve(cfg::numberOfPoints);

    if(!util::silent) {
        std::cout << "Starting TBB-buffered version of QUICK HULL algorithm" << std::endl;
    }

    for(nthreads=cfg::threads.first; nthreads<=cfg::threads.last; nthreads=cfg::threads.step(nthreads)) {
        tbb::task_scheduler_init init(nthreads);

        points.clear();
        util::my_time_t tm_init = util::gettime();
        initialize(points);
        util::my_time_t tm_start = util::gettime();
        if(!util::silent) {
            std::cout <<"Init time on "<<nthreads<<" threads: "<<util::time_diff(tm_init, tm_start)<<"  Points in input: "<<points.size()<<std::endl;
        }

        tm_start = util::gettime();
        quickhull(points, hull);
        util::my_time_t tm_end = util::gettime();
        if(!util::silent) {
            std::cout <<"Time on "<<nthreads<<" threads: "<<util::time_diff(tm_start, tm_end)<<"  Points in hull: "<<hull.size()<<std::endl;
        }
        hull.clear();
    }
    utility::report_elapsed_time(util::time_diff(tm_main_begin, util::gettime()));
    return 0;
}