int main(void) {
  DataGenerator dg = DataGenerator("|");
  vector<string> states = dg.states();
  vector<string>::iterator i;
  for (i = states.begin(); i != states.end(); i++)
     cout << *i << "\n";
  string state = dg.state();
  assert(find(states.begin(),states.end(),state) != states.end());
  cout << "dg.state() : " << state << "\n";
}
示例#2
0
文件: main.cpp 项目: impuls14/qt
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    DataGenerator tester;

    tester.run(argc, argv);

    return 0;
}
示例#3
0
int main (int argc, char* argv[])
{
  cout << "Ref : https://kheresy.wordpress.com/2012/03/05/c11_smartpointer_p2/" << endl;
  cout << "Testing the usage of C++11 smart pointers..." << endl;
  // unique_ptr
  cout << "Testing unique_ptr : " << endl;
  cout << "--------------------------------------------" << endl;
  {
    unique_ptr<int> a(new int(1));
    cout << "*a:" << *a << endl;
    /* unique_ptr<int> b = a;  // compile error! */
    unique_ptr<int> b = move(a);
    cout << "*b:" << *b << endl;
  }
  cout << "--------------------------------------------" << endl;

  // shared_ptr
  cout << "Testing shared_ptr : " << endl;
  cout << "--------------------------------------------" << endl;
  {
    shared_ptr<int> a;  // a is empty
    cout << "a.use_count():" << a.use_count() << endl;
    {
      shared_ptr<int> b(new int(10));  // allocate resource
      a = b;  // reference counter: 2
      cout << "a.use_count():" << a.use_count() << endl;
      cout << "b.use_count():" << b.use_count() << endl;
      cout << "*a:" << *a << endl;
      cout << "*b:" << *b << endl;
      {
        shared_ptr<int> c = a;  // reference counter: 3
        *c = 100;
        cout << "a.use_count():" << a.use_count() << endl;
        cout << "b.use_count():" << b.use_count() << endl;
        cout << "c.use_count():" << c.use_count() << endl;
        cout << "*a:" << *a << endl;
        cout << "*b:" << *b << endl;
        cout << "*c:" << *c << endl;
      }  // c dead, reference counter: 2
      cout << "b.use_count():" << b.use_count() << endl;
    } // b dead, reference counter: 1
    cout << "a.use_count():" << a.use_count() << endl;

    DataGenerator DataGen;
    shared_ptr<int> A = DataGen.GetData();
    cout << "A.use_count():" << A.use_count() << endl;
    cout << "*A:" << *A << endl;

  }  // release resource
  cout << "--------------------------------------------" << endl;

  cout << "bye" << endl;

  return 0;
}
bool atWrapper::executeTests()
{
    qDebug("Executing the tests...");

    QHashIterator<QString, QString> i(enginesToTest);

    DataGenerator generator;

    //Running datagenerator against all the frameworks specified in the config file.
    while ( i.hasNext() )
    {

        i.next();

        qDebug( "Now testing: " + i.key().toLatin1() );

        char* params[13];
        //./bin/datagenerator  -framework data/framework.ini  -engine OpenGL -suite 1.1 -output outtest


        QByteArray eng = i.key().toLatin1();
        QByteArray fwk = framework.toLatin1();
        QByteArray sut = suite.toLatin1();
        QByteArray out = output.toLatin1();
        QByteArray siz = size.toLatin1();
        QByteArray fill = fillColor.toLatin1();

        params[1] = "-framework";
        params[2] = fwk.data();
        params[3] = "-engine";
        params[4] = eng.data();
        params[5] = "-suite";
        params[6] = sut.data();
        params[7] = "-output";
        params[8] = out.data();
        params[9] = "-size";
        params[10] = siz.data();
        params[11] = "-fill";
        params[12] = fill.data();

        generator.run( 13, params );
    }

    return true;
}
示例#5
0
//TEST (PCL_GPU, DISABLED_bruteForceRadiusSeachGPU)
TEST (PCL_GPU, bruteForceRadiusSeachGPU)
{   
    DataGenerator data;
    data.data_size = 871000;
    data.tests_num = 100;
    data.cube_size = 1024.f;
    data.max_radius    = data.cube_size/15.f;
    data.shared_radius = data.cube_size/20.f;
    data.printParams();  

    //generate
    data();
    
    // brute force radius search
    data.bruteForceSearch();

    //prepare gpu cloud
    pcl::gpu::Octree::PointCloud cloud_device;
    cloud_device.upload(data.points);
    
    pcl::gpu::DeviceArray<int> results_device, buffer(cloud_device.size());
    
    vector<int> results_host;
    vector<size_t> sizes;
    for(size_t i = 0; i < data.tests_num; ++i)
    {
        pcl::gpu::bruteForceRadiusSearchGPU(cloud_device, data.queries[i], data.radiuses[i], results_device, buffer);

        results_device.download(results_host);
        std::sort(results_host.begin(), results_host.end());

        ASSERT_EQ ( (results_host == data.bfresutls[i]), true );
        sizes.push_back(results_device.size());      
    }
        
    float avg_size = std::accumulate(sizes.begin(), sizes.end(), (size_t)0) * (1.f/sizes.size());;

    cout << "avg_result_size = " << avg_size << endl;
    ASSERT_GT(avg_size, 5);    
}
TestRunner::TestRunner(const CatalogRelation &relation,
                       const DataGenerator &generator,
                       const attribute_id select_column,
                       const int use_index,
                       const bool sort_matches,
                       const float selectivity,
                       const std::vector<int> &thread_affinities)
    : relation_(relation),
      select_column_(select_column),
      use_index_(use_index),
      sort_matches_(sort_matches),
      thread_affinities_(thread_affinities),
      predicate_(generator.generatePredicate(relation, select_column, selectivity)) {
}
示例#7
0
//TEST(PCL_OctreeGPU, DISABLED_batchRadiusSearch)
TEST(PCL_OctreeGPU, batchRadiusSearch)
{   
    DataGenerator data;
    data.data_size = 871000;
    data.tests_num = 10000;
    data.cube_size = 1024.f;
    data.max_radius    = data.cube_size/30.f;
    data.shared_radius = data.cube_size/30.f;
    data.printParams();

    const int max_answers = 333;

    //generate
    data();
        
    //prepare gpu cloud

    pcl::gpu::Octree::PointCloud cloud_device;
    cloud_device.upload(data.points);

    //gpu build 
    pcl::gpu::Octree octree_device;                
    octree_device.setCloud(cloud_device);	    
    octree_device.build();

    //upload queries
    pcl::gpu::Octree::Queries queries_device;
    pcl::gpu::Octree::Radiuses radiuses_device;
    queries_device.upload(data.queries);                
    radiuses_device.upload(data.radiuses);
    
    //prepare output buffers on device

    pcl::gpu::NeighborIndices result_device1(queries_device.size(), max_answers);
    pcl::gpu::NeighborIndices result_device2(queries_device.size(), max_answers);
    pcl::gpu::NeighborIndices result_device3(data.indices.size(), max_answers);
            
    //prepare output buffers on host
    vector< vector<int> > host_search1(data.tests_num);
    vector< vector<int> > host_search2(data.tests_num);
    for(size_t i = 0; i < data.tests_num; ++i)
    {
        host_search1[i].reserve(max_answers);
        host_search2[i].reserve(max_answers);
    }    
    
    //search GPU shared
    octree_device.radiusSearch(queries_device, data.shared_radius, max_answers, result_device1);

    //search GPU individual
    octree_device.radiusSearch(queries_device,    radiuses_device, max_answers, result_device2);

    //search GPU shared with indices
    pcl::gpu::Octree::Indices indices;
    indices.upload(data.indices);
    octree_device.radiusSearch(queries_device, indices, data.shared_radius, max_answers, result_device3);

    //search CPU
    octree_device.internalDownload();
    for(size_t i = 0; i < data.tests_num; ++i)
    {
        octree_device.radiusSearchHost(data.queries[i], data.shared_radius, host_search1[i], max_answers);
        octree_device.radiusSearchHost(data.queries[i], data.radiuses[i],   host_search2[i], max_answers);
    }
    
    //download results
    vector<int> sizes1;
    vector<int> sizes2;
    vector<int> sizes3;
    result_device1.sizes.download(sizes1);
    result_device2.sizes.download(sizes2);
    result_device3.sizes.download(sizes3);

    vector<int> downloaded_buffer1, downloaded_buffer2, downloaded_buffer3, results_batch;    
    result_device1.data.download(downloaded_buffer1);
    result_device2.data.download(downloaded_buffer2);
    result_device3.data.download(downloaded_buffer3);
        
    //data.bruteForceSearch();

    //verify results    
    for(size_t i = 0; i < data.tests_num; ++i)
    {        
        vector<int>& results_host = host_search1[i];        
        
        int beg = i * max_answers;
        int end = beg + sizes1[i];

        results_batch.assign(downloaded_buffer1.begin() + beg, downloaded_buffer1.begin() + end);

        std::sort(results_batch.begin(), results_batch.end());
        std::sort(results_host.begin(), results_host.end());

        if ((int)results_batch.size() == max_answers && results_batch.size() < results_host.size() && max_answers)
            results_host.resize(max_answers);
        
        ASSERT_EQ ( ( results_batch == results_host ), true );       
       
        //vector<int>& results_bf = data.bfresutls[i];
        //ASSERT_EQ ( ( results_bf == results_batch), true );        
        //ASSERT_EQ ( ( results_bf == results_host ), true );           
    }    

    float avg_size1 = std::accumulate(sizes1.begin(), sizes1.end(), 0) * (1.f/sizes1.size());

    cout << "avg_result_size1 = " << avg_size1 << endl;
    ASSERT_GT(avg_size1, 5);    


    //verify results    
    for(size_t i = 0; i < data.tests_num; ++i)
    {        
        vector<int>& results_host = host_search2[i];        
        
        int beg = i * max_answers;
        int end = beg + sizes2[i];

        results_batch.assign(downloaded_buffer2.begin() + beg, downloaded_buffer2.begin() + end);

        std::sort(results_batch.begin(), results_batch.end());
        std::sort(results_host.begin(), results_host.end());

        if ((int)results_batch.size() == max_answers && results_batch.size() < results_host.size() && max_answers)
            results_host.resize(max_answers);

        ASSERT_EQ ( ( results_batch == results_host ), true );       
       
        //vector<int>& results_bf = data.bfresutls[i];
        //ASSERT_EQ ( ( results_bf == results_batch), true );        
        //ASSERT_EQ ( ( results_bf == results_host ), true );           
    }    

    float avg_size2 = std::accumulate(sizes2.begin(), sizes2.end(), 0) * (1.f/sizes2.size());

    cout << "avg_result_size2 = " << avg_size2 << endl;
    ASSERT_GT(avg_size2, 5);


    //verify results    
    for(size_t i = 0; i < data.tests_num; i+=2)
    {                
        vector<int>& results_host = host_search1[i];        
        
        int beg = i/2 * max_answers;
        int end = beg + sizes3[i/2];

        results_batch.assign(downloaded_buffer3.begin() + beg, downloaded_buffer3.begin() + end);

        std::sort(results_batch.begin(), results_batch.end());
        std::sort(results_host.begin(), results_host.end());

        if ((int)results_batch.size() == max_answers && results_batch.size() < results_host.size() && max_answers)
            results_host.resize(max_answers);
        
        ASSERT_EQ ( ( results_batch == results_host ), true );       
       
        //vector<int>& results_bf = data.bfresutls[i];
        //ASSERT_EQ ( ( results_bf == results_batch), true );        
        //ASSERT_EQ ( ( results_bf == results_host ), true );           
    }

    float avg_size3 = std::accumulate(sizes3.begin(), sizes3.end(), 0) * (1.f/sizes3.size());

    cout << "avg_result_size3 = " << avg_size3 << endl;
    ASSERT_GT(avg_size3, 5);
}
示例#8
0
//TEST(PCL_OctreeGPU, DISABLED_hostRadiusSearch)
TEST(PCL_OctreeGPU, hostRadiusSearch)
{
    DataGenerator data;
    data.data_size = 871000;
    data.tests_num = 10000;
    data.cube_size = 1024.f;
    data.max_radius    = data.cube_size/15.f;
    data.shared_radius = data.cube_size/20.f;
    data.printParams();

    //generate
    data();

    //prepare device cloud
    pcl::gpu::Octree::PointCloud cloud_device;
    cloud_device.upload(data.points);

    //prepare host cloud
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_host(new pcl::PointCloud<pcl::PointXYZ>);	
    cloud_host->width = data.points.size();
    cloud_host->height = 1;
    cloud_host->points.resize (cloud_host->width * cloud_host->height);
    std::transform(data.points.begin(), data.points.end(),  cloud_host->points.begin(), DataGenerator::ConvPoint<pcl::PointXYZ>());
    
    // build device octree
    pcl::gpu::Octree octree_device;                
    octree_device.setCloud(cloud_device);	    
    octree_device.build();



    // build host octree
    float resolution = 25.f;
    cout << "[!]Octree resolution: " << resolution << endl;
    pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree_host(resolution);
    octree_host.setInputCloud (cloud_host);
    octree_host.addPointsFromInputCloud ();

    //perform bruteForceSearch    
    data.bruteForceSearch(true);    
    
    vector<int> sizes;
    sizes.reserve(data.tests_num);
    octree_device.internalDownload();
             
    for(size_t i = 0; i < data.tests_num; ++i)
    {
        //search host on octree tha was built on device
        vector<int> results_host_gpu; //host search
        octree_device.radiusSearchHost(data.queries[i], data.radiuses[i], results_host_gpu);                        
        
        //search host
        vector<float> dists;
        vector<int> results_host;                
        octree_host.radiusSearch(pcl::PointXYZ(data.queries[i].x, data.queries[i].y, data.queries[i].z), data.radiuses[i], results_host, dists);                        
        
        std::sort(results_host_gpu.begin(), results_host_gpu.end());
        std::sort(results_host.begin(), results_host.end());

        ASSERT_EQ ( (results_host_gpu == results_host     ), true );
        ASSERT_EQ ( (results_host_gpu == data.bfresutls[i]), true );                
        sizes.push_back(results_host.size());      
    }    

    float avg_size = std::accumulate(sizes.begin(), sizes.end(), 0) * (1.f/sizes.size());;

    cout << "avg_result_size = " << avg_size << endl;
    ASSERT_GT(avg_size, 5);    
}
示例#9
0
 void run(){ m_dg->_gen_dist_uniform(m_n, m_min, m_max, m_discrete, m_path); }
