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


C++ ExecutionEngine::insertTask方法代码示例

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


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

示例1: main

int main(int argc, char **argv){
  int concurrency = 1;
  if (argc>1)
    concurrency = atoi(argv[1]);

  struct timeval t1, t2;
  gettimeofday(&t1, NULL);
  init_device_streams(1);
  gettimeofday(&t2, NULL);
  std::cerr<< "Time DEVICE init: " <<DIFF_TIME(t1, t2) <<" s." <<endl;
  int concurrentThreadsSupported = (int)std::thread::hardware_concurrency();
  if (concurrency > concurrentThreadsSupported - 2)
    concurrency = concurrentThreadsSupported -2 ;
  ExecutionEngine *execEngine = new ExecutionEngine(concurrency , 1, ExecEngineConstants::PRIORITY_QUEUE);
  //ExecutionEngine *execEngine = new ExecutionEngine(2, 1, ExecEngineConstants::FCFS_QUEUE);
  // int nextTaskDependency;
  //std::cerr  << "Number of threads: [" << concurentThreadsSupported << "]" <<std::endl;
  // Creates first task, which does not have dependencies
  JoinTask *ts = new JoinTask(JCARDINALITY);
  size_t pos, pos2;
  string input_line;
  string tid ;
  string prev_tid = "";

  std::cerr << "I/O" ;
  while(cin && getline(cin, input_line) && !cin.eof()) {
    pos=input_line.find_first_of(TAB,0);
    if (pos == string::npos){
      cerr << "no TAB in the input! We are toasted." << endl;
      return 1; // failure
    }

    tid= input_line.substr(0,pos); // tile id

    // finished reading in a tile data, so perform cross matching
    if (0 != tid.compare(prev_tid) && prev_tid.size()>0) 
    {
      ts->setSpeedup(ExecEngineConstants::GPU, 
                     gpuSpeedUp(ts->nr_vertices[0],
                                ts->nr_vertices[1],
                                ts->geom_arr[0]->size(), 
                                ts->geom_arr[1]->size()));
      ts->setSpeedup(ExecEngineConstants::CPU, 
                     cpuSpeedUp(ts->nr_vertices[0],
                                ts->nr_vertices[1],
                                ts->geom_arr[0]->size(), 
                                ts->geom_arr[1]->size()));
      // Dispatches current tasks for execution
      //std::cerr << ts->getId() << "-------" << prev_tid<< std::endl;
      execEngine->insertTask(ts);
      ts = new JoinTask(JCARDINALITY);
      std::cerr << "  [" <<prev_tid << "]" ;
    }
    // actual geometry info: did,oid,num_ver,mbb, geom
    int i = input_line[pos+1] - '1'; // array position 
    pos2=input_line.find_first_of(COMMA,pos+3); //oid = input_line.substr(pos+3,pos2-pos-3) 
    pos=input_line.find_first_of(COMMA,pos2+1); //num_ver = input_line.substr(pos2+1,pos)
    ts->nr_vertices[i] += std::stoi(input_line.substr(pos2+1,pos-pos2-1));
    ts->geom_arr[i]->push_back(input_line.substr(pos2+1)); // mbb, geom
    prev_tid = tid; 
  }
  ts->setSpeedup(ExecEngineConstants::CPU, 
                     gpuSpeedUp(ts->nr_vertices[0],
                                ts->nr_vertices[1],
                                ts->geom_arr[0]->size(), 
                                ts->geom_arr[1]->size()));
  ts->setSpeedup(ExecEngineConstants::GPU, 
                 gpuSpeedUp(ts->nr_vertices[0],
                            ts->nr_vertices[1],
                            ts->geom_arr[0]->size(), 
                            ts->geom_arr[1]->size()));
  // Dispatches current tasks for execution
  execEngine->insertTask(ts);
  std::cerr << "  ["<<tid << "]" << std::endl;

  // Computing threads startup consuming tasks
  execEngine->startupExecution();

  // No more task will be assigned for execution. Waits
  // until all currently assigned have finished.
  execEngine->endExecution();

  fini_device_streams(1);
  delete execEngine;

  return 0;
}
开发者ID:ablimit,项目名称:hadoopgis,代码行数:87,代码来源:JoinEngine.cpp

