pipeline pulus parallel for

pipeline pulus parallel for

in my app, I want to parallelize it with pipeline and parallel for. Each stage characters serial(There are dependence between different items of the same stage), and in each stage, I want to process the data in parallel, now, I do it with parallel_for. But it seems does not work.

My questions are: TBB does not support task parallelism in producer-consumer patter. So, how should I do it?

in my app, I want to parallelize it with pipeline and parallel for. Each stage characters serial(There are dependence between different items of the same stage), and in each stage, I want to process the data in parallel, now, I do it with parallel_for. But it seems does not work.

My questions are: TBB does not support task parallelism in producer-consumer patter. So, how should I do it?

in my app, I want to parallelize it with pipeline and parallel for. Each stage characters serial(There are dependence between different items of the same stage), and in each stage, I want to process the data in parallel, now, I do it with parallel_for. But it seems does not work.

My questions are: TBB does not support task parallelism in producer-consumer patter. So, how should I do it?

In the above example, I set the Number of threads to execute the pipeline like below:

pipeline.run(TheadNum); // ThreadNum = 3, the same number as the number of stages.

If I set up the task schedule for each parallel_for in different stages as:

task_scheduler_init init(4);

parallel_for( blocked_range<int>(0, 4), PASSIN);

what will happened to stages and parallel_for, are there 3 threads for each stage, and another 4 threads for each parallel_for? or there are only 3 threads totally?

It's a common mistake to think that the argument to pipeline.run() is the number of threads. It's not; it's maximal number of items that are allowed to flow through the pipeline at a time. And the motivation for this argument is not restricting concurrency but bounding resource usage (which could otherwise grow "over the top" when a serial filter is the bottleneck in the pipeline).

So if you instruct the task scheduler (via task_scheduler_init) to use 4 threads, that's what you will get (unless the scheduler was initialized earlier, possibly implicitly), no matter what token limit is set for pipeline.