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

Parellel Balanced Binary Tree search with parallel_reduce

uh18104
Beginner
160 Views
I wonder what would be the best way to split tree to perform parallel reduce. I used the following. But, doesn't work. Thanks in advance.

class Range {
private:
int mygs; // local grainsize
public:
TreeNode *mytree;
Range(TreeNode *t, int grainsize) :mytree(t), mygs(grainsize) {}
Range(SearchByNameRange &r, split) {
if (r.mytree->left) {
mytree = r.mytree->left;
}
else if (r.mytree->right) {
mytree = r.mytree->right;
}
}
bool empty() const {
return (mytree == NULL);
}
bool is_divisible() const {
if(size() > mygs) return true;
return false;
}
int size() const {
return mytree->size();
}
};


0 Kudos
1 Reply
RafSchietekat
Valued Contributor III
160 Views
Why does the splitting constructor take a different type? And of course the splitting constructor has to actually split, i.e., r has to be affected as well. Note that TBB assumes associativity, so I wonder whether parallel_reduce would work for a reduction that has to visit subtrees first.
0 Kudos
Reply