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


C++ tbb::blocked_range类代码示例

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


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

示例1: operator

MSC_NAMESPACE_BEGIN

void RayBoundingbox::operator()(const tbb::blocked_range< size_t >& r)
{
  size_t begin = r.begin();
  size_t end = r.end();

  m_value.min[0] = m_data[begin].org[0];
  m_value.min[1] = m_data[begin].org[1];
  m_value.min[2] = m_data[begin].org[2];
  m_value.max[0] = m_data[begin].org[0];
  m_value.max[1] = m_data[begin].org[1];
  m_value.max[2] = m_data[begin].org[2];

  for(size_t index = begin; index < end; ++index)
  {
    if(m_data[index].org[0] < m_value.min[0])
      m_value.min[0] = m_data[index].org[0];
    if(m_data[index].org[1] < m_value.min[1])
      m_value.min[1] = m_data[index].org[1];
    if(m_data[index].org[2] < m_value.min[2])
      m_value.min[2] = m_data[index].org[2];

    if(m_data[index].org[0] > m_value.max[0])
      m_value.max[0] = m_data[index].org[0];
    if(m_data[index].org[1] > m_value.max[1])
      m_value.max[1] = m_data[index].org[1];
    if(m_data[index].org[2] > m_value.max[2])
      m_value.max[2] = m_data[index].org[2];
  }
}
开发者ID:francoisgfx,项目名称:msc-project,代码行数:31,代码来源:RayBoundingbox.cpp

示例2: operator

    void operator () (const tbb::blocked_range<int> &range) const {
        for(int i=range.begin(); i<range.end(); i++) {
            list_node *node;
            if (addok(head, i, column)) {
                // add the node

#ifdef QUIT_ON_SOLUTION // QUIT as soon as a solution is found
                if (node!=NULL && solution == NULL) {
#endif
                    list_node new_node;
                    new_node.next = head;
                    new_node.row  = i;
                    if (column+1<SIZE) {
#ifdef CUTOFF
                        if (column+1>=CUTOFF_LEVEL)
                            ser_nqueens_rec(column+1, &new_node);
                        else
                            nqueens_rec(column+1, &new_node);
#else
                        nqueens_rec(column+1, &new_node);
#endif

                    } else { // found a solution 
                        //solution = &new_node;
                        solution_count++; //atomic
                        //abort()
                    }
#ifdef QUIT_ON_SOLUTION // QUIT as soon as a solution is found
                }
#endif
            } // end if addok
        // else do nothing -- dead computation branch
        }
    }
开发者ID:,项目名称:,代码行数:34,代码来源:

示例3: operator

 void operator()( tbb::blocked_range<size_t>& range ) const {
     for( size_t i=range.begin(); i!=range.end(); ++i ) {
         typename M::scoped_lock lock(m_mutex);
         for ( size_t j = 0; j!=range.end(); ++j )
             s_anchor = (s_anchor - i) / 2 + (s_anchor + j) / 2;
     }
 }
开发者ID:Zer0code,项目名称:LoLUpdater,代码行数:7,代码来源:test_ittnotify.cpp

示例4: operator

  void operator()(const tbb::blocked_range<int>& range) const {
    GraphType::SrcSeedList seed_remove_list[2];

    /* compute cuts for each seed using the precomputation graph */
    for (int fg_idx = range.begin(); fg_idx != range.end(); ++fg_idx) {
      // copy the precomputation graph
      GraphType* g_fg_precomp = new GraphType(*g_precomp);
      (*g_fgs_precomp)[fg_idx] = g_fg_precomp;

      // get the fg seeds sans the current seed
      generate_seed_fix_list(seed_remove_list, *fg_nodes, fg_idx);
      // transform all S trees (sans the current seed) to sink
      g_fg_precomp->transform_seed_trees(fg_idx, seed_remove_list);

      g_fg_precomp->check_tree_integrity();

      // generate visualization after the seed tree transformation
      g_fg_precomp->generate_graph_visualization(
          node_rows, ((boost::format("graph1_%d") % (fg_idx + 1)).str()));

      // compute the cut after the precomputation for this seed
      int flow_fg_precomp = run_print_maxflow(g_fg_precomp, *fg_nodes,
                                              node_rows, true);

      // generate visualization after cut computation (and generate final pdf)
      g_fg_precomp->generate_graph_visualization(
          node_rows, ((boost::format("graph2_%d") % (fg_idx + 1)).str()));
      g_fg_precomp->generate_pdf_graphs(
          (boost::format("fg%d_precomp") % (fg_idx + 1)).str());
    }
  }
开发者ID:Cloud-CV,项目名称:object-proposals,代码行数:31,代码来源:test_seedsolve.cpp

