Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Need Help for an Implementation.

er_ankushgarg
Beginner
102 Views
Hi All,

I have one task defined as this:

Reader which provides data to parallel parsers(P) , denoted bye this:

task = R , P(1)...P(n)

legend:

R = Reader
P = Parser
R must complete before P(1)...P(n) are started in parallel.

We want to create parallel tasks but the R in task T cannot begin bofore the R in task T-1 is complete.

Readers cannot run in parallel, parsers can run in parallel even between tasks.

So, in time order, the tasks would go in this order in a parallel environment...

"..." means sub-tasks runs that long time.
+ = sub-task completion time.

task T-1: R ......+ P(1) ..... P(n)
|
|
task T: R...+ P(1).....P(n)


How would something like this be accomplished in TBB.


Thanks,
Regards,
Ankush Garg.

0 Kudos
2 Replies
RafSchietekat
Black Belt
102 Views
Use a pipeline with a serial filter for the reader and a parallel filter for the parser.
jimdempseyatthecove
Black Belt
102 Views
As Raf suggests, use a parallel-pipeline. This is an ideal candidate.

>>We want to create parallel tasks but the R in task T cannot begin bofore the R in task T-1 is complete

In a parallel pipeline there is the concept called a token. Pipelinesthe number of tokensfactors into the extent of the desired parallelism (min(number of threads, number of tokens)).The token(s) is(are) passed about such that no two tasks (threads) have possession ofany one tokenat the same time. In your case, the token could contain an I/O buffer plus any other temporary buffers and state variables.

Jim Dempsey
Reply