示例#10
0
 void run(){ m_dg->_export_raw_data(m_count, m_path); }
示例#11
0
 void run(){ m_dg->_gen_dist_poisson(m_n, m_e, m_path); }
示例#12
0
 void run(){ m_dg->_gen_dist_exponential(m_n, m_lambda, m_path); }
示例#13
0
 void run(){ m_dg->_gen_dist_geometric(m_n, m_e, m_path); }
示例#14
0
 void run(){ m_dg->_gen_dist_normal(m_n, m_mean, m_stdev, m_discrete, m_path); }
示例#15
0
//TEST(PCL_OctreeGPU, DISABLED_approxNearesSearch)
TEST(PCL_OctreeGPU, approxNearesSearch)
{   
    DataGenerator data;
    data.data_size = 871000;
    data.tests_num = 10000;
    data.cube_size = 1024.f;
    data.max_radius    = data.cube_size/30.f;
    data.shared_radius = data.cube_size/30.f;
    data.printParams();

    const float host_octree_resolution = 25.f;

    //generate
    data();
        
    //prepare device cloud
    pcl::gpu::Octree::PointCloud cloud_device;
    cloud_device.upload(data.points);


    //prepare host cloud
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_host(new pcl::PointCloud<pcl::PointXYZ>);	
    cloud_host->width = data.points.size();
    cloud_host->height = 1;
    cloud_host->points.resize (cloud_host->width * cloud_host->height);    
    std::transform(data.points.begin(), data.points.end(), cloud_host->points.begin(), DataGenerator::ConvPoint<pcl::PointXYZ>());

    //gpu build 
    pcl::gpu::Octree octree_device;                
    octree_device.setCloud(cloud_device);	    
    octree_device.build();
    
    //build host octree
    pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree_host(host_octree_resolution);
    octree_host.setInputCloud (cloud_host);    
    octree_host.addPointsFromInputCloud();
           
    //upload queries
    pcl::gpu::Octree::Queries queries_device;
    queries_device.upload(data.queries);
    
        
    //prepare output buffers on device
    pcl::gpu::NeighborIndices result_device(data.tests_num, 1);
    vector<int> result_host_pcl(data.tests_num);
    vector<int> result_host_gpu(data.tests_num);
    vector<float> dists_pcl(data.tests_num);
    vector<float> dists_gpu(data.tests_num);
    
    //search GPU shared
    octree_device.approxNearestSearch(queries_device, result_device);

    vector<int> downloaded;
    result_device.data.download(downloaded);
                
    for(size_t i = 0; i < data.tests_num; ++i)
    {
        octree_host.approxNearestSearch(data.queries[i], result_host_pcl[i], dists_pcl[i]);
        octree_device.approxNearestSearchHost(data.queries[i], result_host_gpu[i], dists_gpu[i]);
    }

    ASSERT_EQ ( ( downloaded == result_host_gpu ), true );

    int count_gpu_better = 0;
    int count_pcl_better = 0;
    float diff_pcl_better = 0;
    for(size_t i = 0; i < data.tests_num; ++i)
    {
        float diff = dists_pcl[i] - dists_gpu[i];
        bool gpu_better = diff > 0;

        ++(gpu_better ? count_gpu_better : count_pcl_better);

        if (!gpu_better)
            diff_pcl_better +=fabs(diff);
    }

    diff_pcl_better /=count_pcl_better;

    cout << "count_gpu_better: " << count_gpu_better << endl;
    cout << "count_pcl_better: " << count_pcl_better << endl;
    cout << "avg_diff_pcl_better: " << diff_pcl_better << endl;    

}