I have code where I have to run parallel_for (independent from each other) at once parallely.
Code is something like:
tbb::parallel_for(range1,func1());//first
tbb::parallel_for(range2,func2());//second
tbb::parallel_for(range3,func3());//third
I have tried using task_group. Is there any other method available?
There are many ways to run any parallel algorithm in parallel, you want just run it inside another parallel algorithm of your choice.
task_group
is just one example. The simplest approach for your case is to useparallel_invoke
:but one can choose to use another
parallel_for
over array of ranges and function pointers, or useparallel_pipeline
,parallel_for_each
, or raw low-leveltbb::task
.