Skip to content

Commit

Permalink
Try replacing a task group with a parallel for.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescarni committed Nov 7, 2018
1 parent 17b346c commit 4606ce6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions include/rakau/tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,11 @@ class tree
const code_shifter cs((cbits - ParentLevel - 1u) * NDim);
const auto t_begin = boost::make_transform_iterator(begin, cs),
t_end = boost::make_transform_iterator(end, cs);
tbb::task_group tg;
for (UInt i = 0; i < (UInt(1) << NDim); ++i) {
tg.run([node_prefix, i, t_begin, t_end, &trees, parent_code, this, &retval, split_level, crit_ancestor,
&crit_nodes] {
tbb::parallel_for(tbb::blocked_range<UInt>(0u, UInt(1) << NDim), [node_prefix, t_begin, t_end, &trees,
parent_code, this, &retval, split_level,
crit_ancestor,
&crit_nodes](const auto &range) {
for (auto i = range.begin(); i != range.end(); ++i) {
const auto [it_start, it_end]
= std::equal_range(t_begin, t_end, static_cast<UInt>((node_prefix << NDim) + i));
const auto npart = std::distance(it_start, it_end);
Expand Down Expand Up @@ -625,9 +626,8 @@ class tree
checked_uinc(retval, new_tree[0].n_children);
checked_uinc(retval, size_type(1));
}
});
}
tg.wait();
}
});
return retval.load();
} else {
return 0;
Expand Down

0 comments on commit 4606ce6

Please sign in to comment.