- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
parallel_reduce?
Thx,
Alex
P.S.: It'd be neat to have an example which actually uses a container and it's range....
given a tbb::concurrent_hash_map
tbb::parallel_reduce( map.range(), Body );
where Body contains:
void operator()(tbb::concurrent_hash_map
{
for (tbb::concurrent_hash_map
}
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
parallel_reduce?
Thx,
Alex
P.S.: It'd be neat to have an example which actually uses a container and it's range....
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try without const.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thx,
that actually helped to reduce the errors to something comprehensible...
that actually helped to reduce the errors to something comprehensible...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yep, was easy afterwards.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page