c++ - TBB task_groups without using stack -


i perform post-order tree traversal in c++. tree can deep cannot use recursion (it exhausts stack). instead create std::stack<...> puts on heap, , traverse tree in while loop rather function calls. works great.

now parallelize whole process using tbb. thinking of creating task_group @ every node, , running same functor on each of children. occurs me run same problem tree depth had before: running functor on each node of deepest path eat away stack until whole thing runs out.

is there way out of problem? or imagining whole thing; there magic behind task_group::wait() avoids problem?

from tbb documentation (about implicit continuation):

because parent blocks, thread’s stack cannot popped yet. thread must careful work takes on, because continually stealing , blocking cause stack grow without bound.

this not that, shows tbb not using stack magic empty stack blocked tasks. means stack-overflows bit later (spreaded among multiple thread's stacks) when using implicit continuation.

using explicit continuation might solve problem, depends heavily on internal tbb implementation of thread scheduler (which not documented). there fair chance work correctly - way know either through tbb sources amd see how task handled, or write simple test program small stack , if simple able exhaust it.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -