2019-08-05 18:29:14 +00:00
|
|
|
// -*- C++ -*-
|
2021-11-17 16:25:01 -05:00
|
|
|
//===----------------------------------------------------------------------===//
|
2019-08-05 18:29:14 +00:00
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_EXECUTION
|
|
|
|
#define _LIBCPP_EXECUTION
|
|
|
|
|
2023-01-13 22:48:23 +01:00
|
|
|
/*
|
|
|
|
namespace std::execution {
|
|
|
|
struct sequenced_policy;
|
|
|
|
struct parallel_policy;
|
|
|
|
struct parallel_unsequenced_policy;
|
|
|
|
struct unsequenced_policy; // since C++20
|
|
|
|
|
|
|
|
inline constexpr sequenced_policy seq = implementation-defined;
|
|
|
|
inline constexpr parallel_policy par = implementation-defined;
|
|
|
|
inline constexpr parallel_unsequenced_policy par_unseq = implementation-defined;
|
|
|
|
inline constexpr unsequenced_policy unseq = implementation-defined; // since C++20
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
template <class T>
|
|
|
|
struct is_execution_policy;
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
inline constexpr bool is_execution_policy_v;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2024-12-21 13:01:48 +01:00
|
|
|
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
|
2025-04-09 15:00:46 +02:00
|
|
|
# include <__cxx03/__config>
|
2024-12-21 13:01:48 +01:00
|
|
|
#else
|
2024-12-10 16:02:12 +01:00
|
|
|
# include <__config>
|
|
|
|
# include <__type_traits/is_execution_policy.h>
|
|
|
|
# include <__type_traits/is_same.h>
|
|
|
|
# include <__type_traits/remove_cvref.h>
|
|
|
|
# include <version>
|
|
|
|
|
|
|
|
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
|
|
# pragma GCC system_header
|
|
|
|
# endif
|
2021-12-05 13:08:36 -05:00
|
|
|
|
2025-01-24 09:34:42 +01:00
|
|
|
# if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
|
2023-01-13 22:48:23 +01:00
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
|
|
|
namespace execution {
|
|
|
|
struct sequenced_policy {
|
2023-04-28 11:02:46 -07:00
|
|
|
_LIBCPP_HIDE_FROM_ABI constexpr explicit sequenced_policy(__disable_user_instantiations_tag) {}
|
2023-01-13 22:48:23 +01:00
|
|
|
sequenced_policy(const sequenced_policy&) = delete;
|
|
|
|
sequenced_policy& operator=(const sequenced_policy&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline constexpr sequenced_policy seq{__disable_user_instantiations_tag{}};
|
|
|
|
|
|
|
|
struct parallel_policy {
|
2023-04-28 11:02:46 -07:00
|
|
|
_LIBCPP_HIDE_FROM_ABI constexpr explicit parallel_policy(__disable_user_instantiations_tag) {}
|
2023-01-13 22:48:23 +01:00
|
|
|
parallel_policy(const parallel_policy&) = delete;
|
|
|
|
parallel_policy& operator=(const parallel_policy&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline constexpr parallel_policy par{__disable_user_instantiations_tag{}};
|
|
|
|
|
|
|
|
struct parallel_unsequenced_policy {
|
2023-04-28 11:02:46 -07:00
|
|
|
_LIBCPP_HIDE_FROM_ABI constexpr explicit parallel_unsequenced_policy(__disable_user_instantiations_tag) {}
|
2023-01-13 22:48:23 +01:00
|
|
|
parallel_unsequenced_policy(const parallel_unsequenced_policy&) = delete;
|
|
|
|
parallel_unsequenced_policy& operator=(const parallel_unsequenced_policy&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline constexpr parallel_unsequenced_policy par_unseq{__disable_user_instantiations_tag{}};
|
|
|
|
|
2023-01-14 02:08:27 +01:00
|
|
|
struct __unsequenced_policy {
|
2023-04-28 11:02:46 -07:00
|
|
|
_LIBCPP_HIDE_FROM_ABI constexpr explicit __unsequenced_policy(__disable_user_instantiations_tag) {}
|
2023-01-14 02:08:27 +01:00
|
|
|
__unsequenced_policy(const __unsequenced_policy&) = delete;
|
|
|
|
__unsequenced_policy& operator=(const __unsequenced_policy&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr __unsequenced_policy __unseq{__disable_user_instantiations_tag{}};
|
|
|
|
|
2024-12-10 16:02:12 +01:00
|
|
|
# if _LIBCPP_STD_VER >= 20
|
2023-01-13 22:48:23 +01:00
|
|
|
|
|
|
|
struct unsequenced_policy {
|
2023-05-02 10:48:00 -07:00
|
|
|
_LIBCPP_HIDE_FROM_ABI constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {}
|
2023-01-13 22:48:23 +01:00
|
|
|
unsequenced_policy(const unsequenced_policy&) = delete;
|
|
|
|
unsequenced_policy& operator=(const unsequenced_policy&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}};
|
|
|
|
|
2024-12-10 16:02:12 +01:00
|
|
|
# endif // _LIBCPP_STD_VER >= 20
|
2023-01-13 22:48:23 +01:00
|
|
|
|
|
|
|
} // namespace execution
|
|
|
|
|
2025-01-23 13:18:54 +01:00
|
|
|
_LIBCPP_DIAGNOSTIC_PUSH
|
|
|
|
# if __has_warning("-Winvalid-specialization")
|
|
|
|
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
|
|
|
|
# endif
|
2023-01-13 22:48:23 +01:00
|
|
|
template <>
|
|
|
|
inline constexpr bool is_execution_policy_v<execution::sequenced_policy> = true;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline constexpr bool is_execution_policy_v<execution::parallel_policy> = true;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline constexpr bool is_execution_policy_v<execution::parallel_unsequenced_policy> = true;
|
|
|
|
|
2023-01-14 02:08:27 +01:00
|
|
|
template <>
|
|
|
|
inline constexpr bool is_execution_policy_v<execution::__unsequenced_policy> = true;
|
2025-01-23 13:18:54 +01:00
|
|
|
_LIBCPP_DIAGNOSTIC_POP
|
2023-01-14 02:08:27 +01:00
|
|
|
|
|
|
|
template <>
|
|
|
|
inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_policy> = true;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_unsequenced_policy> = true;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::__unsequenced_policy> = true;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::parallel_unsequenced_policy> = true;
|
|
|
|
|
2024-12-10 16:02:12 +01:00
|
|
|
# if _LIBCPP_STD_VER >= 20
|
2025-01-23 13:18:54 +01:00
|
|
|
_LIBCPP_DIAGNOSTIC_PUSH
|
|
|
|
# if __has_warning("-Winvalid-specialization")
|
|
|
|
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
|
|
|
|
# endif
|
2023-01-13 22:48:23 +01:00
|
|
|
template <>
|
|
|
|
inline constexpr bool is_execution_policy_v<execution::unsequenced_policy> = true;
|
2025-01-23 13:18:54 +01:00
|
|
|
_LIBCPP_DIAGNOSTIC_POP
|
2023-01-14 02:08:27 +01:00
|
|
|
|
|
|
|
template <>
|
|
|
|
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::unsequenced_policy> = true;
|
|
|
|
|
2024-12-10 16:02:12 +01:00
|
|
|
# endif
|
2023-01-13 22:48:23 +01:00
|
|
|
|
|
|
|
template <class _Tp>
|
2025-01-23 13:18:54 +01:00
|
|
|
struct _LIBCPP_NO_SPECIALIZATIONS is_execution_policy : bool_constant<is_execution_policy_v<_Tp>> {};
|
2023-01-13 22:48:23 +01:00
|
|
|
|
2023-01-14 02:08:27 +01:00
|
|
|
template <class _ExecutionPolicy>
|
2023-05-09 07:54:59 -07:00
|
|
|
_LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) {
|
|
|
|
if constexpr (is_same_v<_ExecutionPolicy, execution::parallel_policy>) {
|
|
|
|
return execution::sequenced_policy(execution::__disable_user_instantiations_tag{});
|
|
|
|
} else if constexpr (is_same_v<_ExecutionPolicy, execution::parallel_unsequenced_policy>) {
|
|
|
|
return execution::__unsequenced_policy{execution::__disable_user_instantiations_tag{}};
|
2023-01-14 02:08:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 22:48:23 +01:00
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
2025-01-24 09:34:42 +01:00
|
|
|
# endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
|
2023-01-13 22:48:23 +01:00
|
|
|
|
2024-12-10 16:02:12 +01:00
|
|
|
# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
|
|
|
|
# include <cstddef>
|
|
|
|
# endif
|
2024-12-21 13:01:48 +01:00
|
|
|
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
|
2024-03-18 13:57:07 +01:00
|
|
|
|
2019-08-05 18:29:14 +00:00
|
|
|
#endif // _LIBCPP_EXECUTION
|