示例5: operator

	void operator()(const tbb::blocked_range<int>& r) const
	{
		int begin = r.begin(),
			end = r.end();

		double dmax;
		
		//
		// Define precision(epsilon value)
		double e = .001;
		
		do
		{
			dmax = .0;
			for(int i = begin; i != end; ++i){
				for (int j = 1; j < N; ++j){
					temp_matrix[i][j] = 0.25*(tmatrix[i][j - 1] + tmatrix[i][j + 1] + tmatrix[i - 1][j] + tmatrix[i + 1][j]);
					double diff = fabs(temp_matrix[i][j] - tmatrix[i][j]);
					if (dmax < diff)
						dmax = diff;
					
					tmatrix[i][j] = temp_matrix[i][j];
				}
			}
		} while (dmax > e);
	}
开发者ID:VladGribinchuk,项目名称:CPP_IntelCilk,代码行数:26,代码来源:DerichletTask_usingTBB_Algorithm.cpp

示例6: computeCovarianceMatrix

template <typename PointInT, typename PointOutT> void
pcl::TBB_NormalEstimationTBB<PointInT, PointOutT>::operator () (const tbb::blocked_range <size_t> &r) const
{
  float vpx, vpy, vpz;
  feature_->getViewPoint (vpx, vpy, vpz);
  // Iterating over the entire index vector
  for (size_t idx = r.begin (); idx != r.end (); ++idx)
  {
    std::vector<int> nn_indices (feature_->getKSearch ());
    std::vector<float> nn_dists (feature_->getKSearch ());

    feature_->searchForNeighbors ((*feature_->getIndices ())[idx], feature_->getSearchParameter (), nn_indices, nn_dists);

    // 16-bytes aligned placeholder for the XYZ centroid of a surface patch
    Eigen::Vector4f xyz_centroid;
    // Estimate the XYZ centroid
    compute3DCentroid (*feature_->getSearchSurface (), nn_indices, xyz_centroid);

    // Placeholder for the 3x3 covariance matrix at each surface patch
    EIGEN_ALIGN16 Eigen::Matrix3f covariance_matrix;
    // Compute the 3x3 covariance matrix
    computeCovarianceMatrix (*feature_->getSearchSurface (), nn_indices, xyz_centroid, covariance_matrix);

    // Get the plane normal and surface curvature
    solvePlaneParameters (covariance_matrix,
                          output_.points[idx].normal[0], output_.points[idx].normal[1], output_.points[idx].normal[2], output_.points[idx].curvature);

    flipNormalTowardsViewpoint<PointInT> (feature_->getSearchSurface ()->points[idx], vpx, vpy, vpz,
                                          output_.points[idx].normal[0], output_.points[idx].normal[1], output_.points[idx].normal[2]);
  }
}
开发者ID:jonaswitt,项目名称:nestk,代码行数:31,代码来源:normal_3d_tbb.hpp

示例7: operator

  void operator()(const tbb::blocked_range<int> &range) const {
    fptype price;
    int begin = range.begin();
    int end = range.end();

    for (int i=begin; i!=end; i++) {
      /* Calling main function to calculate option value based on 
       * Black & Scholes's equation.
       */

      price = BlkSchlsEqEuroNoDiv( sptprice[i], strike[i],
                                   rate[i], volatility[i], otime[i], 
                                   otype[i], 0);
      prices[i] = price;

#ifdef ERR_CHK 
      fptype priceDelta = data[i].DGrefval - price;
      if( fabs(priceDelta) >= 1e-5 ){
        fprintf(stderr,"Error on %d. Computed=%.5f, Ref=%.5f, Delta=%.5f\n",
               i, price, data[i].DGrefval, priceDelta);
        numError ++;
      }
#endif
    }
  }
开发者ID:artintal,项目名称:goa2,代码行数:25,代码来源:blackscholes.m4.cpp

示例8: operator

 void operator()(const tbb::blocked_range<uint32>& range) const
 {
     //build index map
     for(uint32 i = range.begin();i != range.end();++i)
     {
         uint16 position = 0;
         uint8 *pBlock = (m_pData + (INDEX_BLOCK_SIZE * i));
         
         //read record
         for(;;)
         {
             if(position > IMAX_RECORD_POS)
                 break;
             
             //get record
             DREC *pDREC = (DREC*)(pBlock + position);
             
             //has data
             if(!IndexBlock::IsEmptyDREC(pDREC))
             {
                 //add key
                 m_pXKeys->push_back(pDREC->m_key);
             }
             
             //update position
             position += sizeof(DREC);
         }
     }
 }
开发者ID:transdb,项目名称:transdb,代码行数:29,代码来源:Storage.cpp

示例9: operator

 /** Increments counter once for each iteration in the iteration space. */
 void operator()( tbb::blocked_range<size_t>& range ) const {
     for( size_t i=range.begin(); i!=range.end(); ++i ) {
         //! Every 8th access is a write access
         const bool write = (i%8)==7;
         bool okay = true;
         bool lock_kept = true;
         if( (i/8)&1 ) {
             // Try implicit acquire and explicit release
             typename I::mutex_type::scoped_lock lock(invariant.mutex,write);
             execute_aux(lock, i, write, /*ref*/okay, /*ref*/lock_kept);
             lock.release();
         } else {
             // Try explicit acquire and implicit release
             typename I::mutex_type::scoped_lock lock;
             lock.acquire(invariant.mutex,write);
             execute_aux(lock, i, write, /*ref*/okay, /*ref*/lock_kept);
         }
         if( !okay ) {
             REPORT( "ERROR for %s at %ld: %s %s %s %s\n",invariant.mutex_name, long(i),
                     write     ? "write,"                  : "read,",
                     write     ? (i%16==7?"downgrade,":"") : (i%8==3?"upgrade,":""),
                     lock_kept ? "lock kept,"              : "lock not kept,", // TODO: only if downgrade/upgrade
                     (i/8)&1   ? "impl/expl"               : "expl/impl" );
         }
     }
 }
开发者ID:AlessioVallero,项目名称:RaspberryPI,代码行数:27,代码来源:test_mutex.cpp

示例10: operator

  void operator()(const tbb::blocked_range<int> &r) const
  {
    u32 numSamples = settings.numSamples;
    numSamples = 1;

    // r contains the scan lines to process
    Color* pp = &buffer[r.begin() * windowSize.x];
    Vector3 p;
    Vector3 tmp2 = tmp;
    tmp2.y += yInc * r.begin();

    for (int y = r.begin(); y < r.end(); ++y)
    {
      p = tmp2;

      for (u32 x = 0; x < windowSize.x; ++x)
      {
        // TODO: all the samples are uniform over the whole pixel. Try a stratisfied approach
        Color col(0,0,0);
        for (u32 i = 0; i < numSamples; ++i)
        {
          // construct ray from eye pos through the image plane
          Vector2 ofs = samples[(sampleIdx++) & 0xff];
          Ray r(cam.frame.origin, Normalize((p + Vector3(ofs.x * xInc, ofs.y * yInc, 0)) - cam.frame.origin));

          col += Radiance(r, 0);
        }

        *pp++ = col / (float)numSamples;

        p.x += xInc;
      }
    }
  }
开发者ID:mrdooz,项目名称:pbr,代码行数:34,代码来源:pathtrace_main.cpp

示例11: operator

  void operator()(const tbb::blocked_range<unsigned>& r) const
  {
    unsigned col, row;
    const int num_ghost = rp_grid_params.num_ghost;
    const int num_eqn = rp_grid_params.num_eqn;
    const int num_aux = rp_grid_params.num_aux;
    const int num_wave = rp_grid_params.num_wave;

    FieldIndexer fi(nx, ny, num_ghost, num_eqn);
    FieldIndexer fi_aux(nx, ny, num_ghost, num_aux);
    EdgeFieldIndexer efi(nx, ny, num_ghost, num_eqn, num_wave);

    for(col = r.begin(); col != std::min(r.end(), efi.num_col_edge_transverse()); ++col) {
      row = efi.num_row_edge_transverse();
      rp(q + fi.idx(row - 1, col), q + fi.idx(row, col),
         aux + fi_aux.idx(row - 1, col), aux + fi_aux.idx(row, col), aux_global, 1,
         amdq + efi.down_edge(row, col), apdq + efi.down_edge(row, col),
         wave + efi.down_edge(row, col), wave_speed + efi.down_edge(row, col));
    }

    for(row = r.begin(); row != std::min(r.end(), efi.num_row_edge_transverse()); ++row){
      col = efi.num_col_edge_transverse();
      rp(q + fi.idx(row, col - 1), q + fi.idx(row, col),
         aux + fi_aux.idx(row, col - 1), aux + fi_aux.idx(row, col), aux_global, 0,
         amdq + efi.left_edge(row, col), apdq + efi.left_edge(row, col),
         wave + efi.left_edge(row, col), wave_speed + efi.left_edge(row, col));
    }
  }
开发者ID:ManyClaw,项目名称:ManyClaw,代码行数:28,代码来源:void_grid_eval.cpp

