3

I have a function that I need to run twice with different data parameters. This function takes long time to run and does heavy computational job.

How I can do that, with which TBB mechanism? Or not even TBB, if I can do this with STL, please give me an example.

UPD:

For example I have a function that takes as a parameter image and does some processing to it:

int Compute(cv::Mat I) { /* computations */ return 0; } void callf(cv::Mat I1, cv::Mat I2) { // make call of this functions parallel Compute(I1); Compute(I2); } 
2
  • Do you mean templates? Without knowing what exactly you are trying to do, it would be difficult to suggest any STL data structure. Commented May 12, 2016 at 10:25
  • So you mean threading? Maybe have a look at std::thread Commented May 12, 2016 at 11:30

1 Answer 1

5

You can use tbb::task_group or tbb::parallel_invoke in conjunction with lambda functions like here:

void callf(cv::Mat I1, cv::Mat I2) { // make call of this functions parallel tbb::parallel_invoke( [&]{ Compute(I1); }, [&]{ Compute(I2); } ); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.