Skip to content

Commit

Permalink
[libc++][PSTL][NFC] clang-format files
Browse files Browse the repository at this point in the history
Reviewed By: ldionne, #libc

Spies: sstefan1, pcwang-thead, jplehr, libcxx-commits, arichardson, mgrang

Differential Revision: https://reviews.llvm.org/D141781
  • Loading branch information
philnik777 committed Apr 27, 2023
1 parent ba3bddb commit 1e9f707
Show file tree
Hide file tree
Showing 16 changed files with 7,157 additions and 5,210 deletions.
1,719 changes: 1,169 additions & 550 deletions libcxx/include/pstl/internal/algorithm_fwd.h

Large diffs are not rendered by default.

6,439 changes: 3,532 additions & 2,907 deletions libcxx/include/pstl/internal/algorithm_impl.h

Large diffs are not rendered by default.

48 changes: 13 additions & 35 deletions libcxx/include/pstl/internal/execution_defs.h
Expand Up @@ -16,31 +16,20 @@

_PSTL_HIDE_FROM_ABI_PUSH

namespace __pstl
{
namespace execution
{
inline namespace v1
{
namespace __pstl {
namespace execution {
inline namespace v1 {

// 2.4, Sequential execution policy
class sequenced_policy
{
};
class sequenced_policy {};

// 2.5, Parallel execution policy
class parallel_policy
{
};
class parallel_policy {};

// 2.6, Parallel+Vector execution policy
class parallel_unsequenced_policy
{
};
class parallel_unsequenced_policy {};

class unsequenced_policy
{
};
class unsequenced_policy {};

// 2.8, Execution policy objects
constexpr sequenced_policy seq{};
Expand All @@ -50,26 +39,16 @@ constexpr unsequenced_policy unseq{};

// 2.3, Execution policy type trait
template <class T>
struct is_execution_policy : std::false_type
{
};
struct is_execution_policy : std::false_type {};

template <>
struct is_execution_policy<__pstl::execution::sequenced_policy> : std::true_type
{
};
struct is_execution_policy<__pstl::execution::sequenced_policy> : std::true_type {};
template <>
struct is_execution_policy<__pstl::execution::parallel_policy> : std::true_type
{
};
struct is_execution_policy<__pstl::execution::parallel_policy> : std::true_type {};
template <>
struct is_execution_policy<__pstl::execution::parallel_unsequenced_policy> : std::true_type
{
};
struct is_execution_policy<__pstl::execution::parallel_unsequenced_policy> : std::true_type {};
template <>
struct is_execution_policy<__pstl::execution::unsequenced_policy> : std::true_type
{
};
struct is_execution_policy<__pstl::execution::unsequenced_policy> : std::true_type {};

#if defined(_PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT)
template <class T>
Expand All @@ -79,8 +58,7 @@ constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy<T>
} // namespace v1
} // namespace execution

namespace __internal
{
namespace __internal {
template <class ExecPolicy, class T>
using __enable_if_execution_policy =
typename std::enable_if<__pstl::execution::is_execution_policy<typename std::decay<ExecPolicy>::type>::value,
Expand Down
64 changes: 26 additions & 38 deletions libcxx/include/pstl/internal/execution_impl.h
Expand Up @@ -13,15 +13,13 @@
#include <iterator>
#include <type_traits>

#include "pstl_config.h"
#include "execution_defs.h"
#include "pstl_config.h"

_PSTL_HIDE_FROM_ABI_PUSH

namespace __pstl
{
namespace __internal
{
namespace __pstl {
namespace __internal {

template <typename _IteratorTag, typename... _IteratorTypes>
using __are_iterators_of = std::conjunction<
Expand All @@ -30,15 +28,9 @@ using __are_iterators_of = std::conjunction<
template <typename... _IteratorTypes>
using __are_random_access_iterators = __are_iterators_of<std::random_access_iterator_tag, _IteratorTypes...>;

struct __serial_backend_tag
{
};
struct __tbb_backend_tag
{
};
struct __openmp_backend_tag
{
};
struct __serial_backend_tag {};
struct __tbb_backend_tag {};
struct __openmp_backend_tag {};

#if defined(_PSTL_PAR_BACKEND_TBB)
using __par_backend_tag = __tbb_backend_tag;
Expand All @@ -47,54 +39,50 @@ using __par_backend_tag = __openmp_backend_tag;
#elif defined(_PSTL_PAR_BACKEND_SERIAL)
using __par_backend_tag = __serial_backend_tag;
#else
# error "A parallel backend must be specified";
# error "A parallel backend must be specified";
#endif

template <class _IsVector>
struct __serial_tag
{
using __is_vector = _IsVector;
struct __serial_tag {
using __is_vector = _IsVector;
};

template <class _IsVector>
struct __parallel_tag
{
using __is_vector = _IsVector;
// backend tag can be change depending on
// TBB availability in the environment
using __backend_tag = __par_backend_tag;
struct __parallel_tag {
using __is_vector = _IsVector;
// backend tag can be change depending on
// TBB availability in the environment
using __backend_tag = __par_backend_tag;
};

template <class _IsVector, class... _IteratorTypes>
using __tag_type = typename std::conditional<__internal::__are_random_access_iterators<_IteratorTypes...>::value,
__parallel_tag<_IsVector>, __serial_tag<_IsVector>>::type;
using __tag_type =
typename std::conditional<__internal::__are_random_access_iterators<_IteratorTypes...>::value,
__parallel_tag<_IsVector>,
__serial_tag<_IsVector>>::type;

template <class... _IteratorTypes>
__serial_tag</*_IsVector = */ std::false_type>
__select_backend(__pstl::execution::sequenced_policy, _IteratorTypes&&...)
{
return {};
__select_backend(__pstl::execution::sequenced_policy, _IteratorTypes&&...) {
return {};
}

template <class... _IteratorTypes>
__serial_tag<__internal::__are_random_access_iterators<_IteratorTypes...>>
__select_backend(__pstl::execution::unsequenced_policy, _IteratorTypes&&...)
{
return {};
__select_backend(__pstl::execution::unsequenced_policy, _IteratorTypes&&...) {
return {};
}

template <class... _IteratorTypes>
__tag_type</*_IsVector = */ std::false_type, _IteratorTypes...>
__select_backend(__pstl::execution::parallel_policy, _IteratorTypes&&...)
{
return {};
__select_backend(__pstl::execution::parallel_policy, _IteratorTypes&&...) {
return {};
}

template <class... _IteratorTypes>
__tag_type<__internal::__are_random_access_iterators<_IteratorTypes...>, _IteratorTypes...>
__select_backend(__pstl::execution::parallel_unsequenced_policy, _IteratorTypes&&...)
{
return {};
__select_backend(__pstl::execution::parallel_unsequenced_policy, _IteratorTypes&&...) {
return {};
}

} // namespace __internal
Expand Down

0 comments on commit 1e9f707

Please sign in to comment.