Reputation: 1332
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);
}
Upvotes: 3
Views: 762
Reputation: 6587
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); }
);
}
Upvotes: 5