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

Maximum task number

Daniil_Osokin
Beginner
424 Views

Hi!

Is any restrictions on creating task number, maximum task number?

0 Kudos
1 Solution
RafSchietekat
Valued Contributor III
424 Views
Performance will suffer if you don't practice "recursive parallelism", where every task generates only (roughly) the number of tasks necessary to create "parallel slack" that allows the scheduler to efficiently divide the work for execution with efficient use of the local cache (both aspects are important). Otherwise, feel free to fill physical RAM and even your swap space with tasks before you even start executing them.

View solution in original post

0 Kudos
5 Replies
RafSchietekat
Valued Contributor III
425 Views
Performance will suffer if you don't practice "recursive parallelism", where every task generates only (roughly) the number of tasks necessary to create "parallel slack" that allows the scheduler to efficiently divide the work for execution with efficient use of the local cache (both aspects are important). Otherwise, feel free to fill physical RAM and even your swap space with tasks before you even start executing them.
0 Kudos
jimdempseyatthecove
Honored Contributor III
424 Views
In following up on Raf's comment... Assume you have a large input dataset in a file that can be divided up into a list of tasks. You could program (pseudo code) while read chunk parallel task chunk end while The above could concievably enqueue as many task as there are chunks in your data set (chunk == task sized hunk of data). More importantly, it is concievable (though not probable) that the read loop could complete before the first enqueued task completes. IOW memory filled (or overflowed) with tasks. A better strategy in the above situation is to use the parallel_pipeline or similar strategy, where the read loop (pipe in pipeline) is dependent upon the availability of a buffer (token). Using this method limits the number of pending task to a good (efficient) working set. Jim Dempsey
0 Kudos
RafSchietekat
Valued Contributor III
424 Views
The answer can be given at different levels of detail, of course, and maybe even my warning against the use of large numbers of simultaneous tasks was superfluous. It is always nice when a motivation is given together with a question, so that we don't have to guess what level of detail would be useful, etc. More technically, I am not aware of any relevant artificial restriction, either at any one time, or, I might add, over the lifetime of a program. I remember a problem with an algorithm whose implementation was susceptible to a wraparound problem, but that was above the task level and has since been remedied.
0 Kudos
Daniil_Osokin
Beginner
424 Views
Thanks, guys!
0 Kudos
SergeyKostrov
Valued Contributor II
424 Views
Hi everybody, Daniil, Raf and Jim already answered your question. I'd like to provide some sources. Unfortunately, I don't have a stress test for 'tbb_task' class but I've enclosed a 'tbbthreadtest.txt' file with a stress test for 'tbb_thread' class. Take a look if interested. Best regards, Sergey
0 Kudos
Reply