using range() from containers for parallel_reduce

using range() from containers for parallel_reduce

This is probably a stupid question, but after staring at miles of template errors ...

given a tbb::concurrent_hash_map map I want to perform a parallel_reduce on the keys:

tbb::parallel_reduce( map.range(), Body );

where Body contains:

void operator()(tbb::concurrent_hash_map::range_type range) const
for (tbb::concurrent_hash_map::iterator size=range.begin(); size != range.end(); ++size) //...

Apparently map.range() doesn't give the right kind of range object for parallel_reduce??
So into which type and how am I supposed to convert the retval of map.range() so I can plug it into


P.S.: It'd be neat to have an example which actually uses a container and it's range....

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

Try without const.


that actually helped to reduce the errors to something comprehensible...

And did you eventually get things working?

You might also pass the range by const reference instead of by value,
but that shouldn't make any noticeable difference. Maybe if you do make a
mistake in the operation's signature it may ensure a clearer error
message, maybe not. Although... has anyone ever verified whether passing
the range by value allows the compiler to optimise the code without
hoisting range.end() out of the loop, which is always slightly ugly and
inconvenient? And wouldn't it actually be more performant to work from a
copy that can be located in registers than always through a pointer (a
reference is merely a pointer in disguise)? Just wondering...

yep, was easy afterwards.

Leave a Comment

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