2

I have simple parallel_for loop and results of every iteration I am inserting to concurrent_unordered_map. I see that inserting makes my code much slower. So what is the best way to return pairs from parallel_for to unordered_map? I was trying with Critical_section but it was much slower. I was trying to use combinable, but I haven't idea how to do it with map.

Pseudocode:

concurrent_unordered_map<type, type> my_map;

parallel_for(0, max, [](int i){
  //is a lot of work happening
  my_map.insert(std::pair<type, type>(a, b); //here is bottleneck!!
}, static::partitioner());
yuri kilochek
  • 12,709
  • 2
  • 32
  • 59
Queen
  • 173
  • 1
  • 11

0 Answers0