Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Daniil_Osokin
Beginner
55 Views

Maximum task number

Jump to solution

Hi!

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

0 Kudos
1 Solution
RafSchietekat
Black Belt
55 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

5 Replies
RafSchietekat
Black Belt
56 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

jimdempseyatthecove
Black Belt
55 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
RafSchietekat
Black Belt
55 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.
Daniil_Osokin
Beginner
55 Views
Thanks, guys!
SergeyKostrov
Valued Contributor II
55 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
Reply