1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef _PSTL_EXECUTION_POLICY_DEFS_H 11 #define _PSTL_EXECUTION_POLICY_DEFS_H 12 13 #include <__config> 14 #include <__type_traits/decay.h> 15 #include <__type_traits/enable_if.h> 16 #include <__type_traits/integral_constant.h> 17 18 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 19 20 namespace __pstl { 21 namespace execution { 22 inline namespace v1 { 23 24 // 2.4, Sequential execution policy 25 class sequenced_policy {}; 26 27 // 2.5, Parallel execution policy 28 class parallel_policy {}; 29 30 // 2.6, Parallel+Vector execution policy 31 class parallel_unsequenced_policy {}; 32 33 class unsequenced_policy {}; 34 35 // 2.8, Execution policy objects 36 constexpr sequenced_policy seq{}; 37 constexpr parallel_policy par{}; 38 constexpr parallel_unsequenced_policy par_unseq{}; 39 constexpr unsequenced_policy unseq{}; 40 41 // 2.3, Execution policy type trait 42 template <class> 43 struct is_execution_policy : std::false_type {}; 44 45 template <> 46 struct is_execution_policy<__pstl::execution::sequenced_policy> : std::true_type {}; 47 template <> 48 struct is_execution_policy<__pstl::execution::parallel_policy> : std::true_type {}; 49 template <> 50 struct is_execution_policy<__pstl::execution::parallel_unsequenced_policy> : std::true_type {}; 51 template <> 52 struct is_execution_policy<__pstl::execution::unsequenced_policy> : std::true_type {}; 53 54 template <class _Tp> 55 constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy<_Tp>::value; 56 } // namespace v1 57 } // namespace execution 58 59 namespace __internal { 60 template <class _ExecPolicy, class _Tp> 61 using __enable_if_execution_policy = 62 typename std::enable_if<__pstl::execution::is_execution_policy<typename std::decay<_ExecPolicy>::type>::value, 63 _Tp>::type; 64 65 template <class _IsVector> 66 struct __serial_tag; 67 template <class _IsVector> 68 struct __parallel_tag; 69 70 } // namespace __internal 71 72 } // namespace __pstl 73 74 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 75 76 #endif /* _PSTL_EXECUTION_POLICY_DEFS_H */ 77