Community
cancel
Showing results for 
Search instead for 
Did you mean: 
uh18104
Beginner
42 Views

Parellel Balanced Binary Tree search with parallel_reduce

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
Black Belt
42 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.
Reply