diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -480,7 +480,6 @@ __numeric/transform_inclusive_scan.h __numeric/transform_reduce.h __pstl_algorithm - __pstl_execution __pstl_memory __pstl_numeric __random/bernoulli_distribution.h @@ -854,7 +853,6 @@ pstl/internal/execution_impl.h pstl/internal/glue_algorithm_defs.h pstl/internal/glue_algorithm_impl.h - pstl/internal/glue_execution_defs.h pstl/internal/glue_memory_defs.h pstl/internal/glue_memory_impl.h pstl/internal/glue_numeric_defs.h diff --git a/libcxx/include/__pstl_execution b/libcxx/include/__pstl_execution deleted file mode 100644 --- a/libcxx/include/__pstl_execution +++ /dev/null @@ -1,15 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// 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 __PSTL_EXECUTION -#define __PSTL_EXECUTION - -#include - -#endif /* __PSTL_EXECUTION */ diff --git a/libcxx/include/execution b/libcxx/include/execution --- a/libcxx/include/execution +++ b/libcxx/include/execution @@ -12,14 +12,82 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__type_traits/integral_constant.h> #include -#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 -# include <__pstl_execution> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace execution { +struct __disable_user_instantiations_tag { + explicit __disable_user_instantiations_tag() = default; +}; + +struct sequenced_policy { + constexpr explicit sequenced_policy(__disable_user_instantiations_tag) {} + sequenced_policy(const sequenced_policy&) = delete; + sequenced_policy& operator=(const sequenced_policy&) = delete; +}; + +constexpr sequenced_policy seq{__disable_user_instantiations_tag{}}; + +struct parallel_policy { + constexpr explicit parallel_policy(__disable_user_instantiations_tag) {} + parallel_policy(const parallel_policy&) = delete; + parallel_policy& operator=(const parallel_policy&) = delete; +}; + +constexpr parallel_policy par{__disable_user_instantiations_tag{}}; + +struct parallel_unsequenced_policy { + constexpr explicit parallel_unsequenced_policy(__disable_user_instantiations_tag) {} + parallel_unsequenced_policy(const parallel_unsequenced_policy&) = delete; + parallel_unsequenced_policy& operator=(const parallel_unsequenced_policy&) = delete; +}; + +constexpr parallel_unsequenced_policy par_unseq{__disable_user_instantiations_tag{}}; + +# if _LIBCPP_STD_VER >= 20 + +struct unsequenced_policy { + constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {} + unsequenced_policy(const unsequenced_policy&) = delete; + unsequenced_policy& operator=(const unsequenced_policy&) = delete; +}; + +constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}}; + +# endif // _LIBCPP_STD_VER >= 20 + +} // namespace execution + +template +inline constexpr bool is_execution_policy_v = false; + +template <> +inline constexpr bool is_execution_policy_v = true; + +template <> +inline constexpr bool is_execution_policy_v = true; + +template <> +inline constexpr bool is_execution_policy_v = true; + +# if _LIBCPP_STD_VER >= 20 +template <> +inline constexpr bool is_execution_policy_v = true; +# endif + +template +struct is_execution_policy : bool_constant> {}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 + #endif // _LIBCPP_EXECUTION diff --git a/libcxx/include/pstl/internal/glue_execution_defs.h b/libcxx/include/pstl/internal/glue_execution_defs.h deleted file mode 100644 --- a/libcxx/include/pstl/internal/glue_execution_defs.h +++ /dev/null @@ -1,53 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// 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 _PSTL_GLUE_EXECUTION_DEFS_H -#define _PSTL_GLUE_EXECUTION_DEFS_H - -#include - -#include "execution_defs.h" -#include "pstl_config.h" - -namespace std { -// Type trait -using __pstl::execution::is_execution_policy; -#if defined(_PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT) -# if defined(__INTEL_COMPILER) -template -constexpr bool is_execution_policy_v = is_execution_policy::value; -# else -using __pstl::execution::is_execution_policy_v; -# endif -#endif - -namespace execution { -// Standard C++ policy classes -using __pstl::execution::parallel_policy; -using __pstl::execution::parallel_unsequenced_policy; -using __pstl::execution::sequenced_policy; - -// Standard predefined policy instances -using __pstl::execution::par; -using __pstl::execution::par_unseq; -using __pstl::execution::seq; - -// Implementation-defined names -// Unsequenced policy is not yet standard, but for consistency -// we include it into namespace std::execution as well -using __pstl::execution::unseq; -using __pstl::execution::unsequenced_policy; -} // namespace execution -} // namespace std - -#include "algorithm_impl.h" -#include "numeric_impl.h" -#include "parallel_backend.h" - -#endif /* _PSTL_GLUE_EXECUTION_DEFS_H */ diff --git a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp --- a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp +++ b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp @@ -9,8 +9,6 @@ // Test that headers are not tripped up by the surrounding code defining the // min() and max() macros. -// XFAIL: with-pstl - // The system-provided seems to be broken on AIX // XFAIL: LIBCXX-AIX-FIXME diff --git a/libcxx/test/libcxx/utilities/expol/policies.compile.pass.cpp b/libcxx/test/libcxx/utilities/expol/policies.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/utilities/expol/policies.compile.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 + +// REQUIRES: with-pstl + +#include +#include + +#include "test_macros.h" + +static_assert(!std::is_default_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_move_constructible_v); +static_assert(!std::is_copy_assignable_v); +static_assert(!std::is_move_assignable_v); + +static_assert(!std::is_default_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_move_constructible_v); +static_assert(!std::is_copy_assignable_v); +static_assert(!std::is_move_assignable_v); + +static_assert(!std::is_default_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_move_constructible_v); +static_assert(!std::is_copy_assignable_v); +static_assert(!std::is_move_assignable_v); + +#if TEST_STD_VER >= 20 +static_assert(!std::is_default_constructible_v); +static_assert(!std::is_copy_constructible_v); +static_assert(!std::is_move_constructible_v); +static_assert(!std::is_copy_assignable_v); +static_assert(!std::is_move_assignable_v); +#endif diff --git a/libcxx/test/std/utilities/expol/is_execution_policy.compile.pass.cpp b/libcxx/test/std/utilities/expol/is_execution_policy.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/utilities/expol/is_execution_policy.compile.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 + +// REQUIRES: with-pstl + +#include + +#include "test_macros.h" + +static_assert(std::is_execution_policy::value); +static_assert(std::is_execution_policy_v); +static_assert(std::is_execution_policy::value); +static_assert(std::is_execution_policy_v); +static_assert(std::is_execution_policy::value); +static_assert(std::is_execution_policy_v); + +#if TEST_STD_VER >= 20 +static_assert(std::is_execution_policy::value); +static_assert(std::is_execution_policy_v); +#endif diff --git a/libcxx/test/std/utilities/expol/policies.compile.pass.cpp b/libcxx/test/std/utilities/expol/policies.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/utilities/expol/policies.compile.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 + +// REQUIRES: with-pstl + +#include +#include + +#include "test_macros.h" + +static_assert(std::is_same_v, std::execution::sequenced_policy>); +static_assert(std::is_same_v, std::execution::parallel_policy>); +static_assert(std::is_same_v, + std::execution::parallel_unsequenced_policy>); + +#if TEST_STD_VER >= 20 +static_assert(std::is_same_v, std::execution::unsequenced_policy>); +#endif