Sequential, parallel, or parallel execution with vectorisation
By using an execution policy in C++17, you can specify whether the algorithm should run sequentially, in parallel, or in parallel with vectorisation.
Execution Policies
The policy tag specifies whether an algorithm should run sequentially, in parallel, or in parallel with vectorisation.
-
std::execution::seq
: runs the algorithm sequentially -
std::execution::par
: runs the algorithm in parallel on multiple threads -
std::execution::par_unseq
: runs the algorithm in parallel on multiple threads and allows the interleaving of individual loops; permits a vectorised version with SIMD (Single Instruction Multiple Data) extensions.
The following code snippet shows all execution policies.