Parellel Balanced Binary Tree search with parallel_reduce

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 {
int mygs; // local grainsize

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();

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.

Leave a Comment

Please sign in to add a comment. Not a member? Join today