22 General utilities library [utilities]

22.12 Execution policies [execpol]

22.12.1 General [execpol.general]

Subclause [execpol] describes classes that are execution policy types.
An object of an execution policy type indicates the kinds of parallelism allowed in the execution of an algorithm and expresses the consequent requirements on the element access functions.
Execution policy types are declared in header <execution>.
[Example 1: using namespace std; vector<int> v = /* ... */; // standard sequential sort sort(v.begin(), v.end()); // explicitly sequential sort sort(execution::seq, v.begin(), v.end()); // permitting parallel execution sort(execution::par, v.begin(), v.end()); // permitting vectorization as well sort(execution::par_unseq, v.begin(), v.end()); — end example]
[Note 1: 
Implementations can provide additional execution policies to those described in this document as extensions to address parallel architectures that require idiosyncratic parameters for efficient execution.
— end note]

22.12.2 Execution policy type trait [execpol.type]

template<class T> struct is_execution_policy { see below };
is_execution_policy can be used to detect execution policies for the purpose of excluding function signatures from otherwise ambiguous overload resolution participation.
is_execution_policy<T> is a Cpp17UnaryTypeTrait with a base characteristic of true_type if T is the type of a standard or implementation-defined execution policy, otherwise false_type.
[Note 1: 
This provision reserves the privilege of creating non-standard execution policies to the library implementation.
— end note]
The behavior of a program that adds specializations for is_execution_policy is undefined.

22.12.3 Sequenced execution policy [execpol.seq]

class execution::sequenced_policy { unspecified };
The class execution​::​sequenced_policy is an execution policy type used as a unique type to disambiguate parallel algorithm overloading and require that a parallel algorithm's execution may not be parallelized.
During the execution of a parallel algorithm with the execution​::​sequenced_policy policy, if the invocation of an element access function exits via an exception, terminate is invoked ([except.terminate]).

22.12.4 Parallel execution policy [execpol.par]

class execution::parallel_policy { unspecified };
The class execution​::​parallel_policy is an execution policy type used as a unique type to disambiguate parallel algorithm overloading and indicate that a parallel algorithm's execution may be parallelized.
During the execution of a parallel algorithm with the execution​::​parallel_policy policy, if the invocation of an element access function exits via an exception, terminate is invoked ([except.terminate]).

22.12.5 Parallel and unsequenced execution policy [execpol.parunseq]

class execution::parallel_unsequenced_policy { unspecified };
The class execution​::​parallel_unsequenced_policy is an execution policy type used as a unique type to disambiguate parallel algorithm overloading and indicate that a parallel algorithm's execution may be parallelized and vectorized.
During the execution of a parallel algorithm with the execution​::​parallel_unsequenced_policy policy, if the invocation of an element access function exits via an exception, terminate is invoked ([except.terminate]).

22.12.6 Unsequenced execution policy [execpol.unseq]

class execution::unsequenced_policy { unspecified };
The class unsequenced_policy is an execution policy type used as a unique type to disambiguate parallel algorithm overloading and indicate that a parallel algorithm's execution may be vectorized, e.g., executed on a single thread using instructions that operate on multiple data items.
During the execution of a parallel algorithm with the execution​::​unsequenced_policy policy, if the invocation of an element access function exits via an exception, terminate is invoked ([except.terminate]).

22.12.7 Execution policy objects [execpol.objects]

inline constexpr execution::sequenced_policy execution::seq{ unspecified }; inline constexpr execution::parallel_policy execution::par{ unspecified }; inline constexpr execution::parallel_unsequenced_policy execution::par_unseq{ unspecified }; inline constexpr execution::unsequenced_policy execution::unseq{ unspecified };
The header <execution> declares global objects associated with each type of execution policy.