Hi, I'm new to tbb and like to implement the downward pass of a tree structure. Let's assume we have a binary tree of nodes
struct node { node*parent,*child; int n_all; }; std::vector<node> nodes;
such that node has children child[0] and child[1] if child!=0 and descendants child[0..n_all), all of which have node as ancestor. In a downward pass, a user-provided function f(node*) has to be called such that f(n) is called after f(n->parent). Nodes are ordered such that children come after their parents. Thus, a serial code just loops all nodes in a forward manner as in "for(auto n:nodes) f(n);" In recursive parallelism, one would call f(n) followed by calls to f(n->child) and f(n->child+1), which can be executed in parallel. Eventually, splitting can be avoided by looping all descendants of a node in a forward manner.
How best to implement this using tbb?