示例12: operator

    void operator () (const tbb::blocked_range<int> &range) const {
        int i; 
        PARTITIONER partitioner;
        for (i=range.begin(); i<range.end(); i++) {
            //printf("Outer Loop Body[%d<=%d<%d]=[0,%d]\n", range.begin(), i, range.end(), degrees[currentLevelSet[i]]);
#ifdef SEQUENTIAL_INNER
            for(int j=0; j<degrees[currentLevelSet[i]]; j++) {
                int oldGatek;
                int freshNode,currentEdge;

                currentEdge = vertices[currentLevelSet[i]]+j;
                // let's handle one edge
#ifdef XBOFILE
                freshNode = edges[currentEdge][1]; // 0 RTM, value was prefetched
#else
                freshNode = edges[currentEdge];    // 0 RTM, value was prefetched
#endif
                oldGatek = -1;
                // test gatekeeper 
                oldGatek = gatekeeper[freshNode].fetch_and_increment();
                if (oldGatek == 0) { // destination vertex unvisited!
                    // increment newLevelIndex atomically
                    int myIndex = newLevelIndex.fetch_and_increment();
                    // store fresh node in new level
                    newLevelSet[myIndex] = freshNode;
 
                    level[freshNode] = currentLevel + 1;
                } // end if freshNode
            }
#else
            tbb::parallel_for (tbb::blocked_range<int>(0,degrees[currentLevelSet[i]],INNER_GRAINSIZE), innerLoopBody(i), partitioner);
#endif
        }
    }
开发者ID:atzannes,项目名称:TBBBenchmarks,代码行数:34,代码来源:bfs.cpp

示例13: operator

 void operator()(const tbb::blocked_range<IntType> &block)
 {
     long r = res_;
     for (IntType i = block.begin(); i != block.end(); ++i)
         r += i;
     res_ = r;
 }
开发者ID:zhouyan,项目名称:MCKL,代码行数:7,代码来源:FindTBB.cpp

示例14: operator

  void operator()(const tbb::blocked_range<int> &range) const {
    fptype price[NCO];
    fptype priceDelta;
    int begin = range.begin();
    int end = range.end();

    for (int i=begin; i!=end; i+=NCO) {
      /* Calling main function to calculate option value based on 
       * Black & Scholes's equation.
       */

      BlkSchlsEqEuroNoDiv( price, NCO, &(sptprice[i]), &(strike[i]),
                           &(rate[i]), &(volatility[i]), &(otime[i]), 
                           &(otype[i]), 0);
      for (int k=0; k<NCO; k++) {
        prices[i+k] = price[k];

#ifdef ERR_CHK 
        priceDelta = data[i+k].DGrefval - price[k];
        if( fabs(priceDelta) >= 1e-5 ){
          fprintf(stderr,"Error on %d. Computed=%.5f, Ref=%.5f, Delta=%.5f\n",
                 i+k, price, data[i+k].DGrefval, priceDelta);
          numError ++;
        }
#endif
      }
    }
  }
开发者ID:rjw245,项目名称:ee194_final_proj,代码行数:28,代码来源:blackscholes.simd.c

示例15: operator

  void operator()(const tbb::blocked_range<size_t>& r) const
  {
    float sum;
    
    const float* __restrict p = &m_data[0] + r.begin();
    float* __restrict d = &m_output[0]+r.begin();

    float k[n];
    float c[n];
    k[0] = m_kernel[0];
    for (int i = 1; i < n; ++i)
    {
      c[i] = p[i-1];
      k[i] = m_kernel[i];
    }

    for (int i = 0, e = r.size()-n-1; i < e ; i += n) {
      d[i+0] = (c[0] = p[i+0]) * k[0] + c[1]*k[2]+c[2]*k[2]+c[3]*k[3]+c[4]*k[4]+c[5]*k[5]+c[6]*k[6];
      d[i+1] = (c[6] = p[i+1]) * k[0] + c[0]*k[2]+c[1]*k[2]+c[2]*k[3]+c[3]*k[4]+c[4]*k[5]+c[5]*k[6];
      d[i+2] = (c[5] = p[i+2]) * k[0] + c[6]*k[2]+c[0]*k[2]+c[1]*k[3]+c[2]*k[4]+c[3]*k[5]+c[4]*k[6];
      d[i+3] = (c[4] = p[i+3]) * k[0] + c[5]*k[2]+c[6]*k[2]+c[0]*k[3]+c[1]*k[4]+c[2]*k[5]+c[3]*k[6];
      d[i+4] = (c[3] = p[i+4]) * k[0] + c[4]*k[2]+c[5]*k[2]+c[6]*k[3]+c[0]*k[4]+c[1]*k[5]+c[2]*k[6];
      d[i+5] = (c[2] = p[i+5]) * k[0] + c[3]*k[2]+c[4]*k[2]+c[5]*k[3]+c[6]*k[4]+c[0]*k[5]+c[1]*k[6];
      d[i+6] = (c[1] = p[i+6]) * k[0] + c[2]*k[2]+c[3]*k[2]+c[4]*k[3]+c[5]*k[4]+c[6]*k[5]+c[0]*k[6];
    }


  }
开发者ID:cs0rbagomba,项目名称:parallel_programming,代码行数:28,代码来源:itbb_convolution-sergey.cpp


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