示例2: main

int main(int argc, char **argv){
  if (argc <2)
  {
    std::cerr <<"Missing argument.. " << endl;
    return 0;
  }
  int loop = atoi (argv[1] ); 
  struct timeval t1, t2;
  gettimeofday(&t1, NULL);
  init_device_streams(1);
  gettimeofday(&t2, NULL);
  std::cerr<< "Time DEVICE init: " <<DIFF_TIME(t1, t2) <<" s." <<endl;
  int concurentThreadsSupported = (int)std::thread::hardware_concurrency();
  //ExecutionEngine *execEngine = new ExecutionEngine(2, 1, ExecEngineConstants::FCFS_QUEUE);
  // int nextTaskDependency;
  //std::cerr  << "Number of threads: [" << concurentThreadsSupported << "]" <<std::endl;
  // Creates first task, which does not have dependencies
  size_t pos, pos2;
  string input_line;
  string tid ;
  string prev_tid = "";

  std::cerr << "I/O" ;
  while(cin && getline(cin, input_line) && !cin.eof()) {
    pos=input_line.find_first_of(TAB,0);
    if (pos == string::npos){
      cerr << "no TAB in the input! We are toasted." << endl;
      return 1; // failure
    }

    tid= input_line.substr(0,pos); // tile id
    if (0 != tid.compare(prev_tid) && prev_tid.size()>0) 
      std::cerr << "  [" <<prev_tid << "]" ;
    // actual geometry info: did,oid,num_ver,mbb, geom
    int i = input_line[pos+1] - '1'; // array position 
    pos2=input_line.find_first_of(COMMA,pos+3); //oid = input_line.substr(pos+3,pos2-pos-3) 
    pos=input_line.find_first_of(COMMA,pos2+1); //num_ver = input_line.substr(pos2+1,pos)
    vertexes[tid][i] += std::stoi(input_line.substr(pos2+1,pos-pos2-1));
    geoms[tid][i].push_back(input_line.substr(pos2+1)); // mbb, geom
    prev_tid = tid; 
  }
  std::cerr << std::endl;

  JoinTask *jt = NULL;
    map<string,map<int,vector<string> > >::iterator it;
    map<string,map<int,int> >::iterator vertexes_iter;
  while (loop-- > 0) {
    std::cerr << "-------------------------------------------------------------------------" << std::endl;

    ExecutionEngine *execEngine = new ExecutionEngine(concurentThreadsSupported-1, 1, ExecEngineConstants::PRIORITY_QUEUE);

    // for each tile 
    for (it=geoms.begin(); it !=geoms.end(); ++it)
    {
      jt = new JoinTask(JCARDINALITY);

      for (int i = 0 ; i < JCARDINALITY; i++){
      jt->nr_vertices[i] = vertexes[it->first][i];

      jt->geom_arr[i]->assign(
          geoms[it->first][i].begin(),
          geoms[it->first][i].end());
      }
      jt->setSpeedup(ExecEngineConstants::GPU, 
                     gpuSpeedUp(jt->nr_vertices[0],
                                jt->nr_vertices[1],
                                jt->geom_arr[0]->size(), 
                                jt->geom_arr[1]->size()));
      jt->setSpeedup(ExecEngineConstants::CPU, 
                     cpuSpeedUp(jt->nr_vertices[0],
                                jt->nr_vertices[1],
                                jt->geom_arr[0]->size(), 
                                jt->geom_arr[1]->size()));
      // Dispatches current tasks for execution
      //std::cerr << ts->getId() << "-------" << prev_tid<< std::endl;
      execEngine->insertTask(jt);
    }

    // Computing threads startup consuming tasks
    execEngine->startupExecution();

    // No more task will be assigned for execution. Waits
    // until all currently assigned have finished.
    execEngine->endExecution();

    delete execEngine;
  }
  fini_device_streams(1);
  return 0;
}
开发者ID:ablimit,项目名称:hadoopgis,代码行数:90,代码来源:TestJoinEngine.cpp


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