sub_o
sub_o

Reputation: 2802

How to specify loop step in Intel TBB's parallel_for loop?

I wanted to do something like this (pseudo code) utilizing intel TBB's library:

some function( int index, Mat data, vector<int> other ) {

}

int start = 0
int end = 100
int step = 5

parallel_for( start, end, step, some function )

However I'm not sure how to pass the additional arguments into 'some function'. What should I do in order to be able to pass my additional data to the parallelized function, without making them static / global ?

I understand that you could do that using C++'s lambda function, however due to some circumstances (clashes with other libraries), I'm unable to use it.

In addition to that, I know that we could use Range to specify the loop range, however, is there any way I could set the loop step inside the Range ?

I'd like to thank you in advance !

Upvotes: 0

Views: 1293

Answers (1)

Arch D. Robison
Arch D. Robison

Reputation: 4059

Please see the example at http://software.intel.com/sites/products/documentation/doclib/tbb_sa/help/hh_goto.htm#tbb_userguide/parallel_for.htm . It shows how to hand-roll a functor for parallel_for.

Upvotes: 1

Related Questions