If the computations you perform can be parallelized, there are two ways you can use that to your advantage. One is by replacing your regular calls to standard library algorithms with parallelizable ones. If you're not familiar with parallel algorithms, they were added in C++17 and in essence are the same algorithms, but you can pass each of them an execution policy. There are three execution policies:
- std::execution::seq: The sequenced policy for the plain-old execution of an algorithm in a non-parallelized way. This one we know too well.
- std::execution::par: A parallel policy that signals that the execution may be parallelized, usually using a thread pool under the hood.
- std::execution::par_unseq: A parallel policy that signals that the execution may be parallelized and vectorized.
- std::execution::unseq: A C++20 addition to the family. This policy signals that the execution can be vectorized, but not parallelized.
If the preceding policies...