1 | initial version |
If you don't see ten times "start" it's because the parallel framework doesn't launch as many threads as your range. Write this instead:
void ParallelClass::operator()( const cv::Range & r ) const {
// loop for the range
for( int i = r.start ; r < r.end ; ++r ) {
std::cout << "start" << std::endl;
}
}
Therefore you will see your start written 10 times. The reason is the parallel binding used (concurency, tbb, etc.) cut your loop in smaller pieces, and you still need to execute your code for a range (argument is a range not an index), sometimes the range could be one, but it's an exception, not the norm.
2 | fix typo |
If you don't see ten times "start" it's because the parallel framework doesn't launch as many threads as your range. Write this instead:
void ParallelClass::operator()( const cv::Range & r ) const {
// loop for the range
for( int i = r.start ; r i < r.end ; ++r ) {
std::cout << "start" << std::endl;
}
}
Therefore you will see your start written 10 times. The reason is the parallel binding used (concurency, tbb, etc.) cut your loop in smaller pieces, and you still need to execute your code for a range (argument is a range not an index), sometimes the range could be one, but it's an exception, not the norm.