本文整理汇总了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];
}
}
示例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
}
}
示例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;
}
}
示例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());
}
}
示例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);
}
示例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]);
}
}
示例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
}
}
示例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);
}
}
}
示例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" );
}
}
}
示例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;
}
}
}
示例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));
}
}
示例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
}
}
示例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;
}
示例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
}
}
}
示例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];
}
}