Parallel algorithms implementation it’s a new feature of C++17 standard. Which allow to use simple STL functions in multiple threads.
At the moment (17.07.2018) only one compiler supports Parallel Algorithms. It’s Visual Studio 2017 ( versions 15.3 and higher).
To build C++ projects with parallel STL you need to build with a flag:
/std:c++17
In C++17 we have a new term – Execution policy
It’s the first parameter to parallel functions from STL. It allows you to choose, how can be function executed. To use it you need to include
#include <execution>
Types of execution policy:
std::seq – without using threads or vectorization, sequenced instructions. This is a default value.
std::par – parallel execution with using threads. When using parallel execution policy, it is the programmer’s responsibility to avoid deadlocks.
std::par_unseq – parallel execution using threads and vectorization or migrating across threads(such as by parent-stealing scheduler). Functions with this policy are permitted to execute in unordered fashion in unspecified threads and unsequenced with other threads.
Continue reading “C++17 Parallel STL (7 new algorithms)”