Do the C++ STL algorithms use multiple-cores of the CPU under the hood for faster performance? If not, are there any recommended libraries to do what does STL does but with multiple cores, say using OpenMP? Or are there any switches one can specify during compilation with gcc instructing STL to use multiple cores
EDIT: I am using Intel Core i7 960 processors, on Ubuntu 10.10 with gcc 4.4
GNU libstdc++ seems to have a parallel mode that supports several parallelization features for STL:
http://gcc.gnu.org/onlinedocs/libstdc++/manual/parallel_mode.html
I know of no STL implementation that leverages multiple cores. Even if one does exist, you need to ensure that the added complexity ends up as a net benefit. The types of algorithms STL provides (sort, accumulate, etc.) benefit from parallelism only in fairly extreme circumstances (e.g. > 10 million elements). If you only leverage parallelism at the STL level, you are probably going to be disappointed in the results.
I would look at Intel's TBB (http://threadingbuildingblocks.org/) which provides a task-based parallelism framework. It encourages algorithm design that is amenable to task-based scheduling and not just a bunch of leaf functions (e.g. parallel_sort() although TBB does provide one).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With