Community
cancel
Showing results for 
Search instead for 
Did you mean: 
nagy
New Contributor I
68 Views

Implicit vs Explicit Task Creation

What are the performance differences between implicit task creation e.g
[cpp]tbb::parallel_invoke
[&]
{
    tbb::parallel_invoke
    [&]
    {
         tbb::parallel_for( /* .... */ );
    },
    [&]
    {
       // Work
    });
},
[&]
{
    // Work
});[/cpp]
vs explicitly allocating tasks, spawning them, and maybe recycling them.
0 Kudos
8 Replies
Dmitry_Vyukov
Valued Contributor I
68 Views

In general, implicit task creation (especially algorithms like parallel_for) should be considered as more efficient, because that way your program communicates much more information to a tasking library. A library receives information about algorithm structure, total task count, task sizes (algorithms like parallel_for assume roughly equal size tasks), etc. While with explicit task creation a tasking library operates mostly "blindly".

RafSchietekat
Black Belt
68 Views

Really? I would say that the algorithms have been designed to use tasks well, by the same team and with incremental improvements based on experience, so they would be difficult to match or improve upon economically, but I'm not sure that there's much going on in the other direction. Do you have any examples?

Dmitry_Vyukov
Valued Contributor I
68 Views

What do you mean by "other direction"? And examples of what do you want?
RafSchietekat
Black Belt
68 Views

Algorithms try to use tasks efficiently (they're built on top of facilities provided by the scheduler), but do you have examples of what tasks know about algorithms (the "other direction")?
Dmitry_Vyukov
Valued Contributor I
68 Views

No, I don't have. And I doubt they exist.

RafSchietekat
Black Belt
68 Views

Then I guess I don't understand what you mean by "While with explicit task creation a tasking library operates mostly "blindly"".

Dmitry_Vyukov
Valued Contributor I
68 Views

I meant that tasking library executes explicit tasks without any high-level optimizations, because it does not have any information on algorithm structure, total number of tasks, task sizes, etc.
RafSchietekat
Black Belt
68 Views

What "high-level optimisations" that you couldn't apply yourself if you really wanted to reinvent the wheel or if you had a need not currently provided for by the provided algorithms? Do they use significant private API, perhaps? I would have to look through the sources to find out for myself, but, whileit seems interesting,it would be far easier for you to prove a positive than for me to prove a negative. :-)

Reply