0

I have this program that is using vector and unordered_map now when I am building them I am reading from a serial file so practically I can't parallelize the building process but when I use them further in my program I can read from them in parallel "note : I don't modify any values on those containers"

So I am going to parallelize this program when reading is it useful to use concurrent containers provided by intel tbb. because I have timed my algorithm in serial without them and it takes 1.4 seconds to finish but when I integrate them without any parallelism the performance of the program is 4 seconds!

Can anybody explain why this degradation, and should I use them since they are somewhat thread safe?

Stephan Dollberg
  • 32,985
  • 16
  • 81
  • 107
aTm
  • 79
  • 2
  • 10

1 Answers1

1

If you are not changing the containers and the values, you can avoid the extra "concurrent" overhead by using a serial version. Be careful with the map, to not use the operator[] as that can change the container if the value you are looking up is not in the map.

Notice that your timing differences can come from different sources, like excessive thread spwaning, locking overhead, wrong measurements ...

Stephan Dollberg
  • 32,985
  • 16
  • 81
  • 107