0

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 !

sub_o
  • 2,642
  • 5
  • 28
  • 41
  • 2
    use [functor](http://stackoverflow.com/a/356993/1762344) or [`std::bind`](http://en.cppreference.com/w/cpp/utility/functional/bind) – Evgeny Panasyuk Apr 15 '13 at 09:39

1 Answers1

1

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.

Arch D. Robison
  • 3,829
  • 2
  • 16
  • 26