Reputation: 347
I want to traverse my std::map
in parallel with parallel_for
.
As the tutorial says, we cannot randomly access it, so I chose parallel_for_each
.
std::map<std::string, std::string> map_; // student name, student age
tbb::parallel_for_each(map_.begin(), map_.end(), [&](const auto& item) {
processOne worker;
worker(item.first, map_.size());
});
But it seems that parallel_for_each
will not chunk the map into subtasks, so it is quite slow.
Is it possible to do something like this?
tbb::parallel_for(tbb::blocked_range<int>(0, map_.size(), 10000), [&](tbb::blocked_range<int> r) {
...
});
Upvotes: 1
Views: 90