Commit f32ee8a2 by Thomas Rodgers Committed by Thomas Rodgers

Synchronize libstdc++ PSTL with upstream LLVM PSTL

	Rename PSTL macro's consistent with libstdc++ (and llvm upstream
	project) standards.
	* include/bits/c++config: Rename all macros of the form __PSTL* to
	_PSTL*.
	* include/std/algorithm: Likewise.
	* include/std/execution: Likewise.
	* include/std/numeric: Likewise.
	* include/std/memory: Likewise.
	* include/pstl/glue_memory_impl.h: Likewise.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/glue_memory_defs.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/utils.h: Likewise.
	* include/pstl/algorithm_fwd.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/parallel_impl.h: Likewise.
	* include/pstl/memory_impl.h: Likewise.
	* include/pstl/glue_numeric_defs.h: Likewise.
	* include/pstl/parallel_backend_utils.h: Likewise.
	* include/pstl/glue_algorithm_defs.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/glue_numeric_impl.h: Likewise.
	* include/pstl/parallel_backend_tbb.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* testsuite/util/pstl/pstl_test_config.h: Likewise.
	* testsuite/util/pstl/test_utils.h: Likewise.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc:
	Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc:
	Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/scan.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/reduce.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_merge/merge.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: Likewise.

	Rename header guards to be consistent with upstream project's
	conventions.
	* include/pstl/glue_memory_impl.h: Rename all macros of the form
	_PSTL_(.*)_H to _PSTL_\U\1_H.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/glue_memory_defs.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/utils.h: Likewise.
	* include/pstl/algorithm_fwd.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/parallel_impl.h: Likewise.
	* include/pstl/memory_impl.h: Likewise.
	* include/pstl/glue_numeric_defs.h: Likewise.
	* include/pstl/parallel_backend_utils.h: Likewise.
	* include/pstl/glue_algorithm_defs.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/glue_numeric_impl.h: Likewise.
	* include/pstl/parallel_backend_tbb.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* testsuite/util/pstl/pstl_test_config.h: Likewise.

	Synchronize libstdc++ parallel algorithms with upstream
	project.
	* include/pstl/algorithm_fwd.h: Synchronize with
	upstream PSTL project.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/parallel_backend_serial.h: New file.
	* include/Makefile.am (pstl_headers): Add
	parallel_backend_serial.h.
	* include/Makefile.in: Regenerate.

	Clean up non-conforming names
	* include/pstl/algorithm_impl.h (__parallel_set_union_op):
	Uglfiy copy_range1 and copy_range2
	(__pattern_walk2_n): Rename local n to __n
	* include/pstl/parallel_backend_tbb.h (struct __binary_no_op):
	Rename parameter _T to _Tp.

	Integrate non-TBB serial backend support
	* include/bits/c++config: Adjust TBB detection logic to select serial
	PSTL backend if no TBB present.
	* testsuite/utils/pstl/test_utils.h: Remove check for
	_PSTL_USE_PAR_POLICIES

From-SVN: r272056
parent 1afab7a8
2019-06-07 Thomas Rodgers <trodgers@redhat.com>
Rename PSTL macro's consistent with libstdc++ (and llvm upstream
project) standards.
* include/bits/c++config: Rename all macros of the form __PSTL* to
_PSTL*.
* include/std/algorithm: Likewise.
* include/std/execution: Likewise.
* include/std/numeric: Likewise.
* include/std/memory: Likewise.
* include/pstl/glue_memory_impl.h: Likewise.
* include/pstl/numeric_impl.h: Likewise.
* include/pstl/glue_memory_defs.h: Likewise.
* include/pstl/execution_defs.h: Likewise.
* include/pstl/utils.h: Likewise.
* include/pstl/algorithm_fwd.h: Likewise.
* include/pstl/unseq_backend_simd.h: Likewise.
* include/pstl/glue_execution_defs.h: Likewise.
* include/pstl/algorithm_impl.h: Likewise.
* include/pstl/parallel_impl.h: Likewise.
* include/pstl/memory_impl.h: Likewise.
* include/pstl/glue_numeric_defs.h: Likewise.
* include/pstl/parallel_backend_utils.h: Likewise.
* include/pstl/glue_algorithm_defs.h: Likewise.
* include/pstl/parallel_backend.h: Likewise.
* include/pstl/glue_numeric_impl.h: Likewise.
* include/pstl/parallel_backend_tbb.h: Likewise.
* include/pstl/numeric_fwd.h: Likewise.
* include/pstl/glue_algorithm_impl.h: Likewise.
* include/pstl/execution_impl.h: Likewise.
* include/pstl/pstl_config.h: Likewise.
* testsuite/util/pstl/pstl_test_config.h: Likewise.
* testsuite/util/pstl/test_utils.h: Likewise.
* testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc:
Likewise.
* testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc:
Likewise.
* testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc:
Likewise.
* testsuite/26_numerics/pstl/numeric_ops/scan.cc: Likewise.
* testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: Likewise.
* testsuite/26_numerics/pstl/numeric_ops/reduce.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_merge/merge.cc: Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc:
Likewise.
* testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: Likewise.
Rename header guards to be consistent with upstream project's
conventions.
* include/pstl/glue_memory_impl.h: Rename all macros of the form
_PSTL_(.*)_H to _PSTL_\U\1_H.
* include/pstl/numeric_impl.h: Likewise.
* include/pstl/glue_memory_defs.h: Likewise.
* include/pstl/execution_defs.h: Likewise.
* include/pstl/utils.h: Likewise.
* include/pstl/algorithm_fwd.h: Likewise.
* include/pstl/unseq_backend_simd.h: Likewise.
* include/pstl/glue_execution_defs.h: Likewise.
* include/pstl/algorithm_impl.h: Likewise.
* include/pstl/parallel_impl.h: Likewise.
* include/pstl/memory_impl.h: Likewise.
* include/pstl/glue_numeric_defs.h: Likewise.
* include/pstl/parallel_backend_utils.h: Likewise.
* include/pstl/glue_algorithm_defs.h: Likewise.
* include/pstl/parallel_backend.h: Likewise.
* include/pstl/glue_numeric_impl.h: Likewise.
* include/pstl/parallel_backend_tbb.h: Likewise.
* include/pstl/numeric_fwd.h: Likewise.
* include/pstl/glue_algorithm_impl.h: Likewise.
* include/pstl/execution_impl.h: Likewise.
* include/pstl/pstl_config.h: Likewise.
* testsuite/util/pstl/pstl_test_config.h: Likewise.
Synchronize libstdc++ parallel algorithms with upstream
project.
* include/pstl/algorithm_fwd.h: Synchronize with
upstream PSTL project.
* include/pstl/algorithm_impl.h: Likewise.
* include/pstl/execution_defs.h: Likewise.
* include/pstl/execution_impl.h: Likewise.
* include/pstl/glue_algorithm_impl.h: Likewise.
* include/pstl/glue_execution_defs.h: Likewise.
* include/pstl/numeric_fwd.h: Likewise.
* include/pstl/numeric_impl.h: Likewise.
* include/pstl/parallel_backend.h: Likewise.
* include/pstl/pstl_config.h: Likewise.
* include/pstl/unseq_backend_simd.h: Likewise.
* include/pstl/parallel_backend_serial.h: New file.
* include/Makefile.am (pstl_headers): Add
parallel_backend_serial.h.
* include/Makefile.in: Regenerate.
Clean up non-conforming names
* include/pstl/algorithm_impl.h (__parallel_set_union_op):
Uglfiy copy_range1 and copy_range2
(__pattern_walk2_n): Rename local n to __n
* include/pstl/parallel_backend_tbb.h (struct __binary_no_op):
Rename parameter _T to _Tp.
Integrate non-TBB serial backend support
* include/bits/c++config: Adjust TBB detection logic to select serial
PSTL backend if no TBB present.
* testsuite/utils/pstl/test_utils.h: Remove check for
_PSTL_USE_PAR_POLICIES
2019-06-07 Jonathan Wakely <jwakely@redhat.com>
* testsuite/24_iterators/container_access.cc: Move dg-options before
......
......@@ -246,6 +246,7 @@ pstl_headers = \
${pstl_srcdir}/numeric_impl.h \
${pstl_srcdir}/parallel_backend.h \
${pstl_srcdir}/parallel_backend_tbb.h \
${pstl_srcdir}/parallel_backend_serial.h \
${pstl_srcdir}/parallel_backend_utils.h \
${pstl_srcdir}/parallel_impl.h \
${pstl_srcdir}/pstl_config.h \
......
......@@ -591,6 +591,7 @@ pstl_headers = \
${pstl_srcdir}/numeric_impl.h \
${pstl_srcdir}/parallel_backend.h \
${pstl_srcdir}/parallel_backend_tbb.h \
${pstl_srcdir}/parallel_backend_serial.h \
${pstl_srcdir}/parallel_backend_utils.h \
${pstl_srcdir}/parallel_impl.h \
${pstl_srcdir}/pstl_config.h \
......
......@@ -656,9 +656,7 @@ namespace std
#if __cplusplus >= 201703L
// Preserved here so we have some idea which version of upstream we've pulled in
// #define PSTL_VERSION 104
// #define PSTL_VERSION_MAJOR (PSTL_VERSION/100)
// #define PSTL_VERSION_MINOR (PSTL_VERSION - PSTL_VERSION_MAJOR * 100)
// #define PSTL_VERSION 9000
// For now this defaults to being based on the presence of Thread Building Blocks
# ifndef _GLIBCXX_USE_TBB_PAR_BACKEND
......@@ -666,11 +664,13 @@ namespace std
# endif
// This section will need some rework when a new (default) backend type is added
# if _GLIBCXX_USE_TBB_PAR_BACKEND
# define __PSTL_USE_PAR_POLICIES 1
# define _PSTL_PAR_BACKEND_TBB
# else
# define _PSTL_PAR_BACKEND_SERIAL
# endif
# define __PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition)
# define __PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition)
# define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition)
# define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition)
#include <pstl/pstl_config.h>
......
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_algorithm_fwd_H
#define __PSTL_algorithm_fwd_H
#ifndef _PSTL_ALGORITHM_FWD_H
#define _PSTL_ALGORITHM_FWD_H
#include <type_traits>
#include <utility>
......@@ -37,12 +37,10 @@ bool
__pattern_any_of(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Pred, _IsVector,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Pred, class _IsVector>
bool
__pattern_any_of(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Pred, _IsVector,
/*parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// walk1 (pseudo)
......@@ -63,24 +61,20 @@ void
__pattern_walk1(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Function, _IsVector,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Function, class _IsVector>
void
__pattern_walk1(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Function, _IsVector,
/*parallel=*/std::true_type);
#endif
template <class _ExecutionPolicy, class _ForwardIterator, class _Brick>
void
__pattern_walk_brick(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Brick,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Brick>
void
__pattern_walk_brick(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Brick,
/*parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// walk1_n
......@@ -99,24 +93,20 @@ _ForwardIterator
__pattern_walk1_n(_ExecutionPolicy&&, _ForwardIterator, _Size, _Function, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Size, class _Function, class _IsVector>
_RandomAccessIterator
__pattern_walk1_n(_ExecutionPolicy&&, _RandomAccessIterator, _Size, _Function, _IsVector,
/*is_parallel=*/std::true_type);
#endif
template <class _ExecutionPolicy, class _ForwardIterator, class _Size, class _Brick>
_ForwardIterator
__pattern_walk_brick_n(_ExecutionPolicy&&, _ForwardIterator, _Size, _Brick,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Size, class _Brick>
_RandomAccessIterator
__pattern_walk_brick_n(_ExecutionPolicy&&, _RandomAccessIterator, _Size, _Brick,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// walk2 (pseudo)
......@@ -145,12 +135,10 @@ _ForwardIterator2
__pattern_walk2(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Function, _IsVector,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Function, class _IsVector>
_ForwardIterator2
__pattern_walk2(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Function, _IsVector,
/*parallel=*/std::true_type);
#endif
template <class _ExecutionPolicy, class _ForwardIterator1, class _Size, class _ForwardIterator2, class _Function,
class _IsVector>
......@@ -158,38 +146,32 @@ _ForwardIterator2
__pattern_walk2_n(_ExecutionPolicy&&, _ForwardIterator1, _Size, _ForwardIterator2, _Function, _IsVector,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _Size, class _RandomAccessIterator2,
class _Function, class _IsVector>
_RandomAccessIterator2
__pattern_walk2_n(_ExecutionPolicy&&, _RandomAccessIterator1, _Size, _RandomAccessIterator2, _Function, _IsVector,
/*parallel=*/std::true_type);
#endif
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Brick>
_ForwardIterator2
__pattern_walk2_brick(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _Brick,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _Brick>
_RandomAccessIterator2
__pattern_walk2_brick(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2,
_Brick,
/*parallel=*/std::true_type);
#endif
template <class _ExecutionPolicy, class _ForwardIterator1, class _Size, class _ForwardIterator2, class _Brick>
_ForwardIterator2
__pattern_walk2_brick_n(_ExecutionPolicy&&, _ForwardIterator1, _Size, _ForwardIterator2, _Brick,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _Size, class _RandomAccessIterator2, class _Brick>
_RandomAccessIterator2
__pattern_walk2_brick_n(_ExecutionPolicy&&, _RandomAccessIterator1, _Size, _RandomAccessIterator2, _Brick,
/*parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// walk3 (pseudo)
......@@ -213,13 +195,11 @@ __pattern_walk3(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _Forwa
_Function, _IsVector,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2,
class _RandomAccessIterator3, class _Function, class _IsVector>
_RandomAccessIterator3
__pattern_walk3(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2,
_RandomAccessIterator3, _Function, _IsVector, /*parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// equal
......@@ -227,7 +207,7 @@ __pattern_walk3(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterato
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
bool __brick_equal(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _BinaryPredicate,
/* IsVector = */ std::false_type) noexcept;
/* is_vector = */ std::false_type) noexcept;
template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _BinaryPredicate>
bool __brick_equal(_RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, _BinaryPredicate,
......@@ -237,17 +217,33 @@ template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterato
class _IsVector>
bool
__pattern_equal(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _BinaryPredicate,
_IsVector,
/* is_parallel = */ std::false_type) noexcept;
_IsVector, /* is_parallel = */ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _BinaryPredicate,
class _IsVector>
bool
__pattern_equal(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2,
_BinaryPredicate, _IsVector,
/*is_parallel=*/std::true_type);
#endif
_BinaryPredicate, _IsVector, /* is_parallel = */ std::true_type);
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
bool __brick_equal(_ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2, _BinaryPredicate,
/* is_vector = */ std::false_type) noexcept;
template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _BinaryPredicate>
bool __brick_equal(_RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, _RandomAccessIterator2,
_BinaryPredicate, /* is_vector = */ std::true_type) noexcept;
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate,
class _IsVector>
bool
__pattern_equal(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_BinaryPredicate, _IsVector, /* is_parallel = */ std::false_type) noexcept;
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _BinaryPredicate,
class _IsVector>
bool
__pattern_equal(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2,
_RandomAccessIterator2, _BinaryPredicate, _IsVector, /* is_parallel = */ std::true_type);
//------------------------------------------------------------------------
// find_if
......@@ -266,12 +262,10 @@ _ForwardIterator
__pattern_find_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate, class _IsVector>
_ForwardIterator
__pattern_find_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// find_end
......@@ -294,14 +288,12 @@ __pattern_find_end(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _Fo
_BinaryPredicate, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate,
class _IsVector>
_ForwardIterator1
__pattern_find_end(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_BinaryPredicate, _IsVector,
/*is_parallel=*/std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// find_first_of
......@@ -323,13 +315,11 @@ _ForwardIterator1
__pattern_find_first_of(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_BinaryPredicate, _IsVector, /*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate,
class _IsVector>
_ForwardIterator1
__pattern_find_first_of(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_BinaryPredicate, _IsVector, /*is_parallel=*/std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// search
......@@ -352,14 +342,12 @@ __pattern_search(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _Forw
_BinaryPredicate, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate,
class _IsVector>
_ForwardIterator1
__pattern_search(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_BinaryPredicate, _IsVector,
/*is_parallel=*/std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// search_n
......@@ -382,14 +370,12 @@ __pattern_search_n(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Size
IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Size, class _Tp, class _BinaryPredicate,
class IsVector>
_RandomAccessIterator
__pattern_search_n(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Size, const _Tp&,
_BinaryPredicate, IsVector,
/*is_parallel=*/std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// copy_n
......@@ -486,13 +472,11 @@ _OutputIterator
__pattern_copy_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _UnaryPredicate, _IsVector,
/*parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryPredicate,
class _IsVector>
_OutputIterator
__pattern_copy_if(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator, _UnaryPredicate,
_IsVector, /*parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// count
......@@ -513,12 +497,10 @@ typename std::iterator_traits<_ForwardIterator>::difference_type
__pattern_count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate,
/* is_parallel */ std::false_type, _IsVector) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate, class _IsVector>
typename std::iterator_traits<_ForwardIterator>::difference_type
__pattern_count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate,
/* is_parallel */ std::true_type, _IsVector);
#endif
//------------------------------------------------------------------------
// unique
......@@ -537,12 +519,10 @@ _ForwardIterator
__pattern_unique(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _BinaryPredicate, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _BinaryPredicate, class _IsVector>
_ForwardIterator
__pattern_unique(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _BinaryPredicate, _IsVector,
/*is_parallel=*/std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// unique_copy
......@@ -556,9 +536,11 @@ template <class _RandomAccessIterator, class _OutputIterator, class _BinaryPredi
_OutputIterator __brick_unique_copy(_RandomAccessIterator, _RandomAccessIterator, _OutputIterator, _BinaryPredicate,
/*vector=*/std::true_type) noexcept;
template <class _ExecutionPolicy, class _ForwardIterator, class OutputIterator, class _BinaryPredicate, class _IsVector>
OutputIterator __pattern_unique_copy(_ForwardIterator, _ForwardIterator, OutputIterator, _BinaryPredicate, _IsVector,
/*parallel=*/std::false_type) noexcept;
template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _BinaryPredicate,
class _IsVector>
_OutputIterator
__pattern_unique_copy(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryPredicate,
_IsVector, /*parallel=*/std::false_type) noexcept;
template <class _ExecutionPolicy, class _DifferenceType, class _RandomAccessIterator, class _BinaryPredicate>
_DifferenceType
......@@ -570,13 +552,11 @@ _DifferenceType
__brick_calc_mask_2(_RandomAccessIterator, _RandomAccessIterator, bool* __restrict, _BinaryPredicate,
/*vector=*/std::true_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _BinaryPredicate,
class _IsVector>
_OutputIterator
__pattern_unique_copy(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator,
_BinaryPredicate, _IsVector, /*parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// reverse
......@@ -603,12 +583,10 @@ void
__pattern_reverse(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _BidirectionalIterator, class _IsVector>
void
__pattern_reverse(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// reverse_copy
......@@ -627,12 +605,10 @@ _OutputIterator
__pattern_reverse_copy(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator, _OutputIterator, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _BidirectionalIterator, class _OutputIterator, class _IsVector>
_OutputIterator
__pattern_reverse_copy(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator, _OutputIterator, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// rotate
......@@ -651,12 +627,10 @@ _ForwardIterator
__pattern_rotate(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _ForwardIterator, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _IsVector>
_ForwardIterator
__pattern_rotate(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _ForwardIterator, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// rotate_copy
......@@ -676,13 +650,11 @@ __pattern_rotate_copy(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _F
_IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _IsVector>
_OutputIterator
__pattern_rotate_copy(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _ForwardIterator, _OutputIterator,
_IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// is_partitioned
......@@ -701,12 +673,10 @@ bool
__pattern_is_partitioned(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _UnaryPredicate, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _UnaryPredicate, class _IsVector>
bool
__pattern_is_partitioned(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _UnaryPredicate, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// partition
......@@ -725,12 +695,10 @@ _ForwardIterator
__pattern_partition(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _UnaryPredicate, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _UnaryPredicate, class _IsVector>
_ForwardIterator
__pattern_partition(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _UnaryPredicate, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// stable_partition
......@@ -750,13 +718,11 @@ __pattern_stable_partition(_ExecutionPolicy&&, _BidirectionalIterator, _Bidirect
_IsVector,
/*is_parallelization=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _BidirectionalIterator, class _UnaryPredicate, class _IsVector>
_BidirectionalIterator
__pattern_stable_partition(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator, _UnaryPredicate,
_IsVector,
/*is_parallelization=*/std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// partition_copy
......@@ -779,14 +745,12 @@ __pattern_partition_copy(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator,
_UnaryPredicate, _IsVector,
/*is_parallelization=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator1, class _OutputIterator2,
class _UnaryPredicate, class _IsVector>
std::pair<_OutputIterator1, _OutputIterator2>
__pattern_partition_copy(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator1,
_OutputIterator2, _UnaryPredicate, _IsVector,
/*is_parallelization=*/std::true_type);
#endif
//------------------------------------------------------------------------
// sort
......@@ -798,13 +762,11 @@ void
__pattern_sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, _IsVector /*is_vector*/,
/*is_parallel=*/std::false_type, _IsMoveConstructible) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
void
__pattern_sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, _IsVector /*is_vector*/,
/*is_parallel=*/std::true_type,
/*is_move_constructible=*/std::true_type);
#endif
//------------------------------------------------------------------------
// stable_sort
......@@ -816,13 +778,11 @@ __pattern_stable_sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIt
_IsVector /*is_vector*/,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
void
__pattern_stable_sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare,
_IsVector /*is_vector*/,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// partial_sort
......@@ -834,13 +794,11 @@ __pattern_partial_sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessI
_Compare, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
void
__pattern_partial_sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator,
_Compare, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// partial_sort_copy
......@@ -852,13 +810,11 @@ __pattern_partial_sort_copy(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterat
_RandomAccessIterator, _Compare, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _RandomAccessIterator, class _Compare, class _IsVector>
_RandomAccessIterator
__pattern_partial_sort_copy(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _RandomAccessIterator,
_RandomAccessIterator, _Compare, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// adjacent_find
......@@ -879,12 +835,10 @@ _ForwardIterator
__pattern_adjacent_find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _BinaryPredicate,
/* is_parallel */ std::false_type, _IsVector, bool) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _BinaryPredicate, class _IsVector>
_RandomAccessIterator
__pattern_adjacent_find(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _BinaryPredicate,
/* is_parallel */ std::true_type, _IsVector, bool);
#endif
//------------------------------------------------------------------------
// nth_element
......@@ -895,13 +849,11 @@ __pattern_nth_element(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIt
_IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
void
__pattern_nth_element(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare,
_IsVector,
/*is_parallel=*/std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// fill, fill_n
......@@ -921,12 +873,10 @@ void
__pattern_fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&,
/*is_parallel=*/std::false_type, _IsVector) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _IsVector>
_ForwardIterator
__pattern_fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&,
/*is_parallel=*/std::true_type, _IsVector);
#endif
template <class _OutputIterator, class _Size, class _Tp>
_OutputIterator
......@@ -943,12 +893,10 @@ _OutputIterator
__pattern_fill_n(_ExecutionPolicy&&, _OutputIterator, _Size, const _Tp&,
/*is_parallel=*/std::false_type, _IsVector) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _OutputIterator, class _Size, class _Tp, class _IsVector>
_OutputIterator
__pattern_fill_n(_ExecutionPolicy&&, _OutputIterator, _Size, const _Tp&,
/*is_parallel=*/std::true_type, _IsVector);
#endif
//------------------------------------------------------------------------
// generate, generate_n
......@@ -967,12 +915,10 @@ void
__pattern_generate(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Generator,
/*is_parallel=*/std::false_type, _IsVector) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Generator, class _IsVector>
_ForwardIterator
__pattern_generate(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Generator,
/*is_parallel=*/std::true_type, _IsVector);
#endif
template <class OutputIterator, class Size, class _Generator>
OutputIterator __brick_generate_n(OutputIterator, Size, _Generator,
......@@ -987,12 +933,10 @@ OutputIterator
__pattern_generate_n(_ExecutionPolicy&&, OutputIterator, Size, _Generator,
/*is_parallel=*/std::false_type, _IsVector) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class OutputIterator, class Size, class _Generator, class _IsVector>
OutputIterator
__pattern_generate_n(_ExecutionPolicy&&, OutputIterator, Size, _Generator,
/*is_parallel=*/std::true_type, _IsVector);
#endif
//------------------------------------------------------------------------
// remove
......@@ -1010,12 +954,10 @@ _ForwardIterator
__pattern_remove_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _UnaryPredicate, _IsVector,
/*is_parallel*/ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _UnaryPredicate, class _IsVector>
_ForwardIterator
__pattern_remove_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _UnaryPredicate, _IsVector,
/*is_parallel*/ std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// merge
......@@ -1037,14 +979,12 @@ _OutputIterator
__pattern_merge(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_OutputIterator, _Compare, _IsVector, /* is_parallel = */ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
__pattern_merge(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2,
_RandomAccessIterator2, _OutputIterator, _Compare, _IsVector,
/* is_parallel = */ std::true_type);
#endif
//------------------------------------------------------------------------
// inplace_merge
......@@ -1064,13 +1004,11 @@ __pattern_inplace_merge(_ExecutionPolicy&&, _BidirectionalIterator, _Bidirection
_Compare, _IsVector,
/* is_parallel = */ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _BidirectionalIterator, class _Compare, class _IsVector>
void
__pattern_inplace_merge(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator,
_Compare, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// includes
......@@ -1082,13 +1020,11 @@ __pattern_includes(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _Fo
_Compare, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Compare, class _IsVector>
bool
__pattern_includes(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_Compare, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// set_union
......@@ -1110,13 +1046,11 @@ _OutputIterator
__pattern_set_union(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_OutputIterator, _Compare, _IsVector, /*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
__pattern_set_union(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_OutputIterator, _Compare, _IsVector, /*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// set_intersection
......@@ -1139,13 +1073,11 @@ __pattern_set_intersection(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterat
_ForwardIterator2, _OutputIterator, _Compare, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
__pattern_set_intersection(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2,
_ForwardIterator2, _OutputIterator, _Compare, _IsVector, /*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// set_difference
......@@ -1167,13 +1099,11 @@ _OutputIterator
__pattern_set_difference(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_OutputIterator, _Compare, _IsVector, /*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
__pattern_set_difference(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_OutputIterator, _Compare, _IsVector, /*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// set_symmetric_difference
......@@ -1196,14 +1126,12 @@ __pattern_set_symmetric_difference(_ExecutionPolicy&&, _ForwardIterator1, _Forwa
_ForwardIterator2, _OutputIterator, _Compare, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
__pattern_set_symmetric_difference(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2,
_ForwardIterator2, _OutputIterator, _Compare, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// is_heap_until
......@@ -1222,12 +1150,10 @@ _RandomAccessIterator
__pattern_is_heap_until(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, _IsVector,
/* is_parallel = */ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
_RandomAccessIterator
__pattern_is_heap_until(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, _IsVector,
/* is_parallel = */ std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// min_element
......@@ -1246,12 +1172,10 @@ _ForwardIterator
__pattern_min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare, _IsVector,
/* is_parallel = */ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <typename _ExecutionPolicy, typename _RandomAccessIterator, typename _Compare, typename _IsVector>
_RandomAccessIterator
__pattern_min_element(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, _IsVector,
/* is_parallel = */ std::true_type);
#endif
//------------------------------------------------------------------------
// minmax_element
......@@ -1270,12 +1194,10 @@ std::pair<_ForwardIterator, _ForwardIterator>
__pattern_minmax_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare, _IsVector,
/* is_parallel = */ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <typename _ExecutionPolicy, typename _ForwardIterator, typename _Compare, typename _IsVector>
std::pair<_ForwardIterator, _ForwardIterator>
__pattern_minmax_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare, _IsVector,
/* is_parallel = */ std::true_type);
#endif
//------------------------------------------------------------------------
// mismatch
......@@ -1297,13 +1219,11 @@ __pattern_mismatch(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _Fo
_Predicate, _IsVector,
/* is_parallel = */ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _Predicate,
class _IsVector>
std::pair<_RandomAccessIterator1, _RandomAccessIterator2>
__pattern_mismatch(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2,
_RandomAccessIterator2, _Predicate, _IsVector, /* is_parallel = */ std::true_type) noexcept;
#endif
//------------------------------------------------------------------------
// lexicographical_compare
......@@ -1324,13 +1244,11 @@ bool
__pattern_lexicographical_compare(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2,
_ForwardIterator2, _Compare, _IsVector, /* is_parallel = */ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Compare, class _IsVector>
bool
__pattern_lexicographical_compare(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2,
_ForwardIterator2, _Compare, _IsVector, /* is_parallel = */ std::true_type) noexcept;
#endif
} // namespace __internal
} // namespace __pstl
#endif /* __PSTL_algorithm_fwd_H */
#endif /* _PSTL_ALGORITHM_FWD_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_algorithm_impl_H
#define __PSTL_algorithm_impl_H
#ifndef _PSTL_ALGORITHM_IMPL_H
#define _PSTL_ALGORITHM_IMPL_H
#include <iterator>
#include <type_traits>
......@@ -19,12 +19,10 @@
#include "execution_impl.h"
#include "memory_impl.h"
#include "parallel_backend_utils.h"
#include "unseq_backend_simd.h"
#if __PSTL_USE_PAR_POLICIES
#include "parallel_backend.h"
#include "parallel_impl.h"
#endif
#include "unseq_backend_simd.h"
namespace __pstl
{
......@@ -59,20 +57,18 @@ __pattern_any_of(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator
return __internal::__brick_any_of(__first, __last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Pred, class _IsVector>
bool
__pattern_any_of(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred,
_IsVector __is_vector, /*parallel=*/std::true_type)
{
return __internal::__except_handler([&]() {
return __internal::__parallel_or(std::forward<_ExecutionPolicy>(__exec), __first, __last,
[__pred, __is_vector](_ForwardIterator __i, _ForwardIterator __j) {
return __internal::__brick_any_of(__i, __j, __pred, __is_vector);
});
return __internal::__parallel_or(std::forward<_ExecutionPolicy>(__exec), __first, __last,
[__pred, __is_vector](_ForwardIterator __i, _ForwardIterator __j) {
return __internal::__brick_any_of(__i, __j, __pred, __is_vector);
});
});
}
#endif
// [alg.foreach]
// for_each_n with no policy
......@@ -115,7 +111,6 @@ __pattern_walk1(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator _
__internal::__brick_walk1(__first, __last, __f, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Function, class _IsVector>
void
__pattern_walk1(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Function __f,
......@@ -129,7 +124,6 @@ __pattern_walk1(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIte
});
});
}
#endif
template <class _ExecutionPolicy, class _ForwardIterator, class _Brick>
void
......@@ -139,7 +133,6 @@ __pattern_walk_brick(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardItera
__brick(__first, __last);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Brick>
void
__pattern_walk_brick(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Brick __brick,
......@@ -150,7 +143,6 @@ __pattern_walk_brick(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Forwa
[__brick](_ForwardIterator __i, _ForwardIterator __j) { __brick(__i, __j); });
});
}
#endif
//------------------------------------------------------------------------
// walk1_n
......@@ -160,7 +152,7 @@ _ForwardIterator
__brick_walk1_n(_ForwardIterator __first, _Size __n, _Function __f, /*_IsVectorTag=*/std::false_type)
{
return __internal::__for_each_n_it_serial(__first, __n,
[&__f](_ForwardIterator __it) { __f(*__it); }); // calling serial version
[&__f](_ForwardIterator __it) { __f(*__it); }); // calling serial version
}
template <class _RandomAccessIterator, class _DifferenceType, class _Function>
......@@ -179,17 +171,16 @@ __pattern_walk1_n(_ExecutionPolicy&&, _ForwardIterator __first, _Size __n, _Func
return __internal::__brick_walk1_n(__first, __n, __f, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Size, class _Function, class _IsVector>
_RandomAccessIterator
__pattern_walk1_n(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Size __n, _Function __f,
_IsVector __is_vector,
/*is_parallel=*/std::true_type)
{
__internal::__pattern_walk1(std::forward<_ExecutionPolicy>(__exec), __first, __first + __n, __f, __is_vector, std::true_type());
__internal::__pattern_walk1(std::forward<_ExecutionPolicy>(__exec), __first, __first + __n, __f, __is_vector,
std::true_type());
return __first + __n;
}
#endif
template <class _ExecutionPolicy, class _ForwardIterator, class _Size, class _Brick>
_ForwardIterator
......@@ -199,7 +190,6 @@ __pattern_walk_brick_n(_ExecutionPolicy&&, _ForwardIterator __first, _Size __n,
return __brick(__first, __n);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Size, class _Brick>
_RandomAccessIterator
__pattern_walk_brick_n(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Size __n, _Brick __brick,
......@@ -212,7 +202,6 @@ __pattern_walk_brick_n(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
return __first + __n;
});
}
#endif
//------------------------------------------------------------------------
// walk2 (pseudo)
......@@ -263,7 +252,6 @@ __pattern_walk2(_ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIterator
return __internal::__brick_walk2(__first1, __last1, __first2, __f, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Function, class _IsVector>
_ForwardIterator2
__pattern_walk2(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
......@@ -278,15 +266,14 @@ __pattern_walk2(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardI
return __first2 + (__last1 - __first1);
});
}
#endif
template <class _ExecutionPolicy, class _ForwardIterator1, class _Size, class _ForwardIterator2, class _Function,
class _IsVector>
_ForwardIterator2
__pattern_walk2_n(_ExecutionPolicy&&, _ForwardIterator1 __first1, _Size __n, _ForwardIterator2 __first2, _Function __f,
_IsVector is_vector, /*parallel=*/std::false_type) noexcept
_IsVector __is_vector, /*parallel=*/std::false_type) noexcept
{
return __internal::__brick_walk2_n(__first1, __n, __first2, __f, is_vector);
return __internal::__brick_walk2_n(__first1, __n, __first2, __f, __is_vector);
}
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _Size, class _RandomAccessIterator2,
......@@ -307,7 +294,6 @@ __pattern_walk2_brick(_ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIt
return __brick(__first1, __last1, __first2);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _Brick>
_RandomAccessIterator2
__pattern_walk2_brick(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
......@@ -322,9 +308,7 @@ __pattern_walk2_brick(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1
return __first2 + (__last1 - __first1);
});
}
#endif
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _Size, class _RandomAccessIterator2, class _Brick>
_RandomAccessIterator2
__pattern_walk2_brick_n(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _Size __n,
......@@ -339,7 +323,6 @@ __pattern_walk2_brick_n(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __firs
return __first2 + __n;
});
}
#endif
template <class _ExecutionPolicy, class _ForwardIterator1, class _Size, class _ForwardIterator2, class _Brick>
_ForwardIterator2
......@@ -381,7 +364,6 @@ __pattern_walk3(_ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIterator
return __internal::__brick_walk3(__first1, __last1, __first2, __first3, __f, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2,
class _RandomAccessIterator3, class _Function, class _IsVector>
_RandomAccessIterator3
......@@ -393,12 +375,12 @@ __pattern_walk3(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _Ran
__par_backend::__parallel_for(
std::forward<_ExecutionPolicy>(__exec), __first1, __last1,
[__f, __first1, __first2, __first3, __is_vector](_RandomAccessIterator1 __i, _RandomAccessIterator1 __j) {
__internal::__brick_walk3(__i, __j, __first2 + (__i - __first1), __first3 + (__i - __first1), __f, __is_vector);
__internal::__brick_walk3(__i, __j, __first2 + (__i - __first1), __first3 + (__i - __first1), __f,
__is_vector);
});
return __first3 + (__last1 - __first1);
});
}
#endif
//------------------------------------------------------------------------
// equal
......@@ -435,7 +417,6 @@ __pattern_equal(_ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIterator
return __internal::__brick_equal(__first1, __last1, __first2, __last2, __p, __is_vector);
}
#if _PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _BinaryPredicate,
class _IsVector>
bool
......@@ -455,7 +436,6 @@ __pattern_equal(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _Ran
});
});
}
#endif
//------------------------------------------------------------------------
// equal version for sequences with equal length
......@@ -487,7 +467,6 @@ __pattern_equal(_ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIterator
return __internal::__brick_equal(__first1, __last1, __first2, __p, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _BinaryPredicate,
class _IsVector>
bool
......@@ -503,7 +482,6 @@ __pattern_equal(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _Ran
});
});
}
#endif
//------------------------------------------------------------------------
// find_if
......@@ -536,7 +514,6 @@ __pattern_find_if(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator
return __internal::__brick_find_if(__first, __last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate, class _IsVector>
_ForwardIterator
__pattern_find_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
......@@ -544,15 +521,15 @@ __pattern_find_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardI
/*is_parallel=*/std::true_type)
{
return __internal::__except_handler([&]() {
return __internal::__parallel_find(std::forward<_ExecutionPolicy>(__exec), __first, __last,
[__pred, __is_vector](_ForwardIterator __i, _ForwardIterator __j) {
return __internal::__brick_find_if(__i, __j, __pred, __is_vector);
},
std::less<typename std::iterator_traits<_ForwardIterator>::difference_type>(),
/*is_first=*/true);
return __internal::__parallel_find(
std::forward<_ExecutionPolicy>(__exec), __first, __last,
[__pred, __is_vector](_ForwardIterator __i, _ForwardIterator __j) {
return __internal::__brick_find_if(__i, __j, __pred, __is_vector);
},
std::less<typename std::iterator_traits<_ForwardIterator>::difference_type>(),
/*is_first=*/true);
});
}
#endif
//------------------------------------------------------------------------
// find_end
......@@ -584,8 +561,8 @@ __find_subrange(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _
while (__first != __last && (__global_last - __first >= __n2))
{
// find position of *s_first in [first, last) (it can be start of subsequence)
__first = __internal::__brick_find_if(__first, __last,
__equal_value_by_pred<_ValueType, _BinaryPredicate>(*__s_first, __pred), __is_vector);
__first = __internal::__brick_find_if(
__first, __last, __equal_value_by_pred<_ValueType, _BinaryPredicate>(*__s_first, __pred), __is_vector);
// if position that was found previously is the start of subsequence
// then we can exit the loop (b_first == true) or keep the position
......@@ -635,8 +612,8 @@ __find_subrange(_RandomAccessIterator __first, _RandomAccessIterator __last, _Ra
// check that all of elements in [first+1, first+count) equal to value
if (__first != __last && (__global_last - __first >= __count) &&
!__internal::__brick_any_of(__first + 1, __first + __count, __not_pred<decltype(__unary_pred)>(__unary_pred),
__is_vector))
!__internal::__brick_any_of(__first + 1, __first + __count,
__not_pred<decltype(__unary_pred)>(__unary_pred), __is_vector))
{
return __first;
}
......@@ -678,7 +655,6 @@ __pattern_find_end(_ExecutionPolicy&&, _ForwardIterator1 __first, _ForwardIterat
return __internal::__brick_find_end(__first, __last, __s_first, __s_last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate,
class _IsVector>
_ForwardIterator1
......@@ -688,23 +664,23 @@ __pattern_find_end(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _Forwar
{
if (__last - __first == __s_last - __s_first)
{
const bool __res = __internal::__pattern_equal(std::forward<_ExecutionPolicy>(__exec), __first, __last, __s_first, __pred,
__is_vector, std::true_type());
const bool __res = __internal::__pattern_equal(std::forward<_ExecutionPolicy>(__exec), __first, __last,
__s_first, __pred, __is_vector, std::true_type());
return __res ? __first : __last;
}
else
{
return __internal::__except_handler([&]() {
return __internal::__parallel_find(
return __internal::__parallel_find(
std::forward<_ExecutionPolicy>(__exec), __first, __last,
[__last, __s_first, __s_last, __pred, __is_vector](_ForwardIterator1 __i, _ForwardIterator1 __j) {
return __internal::__find_subrange(__i, __j, __last, __s_first, __s_last, __pred, false, __is_vector);
return __internal::__find_subrange(__i, __j, __last, __s_first, __s_last, __pred, false,
__is_vector);
},
std::greater<typename std::iterator_traits<_ForwardIterator1>::difference_type>(), /*is_first=*/false);
});
}
}
#endif
//------------------------------------------------------------------------
// find_first_of
......@@ -735,7 +711,6 @@ __pattern_find_first_of(_ExecutionPolicy&&, _ForwardIterator1 __first, _ForwardI
return __internal::__brick_find_first_of(__first, __last, __s_first, __s_last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate,
class _IsVector>
_ForwardIterator1
......@@ -744,7 +719,7 @@ __pattern_find_first_of(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _F
_IsVector __is_vector, /*is_parallel=*/std::true_type) noexcept
{
return __internal::__except_handler([&]() {
return __internal::__parallel_find(
return __internal::__parallel_find(
std::forward<_ExecutionPolicy>(__exec), __first, __last,
[__s_first, __s_last, __pred, __is_vector](_ForwardIterator1 __i, _ForwardIterator1 __j) {
return __internal::__brick_find_first_of(__i, __j, __s_first, __s_last, __pred, __is_vector);
......@@ -752,7 +727,6 @@ __pattern_find_first_of(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _F
std::less<typename std::iterator_traits<_ForwardIterator1>::difference_type>(), /*is_first=*/true);
});
}
#endif
//------------------------------------------------------------------------
// search
......@@ -783,7 +757,6 @@ __pattern_search(_ExecutionPolicy&&, _ForwardIterator1 __first, _ForwardIterator
return __internal::__brick_search(__first, __last, __s_first, __s_last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate,
class _IsVector>
_ForwardIterator1
......@@ -794,8 +767,8 @@ __pattern_search(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardI
{
if (__last - __first == __s_last - __s_first)
{
const bool __res = __internal::__pattern_equal(std::forward<_ExecutionPolicy>(__exec), __first, __last, __s_first, __pred,
__is_vector, std::true_type());
const bool __res = __internal::__pattern_equal(std::forward<_ExecutionPolicy>(__exec), __first, __last,
__s_first, __pred, __is_vector, std::true_type());
return __res ? __first : __last;
}
else
......@@ -804,13 +777,13 @@ __pattern_search(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardI
return __internal::__parallel_find(
std::forward<_ExecutionPolicy>(__exec), __first, __last,
[__last, __s_first, __s_last, __pred, __is_vector](_ForwardIterator1 __i, _ForwardIterator1 __j) {
return __internal::__find_subrange(__i, __j, __last, __s_first, __s_last, __pred, true, __is_vector);
return __internal::__find_subrange(__i, __j, __last, __s_first, __s_last, __pred, true,
__is_vector);
},
std::less<typename std::iterator_traits<_ForwardIterator1>::difference_type>(), /*is_first=*/true);
});
}
}
#endif
//------------------------------------------------------------------------
// search_n
......@@ -841,7 +814,6 @@ __pattern_search_n(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterato
return __internal::__brick_search_n(__first, __last, __count, __value, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Size, class _Tp, class _BinaryPredicate,
class _IsVector>
_RandomAccessIterator
......@@ -851,10 +823,10 @@ __pattern_search_n(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Ra
{
if (__last - __first == __count)
{
const bool __result =
!__internal::__pattern_any_of(std::forward<_ExecutionPolicy>(__exec), __first, __last,
[&__value, &__pred](const _Tp& __val) { return !__pred(__val, __value); }, __is_vector,
/*is_parallel*/ std::true_type());
const bool __result = !__internal::__pattern_any_of(
std::forward<_ExecutionPolicy>(__exec), __first, __last,
[&__value, &__pred](const _Tp& __val) { return !__pred(__val, __value); }, __is_vector,
/*is_parallel*/ std::true_type());
return __result ? __first : __last;
}
else
......@@ -869,7 +841,6 @@ __pattern_search_n(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Ra
});
}
}
#endif
//------------------------------------------------------------------------
// copy_n
......@@ -969,7 +940,7 @@ _OutputIterator
__brick_copy_if(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _UnaryPredicate __pred,
/*vector=*/std::true_type) noexcept
{
#if (__PSTL_MONOTONIC_PRESENT)
#if (_PSTL_MONOTONIC_PRESENT)
return __unseq_backend::__simd_copy_if(__first, __last - __first, __result, __pred);
#else
return std::copy_if(__first, __last, __result, __pred);
......@@ -1028,7 +999,7 @@ void
__brick_copy_by_mask(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result,
bool* __restrict __mask, _Assigner __assigner, /*vector=*/std::true_type) noexcept
{
#if (__PSTL_MONOTONIC_PRESENT)
#if (_PSTL_MONOTONIC_PRESENT)
__unseq_backend::__simd_copy_by_mask(__first, __last - __first, __result, __mask, __assigner);
#else
__internal::__brick_copy_by_mask(__first, __last, __result, __mask, __assigner, std::false_type());
......@@ -1060,7 +1031,7 @@ void
__brick_partition_by_mask(_RandomAccessIterator __first, _RandomAccessIterator __last, _OutputIterator1 __out_true,
_OutputIterator2 __out_false, bool* __mask, /*vector=*/std::true_type) noexcept
{
#if (__PSTL_MONOTONIC_PRESENT)
#if (_PSTL_MONOTONIC_PRESENT)
__unseq_backend::__simd_partition_by_mask(__first, __last - __first, __out_true, __out_false, __mask);
#else
__internal::__brick_partition_by_mask(__first, __last, __out_true, __out_false, __mask, std::false_type());
......@@ -1075,7 +1046,6 @@ __pattern_copy_if(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator
return __internal::__brick_copy_if(__first, __last, __result, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryPredicate,
class _IsVector>
_OutputIterator
......@@ -1093,15 +1063,15 @@ __pattern_copy_if(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Ran
__par_backend::__parallel_strict_scan(
std::forward<_ExecutionPolicy>(__exec), __n, _DifferenceType(0),
[=](_DifferenceType __i, _DifferenceType __len) { // Reduce
return __internal::__brick_calc_mask_1<_DifferenceType>(__first + __i, __first + (__i + __len), __mask + __i,
__pred, __is_vector)
return __internal::__brick_calc_mask_1<_DifferenceType>(__first + __i, __first + (__i + __len),
__mask + __i, __pred, __is_vector)
.first;
},
std::plus<_DifferenceType>(), // Combine
[=](_DifferenceType __i, _DifferenceType __len, _DifferenceType __initial) { // Scan
__internal::__brick_copy_by_mask(__first + __i, __first + (__i + __len), __result + __initial, __mask + __i,
[](_RandomAccessIterator __x, _OutputIterator __z) { *__z = *__x; },
__is_vector);
__internal::__brick_copy_by_mask(
__first + __i, __first + (__i + __len), __result + __initial, __mask + __i,
[](_RandomAccessIterator __x, _OutputIterator __z) { *__z = *__x; }, __is_vector);
},
[&__m](_DifferenceType __total) { __m = __total; });
return __result + __m;
......@@ -1110,7 +1080,6 @@ __pattern_copy_if(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Ran
// trivial sequence - use serial algorithm
return __internal::__brick_copy_if(__first, __last, __result, __pred, __is_vector);
}
#endif
//------------------------------------------------------------------------
// count
......@@ -1139,7 +1108,6 @@ __pattern_count(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator _
return __internal::__brick_count(__first, __last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate, class _IsVector>
typename std::iterator_traits<_ForwardIterator>::difference_type
__pattern_count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
......@@ -1155,7 +1123,6 @@ __pattern_count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIte
std::plus<_SizeType>());
});
}
#endif
//------------------------------------------------------------------------
// unique
......@@ -1174,7 +1141,7 @@ _ForwardIterator
__brick_unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred,
/*is_vector=*/std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
return std::unique(__first, __last, __pred);
}
......@@ -1186,13 +1153,12 @@ __pattern_unique(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator
return __internal::__brick_unique(__first, __last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
// That function is shared between two algorithms - remove_if (__pattern_remove_if) and unique (pattern unique). But a mask calculation is different.
// So, a caller passes _CalcMask brick into remove_elements.
template <class _ExecutionPolicy, class _ForwardIterator, class _CalcMask, class _IsVector>
_ForwardIterator
__remove_elements(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _CalcMask __calc_mask,
_IsVector __is_vector)
_IsVector __is_vector)
{
typedef typename std::iterator_traits<_ForwardIterator>::difference_type _DifferenceType;
typedef typename std::iterator_traits<_ForwardIterator>::value_type _Tp;
......@@ -1214,8 +1180,8 @@ __remove_elements(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardI
return __local_min;
}
// find first iterator that should be removed
bool* __result =
__internal::__brick_find_if(__mask + __i, __mask + __j, [](bool __val) { return !__val; }, __is_vector);
bool* __result = __internal::__brick_find_if(__mask + __i, __mask + __j,
[](bool __val) { return !__val; }, __is_vector);
if (__result - __mask == __j)
{
return __local_min;
......@@ -1242,16 +1208,18 @@ __remove_elements(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardI
__par_backend::__parallel_strict_scan(
std::forward<_ExecutionPolicy>(__exec), __n, _DifferenceType(0),
[__mask, __is_vector](_DifferenceType __i, _DifferenceType __len) {
return __internal::__brick_count(__mask + __i, __mask + __i + __len, [](bool __val) { return __val; }, __is_vector);
return __internal::__brick_count(__mask + __i, __mask + __i + __len, [](bool __val) { return __val; },
__is_vector);
},
std::plus<_DifferenceType>(),
[=](_DifferenceType __i, _DifferenceType __len, _DifferenceType __initial) {
__internal::__brick_copy_by_mask(__first + __i, __first + __i + __len, __result + __initial, __mask + __i,
[](_ForwardIterator __x, _Tp* __z) {
__internal::__invoke_if_else(std::is_trivial<_Tp>(), [&]() { *__z = std::move(*__x); },
[&]() { ::new (std::addressof(*__z)) _Tp(std::move(*__x)); });
},
__is_vector);
__internal::__brick_copy_by_mask(
__first + __i, __first + __i + __len, __result + __initial, __mask + __i,
[](_ForwardIterator __x, _Tp* __z) {
__internal::__invoke_if_else(std::is_trivial<_Tp>(), [&]() { *__z = std::move(*__x); },
[&]() { ::new (std::addressof(*__z)) _Tp(std::move(*__x)); });
},
__is_vector);
},
[&__m](_DifferenceType __total) { __m = __total; });
......@@ -1263,9 +1231,7 @@ __remove_elements(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardI
return __first + __m;
});
}
#endif
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _BinaryPredicate, class _IsVector>
_ForwardIterator
__pattern_unique(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred,
......@@ -1285,13 +1251,12 @@ __pattern_unique(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIt
return __internal::__remove_elements(
std::forward<_ExecutionPolicy>(__exec), ++__first, __last,
[&__pred, __is_vector](bool* __b, bool* __e, _ForwardIterator __it) {
__internal::__brick_walk3(__b, __e, __it - 1, __it,
[&__pred](bool& __x, _ReferenceType __y, _ReferenceType __z) { __x = !__pred(__y, __z); },
__is_vector);
__internal::__brick_walk3(
__b, __e, __it - 1, __it,
[&__pred](bool& __x, _ReferenceType __y, _ReferenceType __z) { __x = !__pred(__y, __z); }, __is_vector);
},
__is_vector);
}
#endif
//------------------------------------------------------------------------
// unique_copy
......@@ -1310,7 +1275,7 @@ OutputIterator
__brick_unique_copy(_RandomAccessIterator __first, _RandomAccessIterator __last, OutputIterator __result,
_BinaryPredicate __pred, /*vector=*/std::true_type) noexcept
{
#if (__PSTL_MONOTONIC_PRESENT)
#if (_PSTL_MONOTONIC_PRESENT)
return __unseq_backend::__simd_unique_copy(__first, __last - __first, __result, __pred);
#else
return std::unique_copy(__first, __last, __result, __pred);
......@@ -1348,7 +1313,6 @@ __brick_calc_mask_2(_RandomAccessIterator __first, _RandomAccessIterator __last,
return __unseq_backend::__simd_calc_mask_2(__first, __last - __first, __mask, __pred);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _BinaryPredicate,
class _IsVector>
_OutputIterator
......@@ -1380,15 +1344,15 @@ __pattern_unique_copy(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
++__extra;
}
return __internal::__brick_calc_mask_2<_DifferenceType>(__first + __i, __first + (__i + __len),
__mask + __i, __pred, __is_vector) +
__mask + __i, __pred, __is_vector) +
__extra;
},
std::plus<_DifferenceType>(), // Combine
[=](_DifferenceType __i, _DifferenceType __len, _DifferenceType __initial) { // Scan
// Phase 2 is same as for __pattern_copy_if
__internal::__brick_copy_by_mask(__first + __i, __first + (__i + __len), __result + __initial, __mask + __i,
[](_RandomAccessIterator __x, _OutputIterator __z) { *__z = *__x; },
__is_vector);
__internal::__brick_copy_by_mask(
__first + __i, __first + (__i + __len), __result + __initial, __mask + __i,
[](_RandomAccessIterator __x, _OutputIterator __z) { *__z = *__x; }, __is_vector);
},
[&__m](_DifferenceType __total) { __m = __total; });
return __result + __m;
......@@ -1398,7 +1362,6 @@ __pattern_unique_copy(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
// trivial sequence - use serial algorithm
return __internal::__brick_unique_copy(__first, __last, __result, __pred, __is_vector);
}
#endif
//------------------------------------------------------------------------
// reverse
......@@ -1461,7 +1424,6 @@ __pattern_reverse(_ExecutionPolicy&&, _BidirectionalIterator __first, _Bidirecti
__internal::__brick_reverse(__first, __last, _is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _BidirectionalIterator, class _IsVector>
void
__pattern_reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last,
......@@ -1473,7 +1435,6 @@ __pattern_reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _Bi
__internal::__brick_reverse(__inner_first, __inner_last, __last - (__inner_first - __first), __is_vector);
});
}
#endif
//------------------------------------------------------------------------
// reverse_copy
......@@ -1507,7 +1468,6 @@ __pattern_reverse_copy(_ExecutionPolicy&&, _BidirectionalIterator __first, _Bidi
return __internal::__brick_reverse_copy(__first, __last, __d_first, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _BidirectionalIterator, class _OutputIterator, class _IsVector>
_OutputIterator
__pattern_reverse_copy(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last,
......@@ -1518,11 +1478,11 @@ __pattern_reverse_copy(_ExecutionPolicy&& __exec, _BidirectionalIterator __first
[__is_vector, __first, __len, __d_first](_BidirectionalIterator __inner_first,
_BidirectionalIterator __inner_last) {
__internal::__brick_reverse_copy(__inner_first, __inner_last,
__d_first + (__len - (__inner_last - __first)), __is_vector);
__d_first + (__len - (__inner_last - __first)),
__is_vector);
});
return __d_first + __len;
}
#endif
//------------------------------------------------------------------------
// rotate
......@@ -1532,7 +1492,7 @@ _ForwardIterator
__brick_rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
/*is_vector=*/std::false_type) noexcept
{
#if __PSTL_CPP11_STD_ROTATE_BROKEN
#if _PSTL_CPP11_STD_ROTATE_BROKEN
std::rotate(__first, __middle, __last);
return std::next(__first, std::distance(__middle, __last));
#else
......@@ -1589,7 +1549,6 @@ __pattern_rotate(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator
return __internal::__brick_rotate(__first, __middle, __last, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _IsVector>
_ForwardIterator
__pattern_rotate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __middle,
......@@ -1611,12 +1570,14 @@ __pattern_rotate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIt
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __first, __middle,
[__last, __middle, __is_vector](_ForwardIterator __b, _ForwardIterator __e) {
__internal::__brick_move(__b, __e, __b + (__last - __middle), __is_vector);
__internal::__brick_move(__b, __e, __b + (__last - __middle),
__is_vector);
});
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __result, __result + (__n - __m),
[__first, __result, __is_vector](_Tp* __b, _Tp* __e) {
__internal::__brick_move(__b, __e, __first + (__b - __result), __is_vector);
__internal::__brick_move(__b, __e, __first + (__b - __result),
__is_vector);
});
return __first + (__last - __middle);
......@@ -1629,26 +1590,26 @@ __pattern_rotate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIt
_Tp* __result = __buf.get();
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __first, __middle,
[__first, __result, __is_vector](_ForwardIterator __b, _ForwardIterator __e) {
__internal::__brick_uninitialized_move(__b, __e, __result + (__b - __first),
__is_vector);
__internal::__brick_uninitialized_move(
__b, __e, __result + (__b - __first), __is_vector);
});
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __middle, __last,
[__first, __middle, __is_vector](_ForwardIterator __b, _ForwardIterator __e) {
__internal::__brick_move(__b, __e, __first + (__b - __middle), __is_vector);
__internal::__brick_move(__b, __e, __first + (__b - __middle),
__is_vector);
});
__par_backend::__parallel_for(std::forward<_ExecutionPolicy>(__exec), __result, __result + __m,
[__n, __m, __first, __result, __is_vector](_Tp* __b, _Tp* __e) {
__internal::__brick_move(__b, __e, __first + ((__n - __m) + (__b - __result)),
__is_vector);
__internal::__brick_move(
__b, __e, __first + ((__n - __m) + (__b - __result)), __is_vector);
});
return __first + (__last - __middle);
});
}
}
#endif
//------------------------------------------------------------------------
// rotate_copy
......@@ -1679,7 +1640,6 @@ __pattern_rotate_copy(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIter
return __internal::__brick_rotate_copy(__first, __middle, __last, __result, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _IsVector>
_OutputIterator
__pattern_rotate_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __middle,
......@@ -1709,7 +1669,6 @@ __pattern_rotate_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Forw
});
return __result + (__last - __first);
}
#endif
//------------------------------------------------------------------------
// is_partitioned
......@@ -1758,7 +1717,6 @@ __pattern_is_partitioned(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardI
return __internal::__brick_is_partitioned(__first, __last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _UnaryPredicate, class _IsVector>
bool
__pattern_is_partitioned(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last,
......@@ -1855,7 +1813,6 @@ __pattern_is_partitioned(_ExecutionPolicy&& __exec, _ForwardIterator __first, _F
});
}
}
#endif
//------------------------------------------------------------------------
// partition
......@@ -1874,7 +1831,7 @@ _ForwardIterator
__brick_partition(_ForwardIterator __first, _ForwardIterator __last, _UnaryPredicate __pred,
/*is_vector=*/std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
return std::partition(__first, __last, __pred);
}
......@@ -1886,7 +1843,6 @@ __pattern_partition(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterat
return __internal::__brick_partition(__first, __last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _UnaryPredicate, class _IsVector>
_ForwardIterator
__pattern_partition(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last,
......@@ -1923,7 +1879,8 @@ __pattern_partition(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Forwar
__par_backend::__parallel_for(
std::forward<_ExecutionPolicy>(__exec), __val1.__pivot, __val1.__pivot + __size1,
[__val1, __val2, __size1, __is_vector](_ForwardIterator __i, _ForwardIterator __j) {
__internal::__brick_swap_ranges(__i, __j, (__val2.__pivot - __size1) + (__i - __val1.__pivot), __is_vector);
__internal::__brick_swap_ranges(__i, __j, (__val2.__pivot - __size1) + (__i - __val1.__pivot),
__is_vector);
});
return {__new_begin, __val2.__pivot - __size1, __val2.__end};
}
......@@ -1953,7 +1910,6 @@ __pattern_partition(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Forwar
return __result.__pivot;
});
}
#endif
//------------------------------------------------------------------------
// stable_partition
......@@ -1972,7 +1928,7 @@ _BidirectionalIterator
__brick_stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _UnaryPredicate __pred,
/*__is_vector=*/std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
return std::stable_partition(__first, __last, __pred);
}
......@@ -1985,7 +1941,6 @@ __pattern_stable_partition(_ExecutionPolicy&&, _BidirectionalIterator __first, _
return __internal::__brick_stable_partition(__first, __last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _BidirectionalIterator, class _UnaryPredicate, class _IsVector>
_BidirectionalIterator
__pattern_stable_partition(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last,
......@@ -2037,7 +1992,6 @@ __pattern_stable_partition(_ExecutionPolicy&& __exec, _BidirectionalIterator __f
return __result.__pivot;
});
}
#endif
//------------------------------------------------------------------------
// partition_copy
......@@ -2056,7 +2010,7 @@ std::pair<_OutputIterator1, _OutputIterator2>
__brick_partition_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator1 __out_true,
_OutputIterator2 __out_false, _UnaryPredicate __pred, /*is_vector=*/std::true_type) noexcept
{
#if (__PSTL_MONOTONIC_PRESENT)
#if (_PSTL_MONOTONIC_PRESENT)
return __unseq_backend::__simd_partition_copy(__first, __last - __first, __out_true, __out_false, __pred);
#else
return std::partition_copy(__first, __last, __out_true, __out_false, __pred);
......@@ -2073,7 +2027,6 @@ __pattern_partition_copy(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardI
return __internal::__brick_partition_copy(__first, __last, __out_true, __out_false, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator1, class _OutputIterator2,
class _UnaryPredicate, class _IsVector>
std::pair<_OutputIterator1, _OutputIterator2>
......@@ -2087,21 +2040,23 @@ __pattern_partition_copy(_ExecutionPolicy&& __exec, _RandomAccessIterator __firs
if (_DifferenceType(1) < __n)
{
__par_backend::__buffer<bool> __mask_buf(__n);
return __internal::__except_handler([&__exec, __n, __first, __out_true, __out_false, __is_vector, __pred, &__mask_buf]() {
return __internal::__except_handler([&__exec, __n, __first, __out_true, __out_false, __is_vector, __pred,
&__mask_buf]() {
bool* __mask = __mask_buf.get();
_ReturnType __m{};
__par_backend::__parallel_strict_scan(
std::forward<_ExecutionPolicy>(__exec), __n, std::make_pair(_DifferenceType(0), _DifferenceType(0)),
[=](_DifferenceType __i, _DifferenceType __len) { // Reduce
return __internal::__brick_calc_mask_1<_DifferenceType>(__first + __i, __first + (__i + __len), __mask + __i,
__pred, __is_vector);
return __internal::__brick_calc_mask_1<_DifferenceType>(__first + __i, __first + (__i + __len),
__mask + __i, __pred, __is_vector);
},
[](const _ReturnType& __x, const _ReturnType& __y) -> _ReturnType {
return std::make_pair(__x.first + __y.first, __x.second + __y.second);
}, // Combine
[=](_DifferenceType __i, _DifferenceType __len, _ReturnType __initial) { // Scan
__internal::__brick_partition_by_mask(__first + __i, __first + (__i + __len), __out_true + __initial.first,
__out_false + __initial.second, __mask + __i, __is_vector);
__internal::__brick_partition_by_mask(__first + __i, __first + (__i + __len),
__out_true + __initial.first, __out_false + __initial.second,
__mask + __i, __is_vector);
},
[&__m](_ReturnType __total) { __m = __total; });
return std::make_pair(__out_true + __m.first, __out_false + __m.second);
......@@ -2110,7 +2065,6 @@ __pattern_partition_copy(_ExecutionPolicy&& __exec, _RandomAccessIterator __firs
// trivial sequence - use serial algorithm
return __internal::__brick_partition_copy(__first, __last, __out_true, __out_false, __pred, __is_vector);
}
#endif
//------------------------------------------------------------------------
// sort
......@@ -2125,7 +2079,6 @@ __pattern_sort(_ExecutionPolicy&&, _RandomAccessIterator __first, _RandomAccessI
std::sort(__first, __last, __comp);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
void
__pattern_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
......@@ -2138,7 +2091,6 @@ __pattern_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Random
__last - __first);
});
}
#endif
//------------------------------------------------------------------------
// stable_sort
......@@ -2152,7 +2104,6 @@ __pattern_stable_sort(_ExecutionPolicy&&, _RandomAccessIterator __first, _Random
std::stable_sort(__first, __last, __comp);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
void
__pattern_stable_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last,
......@@ -2164,7 +2115,6 @@ __pattern_stable_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
_Compare __comp) { std::stable_sort(__first, __last, __comp); });
});
}
#endif
//------------------------------------------------------------------------
// partial_sort
......@@ -2179,7 +2129,6 @@ __pattern_partial_sort(_ExecutionPolicy&&, _RandomAccessIterator __first, _Rando
std::partial_sort(__first, __middle, __last, __comp);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
void
__pattern_partial_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __middle,
......@@ -2198,7 +2147,6 @@ __pattern_partial_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
__n);
});
}
#endif
//------------------------------------------------------------------------
// partial_sort_copy
......@@ -2213,7 +2161,6 @@ __pattern_partial_sort_copy(_ExecutionPolicy&&, _ForwardIterator __first, _Forwa
return std::partial_sort_copy(__first, __last, __d_first, __d_last, __comp);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _RandomAccessIterator, class _Compare, class _IsVector>
_RandomAccessIterator
__pattern_partial_sort_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last,
......@@ -2237,11 +2184,11 @@ __pattern_partial_sort_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first,
_ForwardIterator __j1 = __first + (__j - __d_first);
// 1. Copy elements from input to output
#if !__PSTL_ICC_18_OMP_SIMD_BROKEN
# if !_PSTL_ICC_18_OMP_SIMD_BROKEN
__internal::__brick_copy(__i1, __j1, __i, __is_vector);
#else
# else
std::copy(__i1, __j1, __i);
#endif
# endif
// 2. Sort elements in output sequence
std::sort(__i, __j, __comp);
},
......@@ -2282,7 +2229,6 @@ __pattern_partial_sort_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first,
}
});
}
#endif
//------------------------------------------------------------------------
// adjacent_find
......@@ -2311,7 +2257,6 @@ __pattern_adjacent_find(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIt
return __internal::__brick_adjacent_find(__first, __last, __pred, __is_vector, __or_semantic);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _BinaryPredicate, class _IsVector>
_RandomAccessIterator
__pattern_adjacent_find(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last,
......@@ -2357,7 +2302,6 @@ __pattern_adjacent_find(_ExecutionPolicy&& __exec, _RandomAccessIterator __first
);
});
}
#endif
//------------------------------------------------------------------------
// nth_element
......@@ -2372,7 +2316,6 @@ __pattern_nth_element(_ExecutionPolicy&&, _RandomAccessIterator __first, _Random
std::nth_element(__first, __nth, __last, __comp);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
void
__pattern_nth_element(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __nth,
......@@ -2390,8 +2333,9 @@ __pattern_nth_element(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
do
{
__x = __internal::__pattern_partition(std::forward<_ExecutionPolicy>(__exec), __first + 1, __last,
[&__comp, __first](const _Tp& __x) { return __comp(__x, *__first); }, __is_vector,
/*is_parallel=*/std::true_type());
[&__comp, __first](const _Tp& __x) { return __comp(__x, *__first); },
__is_vector,
/*is_parallel=*/std::true_type());
--__x;
if (__x != __first)
{
......@@ -2418,7 +2362,6 @@ __pattern_nth_element(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
}
} while (__x != __nth);
}
#endif
//------------------------------------------------------------------------
// fill, fill_n
......@@ -2447,7 +2390,6 @@ __pattern_fill(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator __
__internal::__brick_fill(__first, __last, __value, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _IsVector>
_ForwardIterator
__pattern_fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value,
......@@ -2461,7 +2403,6 @@ __pattern_fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIter
return __last;
});
}
#endif
template <class _OutputIterator, class _Size, class _Tp>
_OutputIterator
......@@ -2490,8 +2431,8 @@ _OutputIterator
__pattern_fill_n(_ExecutionPolicy&& __exec, _OutputIterator __first, _Size __count, const _Tp& __value,
/*is_parallel=*/std::true_type, _IsVector __is_vector)
{
return __internal::__pattern_fill(std::forward<_ExecutionPolicy>(__exec), __first, __first + __count, __value, std::true_type(),
__is_vector);
return __internal::__pattern_fill(std::forward<_ExecutionPolicy>(__exec), __first, __first + __count, __value,
std::true_type(), __is_vector);
}
//------------------------------------------------------------------------
......@@ -2521,7 +2462,6 @@ __pattern_generate(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterato
__internal::__brick_generate(__first, __last, __g, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Generator, class _IsVector>
_ForwardIterator
__pattern_generate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Generator __g,
......@@ -2535,7 +2475,6 @@ __pattern_generate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Forward
return __last;
});
}
#endif
template <class OutputIterator, class Size, class _Generator>
OutputIterator
......@@ -2559,7 +2498,6 @@ __pattern_generate_n(_ExecutionPolicy&&, _OutputIterator __first, _Size __count,
return __internal::__brick_generate_n(__first, __count, __g, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _OutputIterator, class _Size, class _Generator, class _IsVector>
_OutputIterator
__pattern_generate_n(_ExecutionPolicy&& __exec, _OutputIterator __first, _Size __count, _Generator __g,
......@@ -2567,10 +2505,9 @@ __pattern_generate_n(_ExecutionPolicy&& __exec, _OutputIterator __first, _Size _
{
static_assert(__is_random_access_iterator<_OutputIterator>::value,
"Pattern-brick error. Should be a random access iterator.");
return __internal::__pattern_generate(std::forward<_ExecutionPolicy>(__exec), __first, __first + __count, __g, std::true_type(),
__is_vector);
return __internal::__pattern_generate(std::forward<_ExecutionPolicy>(__exec), __first, __first + __count, __g,
std::true_type(), __is_vector);
}
#endif
//------------------------------------------------------------------------
// remove
......@@ -2589,7 +2526,7 @@ _RandomAccessIterator
__brick_remove_if(_RandomAccessIterator __first, _RandomAccessIterator __last, _UnaryPredicate __pred,
/* __is_vector = */ std::true_type) noexcept
{
#if __PSTL_MONOTONIC_PRESENT
#if _PSTL_MONOTONIC_PRESENT
return __unseq_backend::__simd_remove_if(__first, __last - __first, __pred);
#else
return std::remove_if(__first, __last, __pred);
......@@ -2604,7 +2541,6 @@ __pattern_remove_if(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterat
return __internal::__brick_remove_if(__first, __last, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _UnaryPredicate, class _IsVector>
_ForwardIterator
__pattern_remove_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last,
......@@ -2618,15 +2554,14 @@ __pattern_remove_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Forwar
return __internal::__brick_remove_if(__first, __last, __pred, __is_vector);
}
return __internal::__remove_elements(std::forward<_ExecutionPolicy>(__exec), __first, __last,
[&__pred, __is_vector](bool* __b, bool* __e, _ForwardIterator __it) {
__internal::__brick_walk2(__b, __e, __it,
[&__pred](bool& __x, _ReferenceType __y) { __x = !__pred(__y); },
__is_vector);
},
__is_vector);
return __internal::__remove_elements(
std::forward<_ExecutionPolicy>(__exec), __first, __last,
[&__pred, __is_vector](bool* __b, bool* __e, _ForwardIterator __it) {
__internal::__brick_walk2(__b, __e, __it, [&__pred](bool& __x, _ReferenceType __y) { __x = !__pred(__y); },
__is_vector);
},
__is_vector);
}
#endif
//------------------------------------------------------------------------
// merge
......@@ -2647,7 +2582,7 @@ __brick_merge(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIte
_ForwardIterator2 __last2, _OutputIterator __d_first, _Compare __comp,
/* __is_vector = */ std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
return std::merge(__first1, __last1, __first2, __last2, __d_first, __comp);
}
......@@ -2661,7 +2596,6 @@ __pattern_merge(_ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIterator
return __internal::__brick_merge(__first1, __last1, __first2, __last2, __d_first, __comp, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
......@@ -2672,11 +2606,11 @@ __pattern_merge(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _Ran
__par_backend::__parallel_merge(
std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __d_first, __comp,
[__is_vector](_RandomAccessIterator1 __f1, _RandomAccessIterator1 __l1, _RandomAccessIterator2 __f2,
_RandomAccessIterator2 __l2, _OutputIterator __f3,
_Compare __comp) { return __internal::__brick_merge(__f1, __l1, __f2, __l2, __f3, __comp, __is_vector); });
_RandomAccessIterator2 __l2, _OutputIterator __f3, _Compare __comp) {
return __internal::__brick_merge(__f1, __l1, __f2, __l2, __f3, __comp, __is_vector);
});
return __d_first + (__last1 - __first1) + (__last2 - __first2);
}
#endif
//------------------------------------------------------------------------
// inplace_merge
......@@ -2694,7 +2628,7 @@ void
__brick_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
_Compare __comp, /* __is_vector = */ std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial")
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial")
std::inplace_merge(__first, __middle, __last, __comp);
}
......@@ -2707,7 +2641,6 @@ __pattern_inplace_merge(_ExecutionPolicy&&, _BidirectionalIterator __first, _Bid
__internal::__brick_inplace_merge(__first, __middle, __last, __comp, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _BidirectionalIterator, class _Compare, class _IsVector>
void
__pattern_inplace_merge(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __middle,
......@@ -2724,8 +2657,8 @@ __pattern_inplace_merge(_ExecutionPolicy&& __exec, _BidirectionalIterator __firs
_Tp* __r = __buf.get();
__internal::__except_handler([&]() {
auto __move_values = [](_BidirectionalIterator __x, _Tp* __z) {
__internal::__invoke_if_else(std::is_trivial<_Tp>(), [&]() { *__z = std::move(*__x); },
[&]() { ::new (std::addressof(*__z)) _Tp(std::move(*__x)); });
__internal::__invoke_if_else(std::is_trivial<_Tp>(), [&]() { *__z = std::move(*__x); },
[&]() { ::new (std::addressof(*__z)) _Tp(std::move(*__x)); });
};
auto __move_sequences = [](_BidirectionalIterator __first1, _BidirectionalIterator __last1, _Tp* __first2) {
......@@ -2749,7 +2682,6 @@ __pattern_inplace_merge(_ExecutionPolicy&& __exec, _BidirectionalIterator __firs
});
});
}
#endif
//------------------------------------------------------------------------
// includes
......@@ -2764,7 +2696,6 @@ __pattern_includes(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwa
return std::includes(__first1, __last1, __first2, __last2, __comp);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Compare, class _IsVector>
bool
__pattern_includes(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
......@@ -2785,11 +2716,11 @@ __pattern_includes(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwa
return !__comp(*__first1, *__first2) && !__comp(*__first2, *__first1);
return __internal::__except_handler([&]() {
return !__internal::__parallel_or(
return !__internal::__parallel_or(
std::forward<_ExecutionPolicy>(__exec), __first2, __last2,
[__first1, __last1, __first2, __last2, &__comp](_ForwardIterator2 __i, _ForwardIterator2 __j) {
__PSTL_ASSERT(__j > __i);
//__PSTL_ASSERT(__j - __i > 1);
_PSTL_ASSERT(__j > __i);
//assert(__j - __i > 1);
//1. moving boundaries to "consume" subsequence of equal elements
auto __is_equal = [&__comp](_ForwardIterator2 __a, _ForwardIterator2 __b) -> bool {
......@@ -2813,17 +2744,15 @@ __pattern_includes(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwa
//2. testing is __a subsequence of the second range included into the first range
auto __b = std::lower_bound(__first1, __last1, *__i, __comp);
__PSTL_ASSERT(!__comp(*(__last1 - 1), *__b));
__PSTL_ASSERT(!__comp(*(__j - 1), *__i));
_PSTL_ASSERT(!__comp(*(__last1 - 1), *__b));
_PSTL_ASSERT(!__comp(*(__j - 1), *__i));
return !std::includes(__b, __last1, __i, __j, __comp);
});
});
}
#endif
constexpr auto __set_algo_cut_off = 1000;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector, class _SizeFunction, class _SetOP>
_OutputIterator
......@@ -2849,14 +2778,14 @@ __parallel_set_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwar
__par_backend::__buffer<_T> __buf(__size_func(__n1, __n2));
return __internal::__except_handler([&__exec, __n1, __first1, __last1, __first2, __last2, __result, __is_vector, __comp,
__size_func, __set_op, &__buf]() {
return __internal::__except_handler([&__exec, __n1, __first1, __last1, __first2, __last2, __result, __is_vector,
__comp, __size_func, __set_op, &__buf]() {
auto __buffer = __buf.get();
_DifferenceType __m{};
auto __scan = [=](_DifferenceType, _DifferenceType, const _SetRange& __s) { // Scan
if (!__s.empty())
__internal::__brick_move(__buffer + __s.__buf_pos, __buffer + (__s.__buf_pos + __s.__len), __result + __s.__pos,
__is_vector);
__internal::__brick_move(__buffer + __s.__buf_pos, __buffer + (__s.__buf_pos + __s.__len),
__result + __s.__pos, __is_vector);
};
__par_backend::__parallel_strict_scan(
std::forward<_ExecutionPolicy>(__exec), __n1, _SetRange{0, 0, 0}, //-1, 0},
......@@ -2912,38 +2841,36 @@ __parallel_set_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forwar
return __result + __m;
});
}
#endif
#if __PSTL_USE_PAR_POLICIES
//a shared parallel pattern for '__pattern_set_union' and '__pattern_set_symmetric_difference'
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _SetUnionOp, class _IsVector>
_OutputIterator
__parallel_set_union_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp,
_SetUnionOp __set_union_op, _IsVector __is_vector)
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _OutputIterator __result,
_Compare __comp, _SetUnionOp __set_union_op, _IsVector __is_vector)
{
typedef typename std::iterator_traits<_ForwardIterator1>::difference_type _DifferenceType;
const auto __n1 = __last1 - __first1;
const auto __n2 = __last2 - __first2;
auto copy_range1 = [__is_vector](_ForwardIterator1 __begin, _ForwardIterator1 __end, _OutputIterator __res) {
auto __copy_range1 = [__is_vector](_ForwardIterator1 __begin, _ForwardIterator1 __end, _OutputIterator __res) {
return __internal::__brick_copy(__begin, __end, __res, __is_vector);
};
auto copy_range2 = [__is_vector](_ForwardIterator2 __begin, _ForwardIterator2 __end, _OutputIterator __res) {
auto __copy_range2 = [__is_vector](_ForwardIterator2 __begin, _ForwardIterator2 __end, _OutputIterator __res) {
return __internal::__brick_copy(__begin, __end, __res, __is_vector);
};
// {1} {}: parallel copying just first sequence
if (__n2 == 0)
return __internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __result, copy_range1,
std::true_type());
return __internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __result,
__copy_range1, std::true_type());
// {} {2}: parallel copying justmake second sequence
if (__n1 == 0)
return __internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first2, __last2, __result, copy_range2,
std::true_type());
return __internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first2, __last2, __result,
__copy_range2, std::true_type());
// testing whether the sequences are intersected
_ForwardIterator1 __left_bound_seq_1 = std::lower_bound(__first1, __last1, *__first2, __comp);
......@@ -2951,16 +2878,16 @@ __parallel_set_union_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _
if (__left_bound_seq_1 == __last1)
{
//{1} < {2}: seq2 is wholly greater than seq1, so, do parallel copying seq1 and seq2
__par_backend::__parallel_invoke(std::forward<_ExecutionPolicy>(__exec),
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first1,
__last1, __result, copy_range1, std::true_type());
},
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first2,
__last2, __result + __n1, copy_range2,
std::true_type());
});
__par_backend::__parallel_invoke(
std::forward<_ExecutionPolicy>(__exec),
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __result,
__copy_range1, std::true_type());
},
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first2, __last2,
__result + __n1, __copy_range2, std::true_type());
});
return __result + __n1 + __n2;
}
......@@ -2970,16 +2897,16 @@ __parallel_set_union_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _
if (__left_bound_seq_2 == __last2)
{
//{2} < {1}: seq2 is wholly greater than seq1, so, do parallel copying seq1 and seq2
__par_backend::__parallel_invoke(std::forward<_ExecutionPolicy>(__exec),
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first2,
__last2, __result, copy_range2, std::true_type());
},
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first1,
__last1, __result + __n2, copy_range1,
std::true_type());
});
__par_backend::__parallel_invoke(
std::forward<_ExecutionPolicy>(__exec),
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first2, __last2, __result,
__copy_range2, std::true_type());
},
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first1, __last1,
__result + __n2, __copy_range1, std::true_type());
});
return __result + __n1 + __n2;
}
......@@ -2992,20 +2919,20 @@ __parallel_set_union_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _
std::forward<_ExecutionPolicy>(__exec),
//do parallel copying of [first1; left_bound_seq_1)
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first1, __left_bound_seq_1, __res_or,
copy_range1, std::true_type());
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first1, __left_bound_seq_1,
__res_or, __copy_range1, std::true_type());
},
[=, &__result] {
__result = __internal::__parallel_set_op(std::forward<_ExecutionPolicy>(__exec), __left_bound_seq_1, __last1,
__first2, __last2, __result, __comp,
[](_DifferenceType __n, _DifferenceType __m) { return __n + __m; },
__set_union_op, __is_vector);
__result = __internal::__parallel_set_op(
std::forward<_ExecutionPolicy>(__exec), __left_bound_seq_1, __last1, __first2, __last2, __result,
__comp, [](_DifferenceType __n, _DifferenceType __m) { return __n + __m; }, __set_union_op,
__is_vector);
});
return __result;
}
const auto __m2 = __left_bound_seq_2 - __first2;
__PSTL_ASSERT(__m1 == 0 || __m2 == 0);
_PSTL_ASSERT(__m1 == 0 || __m2 == 0);
if (__m2 > __set_algo_cut_off)
{
auto __res_or = __result;
......@@ -3014,23 +2941,22 @@ __parallel_set_union_op(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _
std::forward<_ExecutionPolicy>(__exec),
//do parallel copying of [first2; left_bound_seq_2)
[=] {
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first2, __left_bound_seq_2, __res_or,
copy_range2, std::true_type());
__internal::__pattern_walk2_brick(std::forward<_ExecutionPolicy>(__exec), __first2, __left_bound_seq_2,
__res_or, __copy_range2, std::true_type());
},
[=, &__result] {
__result = __internal::__parallel_set_op(std::forward<_ExecutionPolicy>(__exec), __first1, __last1,
__left_bound_seq_2, __last2, __result, __comp,
[](_DifferenceType __n, _DifferenceType __m) { return __n + __m; },
__set_union_op, __is_vector);
__result = __internal::__parallel_set_op(
std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __left_bound_seq_2, __last2, __result,
__comp, [](_DifferenceType __n, _DifferenceType __m) { return __n + __m; }, __set_union_op,
__is_vector);
});
return __result;
}
return __internal::__parallel_set_op(std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result,
__comp, [](_DifferenceType __n, _DifferenceType __m) { return __n + __m; }, __set_union_op,
__is_vector);
return __internal::__parallel_set_op(
std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result, __comp,
[](_DifferenceType __n, _DifferenceType __m) { return __n + __m; }, __set_union_op, __is_vector);
}
#endif
//------------------------------------------------------------------------
// set_union
......@@ -3051,7 +2977,7 @@ __brick_set_union(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _Forwar
_ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp,
/*__is_vector=*/std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
return std::set_union(__first1, __last1, __first2, __last2, __result, __comp);
}
......@@ -3066,7 +2992,6 @@ __pattern_set_union(_ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIter
return __internal::__brick_set_union(__first1, __last1, __first2, __last2, __result, __comp, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
......@@ -3083,15 +3008,13 @@ __pattern_set_union(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _Forw
return std::set_union(__first1, __last1, __first2, __last2, __result, __comp);
typedef typename std::iterator_traits<_OutputIterator>::value_type _T;
return __internal::__parallel_set_union_op(std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result,
__comp,
[](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _T* __result, _Compare __comp) {
return std::set_union(__first1, __last1, __first2, __last2, __result, __comp);
},
__is_vector);
return __internal::__parallel_set_union_op(
std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result, __comp,
[](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
_T* __result,
_Compare __comp) { return std::set_union(__first1, __last1, __first2, __last2, __result, __comp); },
__is_vector);
}
#endif
//------------------------------------------------------------------------
// set_intersection
......@@ -3112,7 +3035,7 @@ __brick_set_intersection(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp,
/*__is_vector=*/std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
return std::set_intersection(__first1, __last1, __first2, __last2, __result, __comp);
}
......@@ -3126,7 +3049,6 @@ __pattern_set_intersection(_ExecutionPolicy&&, _ForwardIterator1 __first1, _Forw
return __internal::__brick_set_intersection(__first1, __last1, __first2, __last2, __result, __comp, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
......@@ -3188,7 +3110,6 @@ __pattern_set_intersection(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1
// [left_bound_seq_1; last1) and [left_bound_seq_2; last2) - use serial algorithm
return std::set_intersection(__left_bound_seq_1, __last1, __left_bound_seq_2, __last2, __result, __comp);
}
#endif
//------------------------------------------------------------------------
// set_difference
......@@ -3209,7 +3130,7 @@ __brick_set_difference(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _F
_ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp,
/*__is_vector=*/std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
return std::set_difference(__first1, __last1, __first2, __last2, __result, __comp);
}
......@@ -3223,7 +3144,6 @@ __pattern_set_difference(_ExecutionPolicy&&, _ForwardIterator1 __first1, _Forwar
return __internal::__brick_set_difference(__first1, __last1, __first2, __last2, __result, __comp, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
......@@ -3273,18 +3193,17 @@ __pattern_set_difference(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1,
std::true_type());
if (__n1 + __n2 > __set_algo_cut_off)
return __internal::__parallel_set_op(std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result,
__comp, [](_DifferenceType __n, _DifferenceType __m) { return __n; },
[](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _T* __result, _Compare __comp) {
return std::set_difference(__first1, __last1, __first2, __last2, __result, __comp);
},
__is_vector);
return __internal::__parallel_set_op(
std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __result, __comp,
[](_DifferenceType __n, _DifferenceType __m) { return __n; },
[](_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _T* __result,
_Compare __comp) { return std::set_difference(__first1, __last1, __first2, __last2, __result, __comp); },
__is_vector);
// use serial algorithm
return std::set_difference(__first1, __last1, __first2, __last2, __result, __comp);
}
#endif
//------------------------------------------------------------------------
// set_symmetric_difference
......@@ -3305,7 +3224,7 @@ __brick_set_symmetric_difference(_ForwardIterator1 __first1, _ForwardIterator1 _
_ForwardIterator2 __last2, _OutputIterator __result, _Compare __comp,
/*__is_vector=*/std::true_type) noexcept
{
__PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
_PSTL_PRAGMA_MESSAGE("Vectorized algorithm unimplemented, redirected to serial");
return std::set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __comp);
}
......@@ -3316,10 +3235,10 @@ __pattern_set_symmetric_difference(_ExecutionPolicy&&, _ForwardIterator1 __first
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _OutputIterator __result,
_Compare __comp, _IsVector __is_vector, /*is_parallel=*/std::false_type) noexcept
{
return __internal::__brick_set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __comp, __is_vector);
return __internal::__brick_set_symmetric_difference(__first1, __last1, __first2, __last2, __result, __comp,
__is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _OutputIterator,
class _Compare, class _IsVector>
_OutputIterator
......@@ -3344,7 +3263,6 @@ __pattern_set_symmetric_difference(_ExecutionPolicy&& __exec, _ForwardIterator1
},
__is_vector);
}
#endif
//------------------------------------------------------------------------
// is_heap_until
......@@ -3382,7 +3300,7 @@ __pattern_is_heap_until(_ExecutionPolicy&&, _RandomAccessIterator __first, _Rand
template <class _RandomAccessIterator, class _DifferenceType, class _Compare>
_RandomAccessIterator
__is_heap_until_local(_RandomAccessIterator __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp,
/* __is_vector = */ std::false_type) noexcept
/* __is_vector = */ std::false_type) noexcept
{
_DifferenceType __i = __begin;
for (; __i < __end; ++__i)
......@@ -3398,14 +3316,13 @@ __is_heap_until_local(_RandomAccessIterator __first, _DifferenceType __begin, _D
template <class _RandomAccessIterator, class _DifferenceType, class _Compare>
_RandomAccessIterator
__is_heap_until_local(_RandomAccessIterator __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp,
/* __is_vector = */ std::true_type) noexcept
/* __is_vector = */ std::true_type) noexcept
{
return __unseq_backend::__simd_first(
__first, __begin, __end,
[&__comp](_RandomAccessIterator __it, _DifferenceType __i) { return __comp(__it[(__i - 1) / 2], __it[__i]); });
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsVector>
_RandomAccessIterator
__pattern_is_heap_until(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last,
......@@ -3423,7 +3340,6 @@ __pattern_is_heap_until(_ExecutionPolicy&& __exec, _RandomAccessIterator __first
std::less<typename std::iterator_traits<_RandomAccessIterator>::difference_type>(), /*is_first=*/true);
});
}
#endif
//------------------------------------------------------------------------
// min_element
......@@ -3442,7 +3358,7 @@ _ForwardIterator
__brick_min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp,
/* __is_vector = */ std::true_type) noexcept
{
#if __PSTL_UDR_PRESENT
#if _PSTL_UDR_PRESENT
return __unseq_backend::__simd_min_element(__first, __last - __first, __comp);
#else
return std::min_element(__first, __last, __comp);
......@@ -3457,7 +3373,6 @@ __pattern_min_element(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIter
return __internal::__brick_min_element(__first, __last, __comp, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <typename _ExecutionPolicy, typename _RandomAccessIterator, typename _Compare, typename _IsVector>
_RandomAccessIterator
__pattern_min_element(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last,
......@@ -3471,7 +3386,8 @@ __pattern_min_element(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
std::forward<_ExecutionPolicy>(__exec), __first + 1, __last, __first,
[=](_RandomAccessIterator __begin, _RandomAccessIterator __end,
_RandomAccessIterator __init) -> _RandomAccessIterator {
const _RandomAccessIterator subresult = __internal::__brick_min_element(__begin, __end, __comp, __is_vector);
const _RandomAccessIterator subresult =
__internal::__brick_min_element(__begin, __end, __comp, __is_vector);
return __internal::__cmp_iterators_by_values(__init, subresult, __comp);
},
[=](_RandomAccessIterator __it1, _RandomAccessIterator __it2) -> _RandomAccessIterator {
......@@ -3479,7 +3395,6 @@ __pattern_min_element(_ExecutionPolicy&& __exec, _RandomAccessIterator __first,
});
});
}
#endif
//------------------------------------------------------------------------
// minmax_element
......@@ -3498,7 +3413,7 @@ std::pair<_ForwardIterator, _ForwardIterator>
__brick_minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp,
/* __is_vector = */ std::true_type) noexcept
{
#if __PSTL_UDR_PRESENT
#if _PSTL_UDR_PRESENT
return __unseq_backend::__simd_minmax_element(__first, __last - __first, __comp);
#else
return std::minmax_element(__first, __last, __comp);
......@@ -3513,7 +3428,6 @@ __pattern_minmax_element(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardI
return __internal::__brick_minmax_element(__first, __last, __comp, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <typename _ExecutionPolicy, typename _ForwardIterator, typename _Compare, typename _IsVector>
std::pair<_ForwardIterator, _ForwardIterator>
__pattern_minmax_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp,
......@@ -3529,9 +3443,9 @@ __pattern_minmax_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _F
std::forward<_ExecutionPolicy>(__exec), __first + 1, __last, std::make_pair(__first, __first),
[=](_ForwardIterator __begin, _ForwardIterator __end, _Result __init) -> _Result {
const _Result __subresult = __internal::__brick_minmax_element(__begin, __end, __comp, __is_vector);
return std::make_pair(
__internal::__cmp_iterators_by_values(__subresult.first, __init.first, __comp),
__internal::__cmp_iterators_by_values(__init.second, __subresult.second, __not_pred<_Compare>(__comp)));
return std::make_pair(__internal::__cmp_iterators_by_values(__subresult.first, __init.first, __comp),
__internal::__cmp_iterators_by_values(__init.second, __subresult.second,
__not_pred<_Compare>(__comp)));
},
[=](_Result __p1, _Result __p2) -> _Result {
return std::make_pair(
......@@ -3540,7 +3454,6 @@ __pattern_minmax_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _F
});
});
}
#endif
//------------------------------------------------------------------------
// mismatch
......@@ -3550,7 +3463,7 @@ std::pair<_ForwardIterator1, _ForwardIterator2>
__mismatch_serial(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _BinaryPredicate __pred)
{
#if __PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT
#if _PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT
return std::mismatch(__first1, __last1, __first2, __last2, __pred);
#else
for (; __first1 != __last1 && __first2 != __last2 && __pred(*__first1, *__first2); ++__first1, ++__first2)
......@@ -3586,7 +3499,6 @@ __pattern_mismatch(_ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardItera
return __internal::__brick_mismatch(__first1, __last1, __first2, __last2, __pred, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _Predicate,
class _IsVector>
std::pair<_RandomAccessIterator1, _RandomAccessIterator2>
......@@ -3599,15 +3511,14 @@ __pattern_mismatch(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _
auto __result = __internal::__parallel_find(
std::forward<_ExecutionPolicy>(__exec), __first1, __first1 + __n,
[__first1, __first2, __pred, __is_vector](_RandomAccessIterator1 __i, _RandomAccessIterator1 __j) {
return __internal::__brick_mismatch(__i, __j, __first2 + (__i - __first1), __first2 + (__j - __first1), __pred,
__is_vector)
return __internal::__brick_mismatch(__i, __j, __first2 + (__i - __first1), __first2 + (__j - __first1),
__pred, __is_vector)
.first;
},
std::less<typename std::iterator_traits<_RandomAccessIterator1>::difference_type>(), /*is_first=*/true);
return std::make_pair(__result, __first2 + (__result - __first1));
});
}
#endif
//------------------------------------------------------------------------
// lexicographical_compare
......@@ -3667,7 +3578,6 @@ __pattern_lexicographical_compare(_ExecutionPolicy&&, _ForwardIterator1 __first1
return __internal::__brick_lexicographical_compare(__first1, __last1, __first2, __last2, __comp, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _Compare, class _IsVector>
bool
__pattern_lexicographical_compare(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
......@@ -3693,10 +3603,10 @@ __pattern_lexicographical_compare(_ExecutionPolicy&& __exec, _ForwardIterator1 _
std::forward<_ExecutionPolicy>(__exec), __first1, __first1 + __n,
[__first1, __first2, &__comp, __is_vector](_ForwardIterator1 __i, _ForwardIterator1 __j) {
return __internal::__brick_mismatch(__i, __j, __first2 + (__i - __first1), __first2 + (__j - __first1),
[&__comp](const _RefType1 __x, const _RefType2 __y) {
return !__comp(__x, __y) && !__comp(__y, __x);
},
__is_vector)
[&__comp](const _RefType1 __x, const _RefType2 __y) {
return !__comp(__x, __y) && !__comp(__y, __x);
},
__is_vector)
.first;
},
std::less<typename std::iterator_traits<_ForwardIterator1>::difference_type>(), /*is_first=*/true);
......@@ -3711,9 +3621,8 @@ __pattern_lexicographical_compare(_ExecutionPolicy&& __exec, _ForwardIterator1 _
}
}
}
#endif
} // namespace __internal
} // namespace __pstl
#endif /* __PSTL_algorithm_impl_H */
#endif /* _PSTL_ALGORITHM_IMPL_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_execution_policy_defs_H
#define __PSTL_execution_policy_defs_H
#ifndef _PSTL_EXECUTION_POLICY_DEFS_H
#define _PSTL_EXECUTION_POLICY_DEFS_H
#include <type_traits>
......@@ -41,7 +41,6 @@ class sequenced_policy
}
};
#if __PSTL_USE_PAR_POLICIES
// 2.5, Parallel execution policy
class parallel_policy
{
......@@ -85,7 +84,6 @@ class parallel_unsequenced_policy
return std::true_type{};
}
};
#endif
class unsequenced_policy
{
......@@ -110,10 +108,8 @@ class unsequenced_policy
// 2.8, Execution policy objects
constexpr sequenced_policy seq{};
#if __PSTL_USE_PAR_POLICIES
constexpr parallel_policy par{};
constexpr parallel_unsequenced_policy par_unseq{};
#endif
constexpr unsequenced_policy unseq{};
// 2.3, Execution policy type trait
......@@ -126,7 +122,6 @@ template <>
struct is_execution_policy<__pstl::execution::sequenced_policy> : std::true_type
{
};
#if __PSTL_USE_PAR_POLICIES
template <>
struct is_execution_policy<__pstl::execution::parallel_policy> : std::true_type
{
......@@ -135,13 +130,12 @@ template <>
struct is_execution_policy<__pstl::execution::parallel_unsequenced_policy> : std::true_type
{
};
#endif
template <>
struct is_execution_policy<__pstl::execution::unsequenced_policy> : std::true_type
{
};
#if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
#if _PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
template <class _Tp>
constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy<_Tp>::value;
#endif
......@@ -165,4 +159,4 @@ using __enable_if_execution_policy =
} // namespace __pstl
#endif /* __PSTL_execution_policy_defs_H */
#endif /* _PSTL_EXECUTION_POLICY_DEFS_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_execution_impl_H
#define __PSTL_execution_impl_H
#ifndef _PSTL_EXECUTION_IMPL_H
#define _PSTL_EXECUTION_IMPL_H
#include <iterator>
#include <type_traits>
......@@ -54,8 +54,8 @@ __lazy_or(_Tp __a, std::false_type)
template <typename _IteratorType, typename... _OtherIteratorTypes>
struct __is_random_access_iterator
{
static constexpr bool value =
__internal::__is_random_access_iterator<_IteratorType>::value && __internal::__is_random_access_iterator<_OtherIteratorTypes...>::value;
static constexpr bool value = __internal::__is_random_access_iterator<_IteratorType>::value &&
__internal::__is_random_access_iterator<_OtherIteratorTypes...>::value;
typedef std::integral_constant<bool, value> type;
};
......@@ -87,7 +87,6 @@ struct __policy_traits<unsequenced_policy>
typedef std::true_type allow_vector;
};
#if __PSTL_USE_PAR_POLICIES
template <>
struct __policy_traits<parallel_policy>
{
......@@ -103,53 +102,60 @@ struct __policy_traits<parallel_unsequenced_policy>
typedef std::true_type allow_unsequenced;
typedef std::true_type allow_vector;
};
#endif
template <typename _ExecutionPolicy>
using __collector_t = typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__collector_type;
using __collector_t =
typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__collector_type;
template <typename _ExecutionPolicy>
using __allow_vector = typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_vector;
using __allow_vector =
typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_vector;
template <typename _ExecutionPolicy>
using __allow_unsequenced = typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_unsequenced;
using __allow_unsequenced =
typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_unsequenced;
template <typename _ExecutionPolicy>
using __allow_parallel = typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_parallel;
using __allow_parallel =
typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_parallel;
template <typename _ExecutionPolicy, typename... _IteratorTypes>
auto
__is_vectorization_preferred(_ExecutionPolicy&& __exec)
-> decltype(__internal::__lazy_and(__exec.__allow_vector(), typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()))
-> decltype(__internal::__lazy_and(__exec.__allow_vector(),
typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()))
{
return __internal::__lazy_and(__exec.__allow_vector(), typename __internal::__is_random_access_iterator<_IteratorTypes...>::type());
return __internal::__lazy_and(__exec.__allow_vector(),
typename __internal::__is_random_access_iterator<_IteratorTypes...>::type());
}
template <typename _ExecutionPolicy, typename... _IteratorTypes>
auto
__is_parallelization_preferred(_ExecutionPolicy&& __exec)
-> decltype(__internal::__lazy_and(__exec.__allow_parallel(), typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()))
-> decltype(__internal::__lazy_and(__exec.__allow_parallel(),
typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()))
{
return __internal::__lazy_and(__exec.__allow_parallel(), typename __internal::__is_random_access_iterator<_IteratorTypes...>::type());
return __internal::__lazy_and(__exec.__allow_parallel(),
typename __internal::__is_random_access_iterator<_IteratorTypes...>::type());
}
template <typename policy, typename... _IteratorTypes>
struct __prefer_unsequenced_tag
{
static constexpr bool value =
__internal::__allow_unsequenced<policy>::value && __internal::__is_random_access_iterator<_IteratorTypes...>::value;
static constexpr bool value = __internal::__allow_unsequenced<policy>::value &&
__internal::__is_random_access_iterator<_IteratorTypes...>::value;
typedef std::integral_constant<bool, value> type;
};
template <typename policy, typename... _IteratorTypes>
struct __prefer_parallel_tag
{
static constexpr bool value =
__internal::__allow_parallel<policy>::value && __internal::__is_random_access_iterator<_IteratorTypes...>::value;
static constexpr bool value = __internal::__allow_parallel<policy>::value &&
__internal::__is_random_access_iterator<_IteratorTypes...>::value;
typedef std::integral_constant<bool, value> type;
};
} // namespace __internal
} // namespace __pstl
#endif /* __PSTL_execution_impl_H */
#endif /* _PSTL_EXECUTION_IMPL_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_glue_algorithm_defs_H
#define __PSTL_glue_algorithm_defs_H
#ifndef _PSTL_GLUE_ALGORITHM_DEFS_H
#define _PSTL_GLUE_ALGORITHM_DEFS_H
#include <functional>
......@@ -548,4 +548,4 @@ lexicographical_compare(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _
_ForwardIterator2 __first2, _ForwardIterator2 __last2);
} // namespace std
#endif /* __PSTL_glue_algorithm_defs_H */
#endif /* _PSTL_GLUE_ALGORITHM_DEFS_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_glue_algorithm_impl_H
#define __PSTL_glue_algorithm_impl_H
#ifndef _PSTL_GLUE_ALGORITHM_IMPL_H
#define _PSTL_GLUE_ALGORITHM_IMPL_H
#include <functional>
......@@ -745,11 +745,11 @@ __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, bool>
equal(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _BinaryPredicate __p)
{
//TODO: to get rid of "distance"
if (std::distance(__first1, __last1) == std::distance(__first2, __last2))
return std::equal(__first1, __last1, __first2, __p);
else
return false;
using namespace __pstl;
return __internal::__pattern_equal(
std::forward<_ExecutionPolicy>(__exec), __first1, __last1, __first2, __last2, __p,
__internal::__is_vectorization_preferred<_ExecutionPolicy, _ForwardIterator1>(__exec),
__internal::__is_parallelization_preferred<_ExecutionPolicy, _ForwardIterator1>(__exec));
}
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2>
......@@ -1179,4 +1179,4 @@ lexicographical_compare(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _
} // namespace std
#endif /* __PSTL_glue_algorithm_impl_H */
#endif /* _PSTL_GLUE_ALGORITHM_IMPL_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_glue_execution_defs_H
#define __PSTL_glue_execution_defs_H
#ifndef _PSTL_GLUE_EXECUTION_DEFS_H
#define _PSTL_GLUE_EXECUTION_DEFS_H
#include <type_traits>
......@@ -18,29 +18,27 @@ namespace std
{
// Type trait
using __pstl::execution::is_execution_policy;
#if __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
#if __INTEL_COMPILER
#if _PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT
# if __INTEL_COMPILER
template <class T>
constexpr bool is_execution_policy_v = is_execution_policy<T>::value;
#else
# else
using __pstl::execution::is_execution_policy_v;
#endif
# endif
#endif
namespace execution
{
// Standard C++ policy classes
using __pstl::execution::sequenced_policy;
#if __PSTL_USE_PAR_POLICIES
using __pstl::execution::parallel_policy;
using __pstl::execution::parallel_unsequenced_policy;
#endif
using __pstl::execution::sequenced_policy;
// Standard predefined policy instances
using __pstl::execution::seq;
#if __PSTL_USE_PAR_POLICIES
using __pstl::execution::par;
using __pstl::execution::par_unseq;
#endif
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
......@@ -53,4 +51,4 @@ using __pstl::execution::unsequenced_policy;
#include "numeric_impl.h"
#include "parallel_backend.h"
#endif /* __PSTL_glue_execution_defs_H */
#endif /* _PSTL_GLUE_EXECUTION_DEFS_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_glue_memory_defs_H
#define __PSTL_glue_memory_defs_H
#ifndef _PSTL_GLUE_MEMORY_DEFS_H
#define _PSTL_GLUE_MEMORY_DEFS_H
#include "execution_defs.h"
......@@ -76,4 +76,4 @@ __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardItera
uninitialized_value_construct_n(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Size __n);
} // namespace std
#endif /* __PSTL_glue_memory_defs_H */
#endif /* _PSTL_GLUE_MEMORY_DEFS_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_glue_memory_impl_H
#define __PSTL_glue_memory_impl_H
#ifndef _PSTL_GLUE_MEMORY_IMPL_H
#define _PSTL_GLUE_MEMORY_IMPL_H
#include "utils.h"
#include "algorithm_fwd.h"
......@@ -355,4 +355,4 @@ uninitialized_value_construct_n(_ExecutionPolicy&& __exec, _ForwardIterator __fi
} // namespace std
#endif /* __PSTL_glue_memory_imple_H */
#endif /* _PSTL_GLUE_MEMORY_IMPL_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_glue_numeric_defs_H
#define __PSTL_glue_numeric_defs_H
#ifndef _PSTL_GLUE_NUMERIC_DEFS_H
#define _PSTL_GLUE_NUMERIC_DEFS_H
#include "execution_defs.h"
......@@ -113,4 +113,4 @@ adjacent_difference(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _Forwa
_ForwardIterator2 __d_first);
} // namespace std
#endif /* __PSTL_glue_numeric_defs_H */
#endif /* _PSTL_GLUE_NUMERIC_DEFS_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_glue_numeric_impl_H
#define __PSTL_glue_numeric_impl_H
#ifndef _PSTL_GLUE_NUMERIC_IMPL_H
#define _PSTL_GLUE_NUMERIC_IMPL_H
#include <functional>
......@@ -221,4 +221,4 @@ adjacent_difference(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _Forwa
} // namespace std
#endif /* __PSTL_glue_numeric_impl_H_ */
#endif /* _PSTL_GLUE_NUMERIC_IMPL_H_ */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_memory_impl_H
#define __PSTL_memory_impl_H
#ifndef _PSTL_MEMORY_IMPL_H
#define _PSTL_MEMORY_IMPL_H
#include <iterator>
......@@ -53,4 +53,4 @@ __brick_uninitialized_move(_ForwardIterator __first, _ForwardIterator __last, _O
} // namespace __internal
} // namespace __pstl
#endif /* __PSTL_memory_impl_H */
#endif /* _PSTL_MEMORY_IMPL_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_numeric_fwd_H
#define __PSTL_numeric_fwd_H
#ifndef _PSTL_NUMERIC_FWD_H
#define _PSTL_NUMERIC_FWD_H
#include <type_traits>
#include <utility>
......@@ -39,14 +39,12 @@ __pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterat
_BinaryOperation1, _BinaryOperation2, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _Tp,
class _BinaryOperation1, class _BinaryOperation2, class _IsVector>
_Tp
__pattern_transform_reduce(_ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2,
_Tp, _BinaryOperation1, _BinaryOperation2, _IsVector __is_vector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// transform_reduce (version with unary and binary functions)
......@@ -67,14 +65,12 @@ __pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterato
_UnaryOperation, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation,
class _IsVector>
_Tp
__pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Tp, _BinaryOperation,
_UnaryOperation, _IsVector,
/*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// transform_exclusive_scan
......@@ -99,21 +95,17 @@ __pattern_transform_scan(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator,
_BinaryOperation, _Inclusive, _IsVector,
/*is_parallel=*/std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp,
class _BinaryOperation, class _Inclusive, class _IsVector>
typename std::enable_if<!std::is_floating_point<_Tp>::value, _OutputIterator>::type
__pattern_transform_scan(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator,
_UnaryOperation, _Tp, _BinaryOperation, _Inclusive, _IsVector, /*is_parallel=*/std::true_type);
#endif
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp,
class _BinaryOperation, class _Inclusive, class _IsVector>
typename std::enable_if<std::is_floating_point<_Tp>::value, _OutputIterator>::type
__pattern_transform_scan(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _OutputIterator,
_UnaryOperation, _Tp, _BinaryOperation, _Inclusive, _IsVector, /*is_parallel=*/std::true_type);
#endif
//------------------------------------------------------------------------
// adjacent_difference
......@@ -133,14 +125,12 @@ _OutputIterator
__pattern_adjacent_difference(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation,
_IsVector, /*is_parallel*/ std::false_type) noexcept;
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _BinaryOperation,
class _IsVector>
_OutputIterator
__pattern_adjacent_difference(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _OutputIterator, _BinaryOperation,
_IsVector, /*is_parallel*/ std::true_type);
#endif
} // namespace __internal
} // namespace __pstl
#endif /* __PSTL_numeric_fwd_H */
#endif /* _PSTL_NUMERIC_FWD_H */
......@@ -7,21 +7,19 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_numeric_impl_H
#define __PSTL_numeric_impl_H
#ifndef _PSTL_NUMERIC_IMPL_H
#define _PSTL_NUMERIC_IMPL_H
#include <iterator>
#include <type_traits>
#include <numeric>
#include "parallel_backend.h"
#include "pstl_config.h"
#include "execution_impl.h"
#include "unseq_backend_simd.h"
#include "algorithm_fwd.h"
#if __PSTL_USE_PAR_POLICIES
#include "parallel_backend.h"
#endif
namespace __pstl
{
namespace __internal
......@@ -63,7 +61,6 @@ __pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator1 __first1, _Forw
return __brick_transform_reduce(__first1, __last1, __first2, __init, __binary_op1, __binary_op2, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2, class _Tp,
class _BinaryOperation1, class _BinaryOperation2, class _IsVector>
_Tp
......@@ -82,11 +79,10 @@ __pattern_transform_reduce(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __f
[__first1, __first2, __binary_op1, __binary_op2,
__is_vector](_RandomAccessIterator1 __i, _RandomAccessIterator1 __j, _Tp __init) -> _Tp {
return __internal::__brick_transform_reduce(__i, __j, __first2 + (__i - __first1), __init, __binary_op1,
__binary_op2, __is_vector);
__binary_op2, __is_vector);
});
});
}
#endif
//------------------------------------------------------------------------
// transform_reduce (version with unary and binary functions)
......@@ -125,7 +121,6 @@ __pattern_transform_reduce(_ExecutionPolicy&&, _ForwardIterator __first, _Forwar
return __internal::__brick_transform_reduce(__first, __last, __init, __binary_op, __unary_op, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation,
class _IsVector>
_Tp
......@@ -142,7 +137,6 @@ __pattern_transform_reduce(_ExecutionPolicy&& __exec, _ForwardIterator __first,
});
});
}
#endif
//------------------------------------------------------------------------
// transform_exclusive_scan
......@@ -160,7 +154,7 @@ __brick_transform_scan(_ForwardIterator __first, _ForwardIterator __last, _Outpu
for (; __first != __last; ++__first, ++__result)
{
*__result = __init;
__PSTL_PRAGMA_FORCEINLINE
_PSTL_PRAGMA_FORCEINLINE
__init = __binary_op(__init, __unary_op(*__first));
}
return std::make_pair(__result, __init);
......@@ -175,7 +169,7 @@ __brick_transform_scan(_ForwardIterator __first, _ForwardIterator __last, _Outpu
{
for (; __first != __last; ++__first, ++__result)
{
__PSTL_PRAGMA_FORCEINLINE
_PSTL_PRAGMA_FORCEINLINE
__init = __binary_op(__init, __unary_op(*__first));
*__result = __init;
}
......@@ -196,13 +190,13 @@ __brick_transform_scan(_ForwardIterator __first, _ForwardIterator __last, _Outpu
_UnaryOperation __unary_op, _Tp __init, _BinaryOperation __binary_op, _Inclusive,
/*is_vector=*/std::true_type) noexcept
{
#if (__PSTL_UDS_PRESENT)
#if (_PSTL_UDS_PRESENT)
return __unseq_backend::__simd_scan(__first, __last - __first, __result, __unary_op, __init, __binary_op,
_Inclusive());
#else
// We need to call serial brick here to call function for inclusive and exclusive scan that depends on _Inclusive() value
return __internal::__brick_transform_scan(__first, __last, __result, __unary_op, __init, __binary_op, _Inclusive(),
/*is_vector=*/std::false_type());
/*is_vector=*/std::false_type());
#endif
}
......@@ -214,7 +208,7 @@ __brick_transform_scan(_ForwardIterator __first, _ForwardIterator __last, _Outpu
/*is_vector=*/std::true_type) noexcept
{
return __internal::__brick_transform_scan(__first, __last, __result, __unary_op, __init, __binary_op, _Inclusive(),
/*is_vector=*/std::false_type());
/*is_vector=*/std::false_type());
}
template <class _ExecutionPolicy, class _ForwardIterator, class _OutputIterator, class _UnaryOperation, class _Tp,
......@@ -224,11 +218,11 @@ __pattern_transform_scan(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardI
_OutputIterator __result, _UnaryOperation __unary_op, _Tp __init, _BinaryOperation __binary_op,
_Inclusive, _IsVector __is_vector, /*is_parallel=*/std::false_type) noexcept
{
return __internal::__brick_transform_scan(__first, __last, __result, __unary_op, __init, __binary_op, _Inclusive(), __is_vector)
return __internal::__brick_transform_scan(__first, __last, __result, __unary_op, __init, __binary_op, _Inclusive(),
__is_vector)
.first;
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp,
class _BinaryOperation, class _Inclusive, class _IsVector>
typename std::enable_if<!std::is_floating_point<_Tp>::value, _OutputIterator>::type
......@@ -245,21 +239,20 @@ __pattern_transform_scan(_ExecutionPolicy&& __exec, _RandomAccessIterator __firs
__binary_op,
[__first, __unary_op, __binary_op](_DifferenceType __i, _DifferenceType __j, _Tp __init) {
// Execute serial __brick_transform_reduce, due to the explicit SIMD vectorization (reduction) requires a commutative operation for the guarantee of correct scan.
return __internal::__brick_transform_reduce(__first + __i, __first + __j, __init, __binary_op, __unary_op,
/*__is_vector*/ std::false_type());
return __internal::__brick_transform_reduce(__first + __i, __first + __j, __init, __binary_op,
__unary_op,
/*__is_vector*/ std::false_type());
},
[__first, __unary_op, __binary_op, __result, __is_vector](_DifferenceType __i, _DifferenceType __j,
_Tp __init) {
return __internal::__brick_transform_scan(__first + __i, __first + __j, __result + __i, __unary_op, __init,
__binary_op, _Inclusive(), __is_vector)
return __internal::__brick_transform_scan(__first + __i, __first + __j, __result + __i, __unary_op,
__init, __binary_op, _Inclusive(), __is_vector)
.second;
});
return __result + (__last - __first);
});
}
#endif
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _RandomAccessIterator, class _OutputIterator, class _UnaryOperation, class _Tp,
class _BinaryOperation, class _Inclusive, class _IsVector>
typename std::enable_if<std::is_floating_point<_Tp>::value, _OutputIterator>::type
......@@ -278,15 +271,15 @@ __pattern_transform_scan(_ExecutionPolicy&& __exec, _RandomAccessIterator __firs
__par_backend::__parallel_strict_scan(
std::forward<_ExecutionPolicy>(__exec), __n, __init,
[__first, __unary_op, __binary_op, __result, __is_vector](_DifferenceType __i, _DifferenceType __len) {
return __internal::__brick_transform_scan(__first + __i, __first + (__i + __len), __result + __i, __unary_op, _Tp{},
__binary_op, _Inclusive(), __is_vector)
return __internal::__brick_transform_scan(__first + __i, __first + (__i + __len), __result + __i,
__unary_op, _Tp{}, __binary_op, _Inclusive(), __is_vector)
.second;
},
__binary_op,
[__result, &__binary_op](_DifferenceType __i, _DifferenceType __len, _Tp __initial) {
return *(std::transform(__result + __i, __result + __i + __len, __result + __i,
[&__initial, &__binary_op](const _Tp& __x) {
__PSTL_PRAGMA_FORCEINLINE
_PSTL_PRAGMA_FORCEINLINE
return __binary_op(__initial, __x);
}) -
1);
......@@ -295,7 +288,6 @@ __pattern_transform_scan(_ExecutionPolicy&& __exec, _RandomAccessIterator __firs
return __result + (__last - __first);
});
}
#endif
//------------------------------------------------------------------------
// adjacent_difference
......@@ -314,7 +306,7 @@ _ForwardIterator2
__brick_adjacent_difference(_ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first,
BinaryOperation __op, /*is_vector=*/std::true_type) noexcept
{
__PSTL_ASSERT(__first != __last);
_PSTL_ASSERT(__first != __last);
typedef typename std::iterator_traits<_ForwardIterator1>::reference _ReferenceType1;
typedef typename std::iterator_traits<_ForwardIterator2>::reference _ReferenceType2;
......@@ -336,7 +328,6 @@ __pattern_adjacent_difference(_ExecutionPolicy&&, _ForwardIterator __first, _For
return __internal::__brick_adjacent_difference(__first, __last, __d_first, __op, __is_vector);
}
#if __PSTL_USE_PAR_POLICIES
template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryOperation,
class _IsVector>
_ForwardIterator2
......@@ -344,7 +335,7 @@ __pattern_adjacent_difference(_ExecutionPolicy&& __exec, _ForwardIterator1 __fir
_ForwardIterator2 __d_first, _BinaryOperation __op, _IsVector __is_vector,
/*is_parallel=*/std::true_type)
{
__PSTL_ASSERT(__first != __last);
_PSTL_ASSERT(__first != __last);
typedef typename std::iterator_traits<_ForwardIterator1>::reference _ReferenceType1;
typedef typename std::iterator_traits<_ForwardIterator2>::reference _ReferenceType2;
......@@ -360,9 +351,8 @@ __pattern_adjacent_difference(_ExecutionPolicy&& __exec, _ForwardIterator1 __fir
});
return __d_first + (__last - __first);
}
#endif
} // namespace __internal
} // namespace __pstl
#endif /* __PSTL_numeric_impl_H */
#endif /* _PSTL_NUMERIC_IMPL_H */
......@@ -7,13 +7,15 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_parallel_backend_H
#define __PSTL_parallel_backend_H
#ifndef _PSTL_PARALLEL_BACKEND_H
#define _PSTL_PARALLEL_BACKEND_H
#if __PSTL_PAR_BACKEND_TBB
#include "parallel_backend_tbb.h"
#if defined(_PSTL_PAR_BACKEND_SERIAL)
# include "parallel_backend_serial.h"
#elif defined(_PSTL_PAR_BACKEND_TBB)
# include "parallel_backend_tbb.h"
#else
__PSTL_PRAGMA_MESSAGE("Parallel backend was not specified");
_PSTL_PRAGMA_MESSAGE("Parallel backend was not specified");
#endif
#endif /* __PSTL_parallel_backend_H */
#endif /* _PSTL_PARALLEL_BACKEND_H */
// -*- C++ -*-
//===-- parallel_backend_serial.h -----------------------------------------===//
//
// 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_PARALLEL_BACKEND_SERIAL_H
#define _PSTL_PARALLEL_BACKEND_SERIAL_H
#include <algorithm>
#include <cstddef>
#include <memory>
#include <numeric>
#include <utility>
namespace __pstl
{
namespace __serial
{
template <typename _Tp>
class __buffer
{
std::allocator<_Tp> __allocator_;
_Tp* __ptr_;
const std::size_t __buf_size_;
__buffer(const __buffer&) = delete;
void
operator=(const __buffer&) = delete;
public:
__buffer(std::size_t __n) : __allocator_(), __ptr_(__allocator_.allocate(__n)), __buf_size_(__n) {}
operator bool() const { return __ptr_ != nullptr; }
_Tp*
get() const
{
return __ptr_;
}
~__buffer() { __allocator_.deallocate(__ptr_, __buf_size_); }
};
inline void
__cancel_execution()
{
}
template <class _ExecutionPolicy, class _Index, class _Fp>
void
__parallel_for(_ExecutionPolicy&&, _Index __first, _Index __last, _Fp __f)
{
__f(__first, __last);
}
template <class _ExecutionPolicy, class _Value, class _Index, typename _RealBody, typename _Reduction>
_Value
__parallel_reduce(_ExecutionPolicy&&, _Index __first, _Index __last, const _Value& __identity,
const _RealBody& __real_body, const _Reduction&)
{
if (__first == __last)
{
return __identity;
}
else
{
return __real_body(__first, __last, __identity);
}
}
template <class _ExecutionPolicy, class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
_Tp
__parallel_transform_reduce(_ExecutionPolicy&&, _Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp,
_Reduce __reduce)
{
return __reduce(__first, __last, __init);
}
template <class _ExecutionPolicy, typename _Index, typename _Tp, typename _Rp, typename _Cp, typename _Sp, typename _Ap>
void
__parallel_strict_scan(_ExecutionPolicy&&, _Index __n, _Tp __initial, _Rp __reduce, _Cp __combine, _Sp __scan,
_Ap __apex)
{
_Tp __sum = __initial;
if (__n)
__sum = __combine(__sum, __reduce(_Index(0), __n));
__apex(__sum);
if (__n)
__scan(_Index(0), __n, __initial);
}
template <class _ExecutionPolicy, class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce, class _Scan>
_Tp
__parallel_transform_scan(_ExecutionPolicy&&, _Index __n, _UnaryOp, _Tp __init, _BinaryOp, _Reduce, _Scan __scan)
{
return __scan(_Index(0), __n, __init);
}
template <class _ExecutionPolicy, typename _RandomAccessIterator, typename _Compare, typename _LeafSort>
void
__parallel_stable_sort(_ExecutionPolicy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
_LeafSort __leaf_sort, std::size_t = 0)
{
__leaf_sort(__first, __last, __comp);
}
template <class _ExecutionPolicy, typename _RandomAccessIterator1, typename _RandomAccessIterator2,
typename _RandomAccessIterator3, typename _Compare, typename _LeafMerge>
void
__parallel_merge(_ExecutionPolicy&&, _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _RandomAccessIterator3 __out,
_Compare __comp, _LeafMerge __leaf_merge)
{
__leaf_merge(__first1, __last1, __first2, __last2, __out, __comp);
}
template <class _ExecutionPolicy, typename _F1, typename _F2>
void
__parallel_invoke(_ExecutionPolicy&&, _F1&& __f1, _F2&& __f2)
{
std::forward<_F1>(__f1)();
std::forward<_F2>(__f2)();
}
} // namespace __serial
} // namespace __pstl
namespace __pstl
{
namespace __par_backend
{
using namespace __pstl::__serial;
}
} // namespace __pstl
#endif /* _PSTL_PARALLEL_BACKEND_SERIAL_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_parallel_backend_tbb_H
#define __PSTL_parallel_backend_tbb_H
#ifndef _PSTL_PARALLEL_BACKEND_TBB_H
#define _PSTL_PARALLEL_BACKEND_TBB_H
#include <algorithm>
#include <type_traits>
......@@ -25,7 +25,7 @@
#include <tbb/tbb_allocator.h>
#if TBB_INTERFACE_VERSION < 10000
#error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
# error Intel(R) Threading Building Blocks 2018 is required; older versions are not supported.
#endif
namespace __pstl
......@@ -138,7 +138,7 @@ struct __par_trans_red_body
_Tp&
sum()
{
__PSTL_ASSERT_MSG(_M_has_sum, "sum expected");
_PSTL_ASSERT_MSG(_M_has_sum, "sum expected");
return *(_Tp*)_M_sum_storage;
}
__par_trans_red_body(_Up __u, _Tp __init, _Cp __c, _Rp __r)
......@@ -172,7 +172,7 @@ struct __par_trans_red_body
_Index __j = __range.end();
if (!_M_has_sum)
{
__PSTL_ASSERT_MSG(__range.size() > 1, "there should be at least 2 elements");
_PSTL_ASSERT_MSG(__range.size() > 1, "there should be at least 2 elements");
new (&_M_sum_storage)
_Tp(_M_combine(_M_u(__i), _M_u(__i + 1))); // The condition i+1 < j is provided by the grain size of 3
_M_has_sum = true;
......@@ -232,7 +232,7 @@ class __trans_scan_body
_Tp&
sum() const
{
__PSTL_ASSERT_MSG(_M_has_sum, "sum expected");
_PSTL_ASSERT_MSG(_M_has_sum, "sum expected");
return *const_cast<_Tp*>(reinterpret_cast<_Tp const*>(_M_sum_storage));
}
......@@ -303,8 +303,10 @@ __upsweep(_Index __i, _Index __m, _Index __tilesize, _Tp* __r, _Index __lastsize
{
_Index __k = __split(__m);
tbb::parallel_invoke(
[=] { __par_backend::__upsweep(__i, __k, __tilesize, __r, __tilesize, __reduce, __combine); },
[=] { __par_backend::__upsweep(__i + __k, __m - __k, __tilesize, __r + __k, __lastsize, __reduce, __combine); });
[=] { __par_backend::__upsweep(__i, __k, __tilesize, __r, __tilesize, __reduce, __combine); },
[=] {
__par_backend::__upsweep(__i + __k, __m - __k, __tilesize, __r + __k, __lastsize, __reduce, __combine);
});
if (__m == 2 * __k)
__r[__m - 1] = __combine(__r[__k - 1], __r[__m - 1]);
}
......@@ -320,13 +322,14 @@ __downsweep(_Index __i, _Index __m, _Index __tilesize, _Tp* __r, _Index __lastsi
else
{
const _Index __k = __split(__m);
tbb::parallel_invoke([=] { __par_backend::__downsweep(__i, __k, __tilesize, __r, __tilesize, __initial, __combine, __scan); },
// Assumes that __combine never throws.
//TODO: Consider adding a requirement for user functors to be constant.
[=, &__combine] {
__par_backend::__downsweep(__i + __k, __m - __k, __tilesize, __r + __k, __lastsize,
__combine(__initial, __r[__k - 1]), __combine, __scan);
});
tbb::parallel_invoke(
[=] { __par_backend::__downsweep(__i, __k, __tilesize, __r, __tilesize, __initial, __combine, __scan); },
// Assumes that __combine never throws.
//TODO: Consider adding a requirement for user functors to be constant.
[=, &__combine] {
__par_backend::__downsweep(__i + __k, __m - __k, __tilesize, __r + __k, __lastsize,
__combine(__initial, __r[__k - 1]), __combine, __scan);
});
}
}
......@@ -358,7 +361,8 @@ __parallel_strict_scan(_ExecutionPolicy&&, _Index __n, _Tp __initial, _Rp __redu
_Index __m = (__n - 1) / __tilesize;
__buffer<_Tp> __buf(__m + 1);
_Tp* __r = __buf.get();
__par_backend::__upsweep(_Index(0), _Index(__m + 1), __tilesize, __r, __n - __m * __tilesize, __reduce, __combine);
__par_backend::__upsweep(_Index(0), _Index(__m + 1), __tilesize, __r, __n - __m * __tilesize, __reduce,
__combine);
// When __apex is a no-op and __combine has no side effects, a good optimizer
// should be able to eliminate all code between here and __apex.
......@@ -369,8 +373,8 @@ __parallel_strict_scan(_ExecutionPolicy&&, _Index __n, _Tp __initial, _Rp __redu
while ((__k &= __k - 1))
__t = __combine(__r[__k - 1], __t);
__apex(__combine(__initial, __t));
__par_backend::__downsweep(_Index(0), _Index(__m + 1), __tilesize, __r, __n - __m * __tilesize, __initial, __combine,
__scan);
__par_backend::__downsweep(_Index(0), _Index(__m + 1), __tilesize, __r, __n - __m * __tilesize, __initial,
__combine, __scan);
return;
}
// Fewer than 2 elements in sequence, or out of memory. Handle has single block.
......@@ -427,7 +431,7 @@ class __merge_task : public tbb::task
}
};
#define __PSTL_MERGE_CUT_OFF 2000
#define _PSTL_MERGE_CUT_OFF 2000
template <typename _RandomAccessIterator1, typename _RandomAccessIterator2, typename _RandomAccessIterator3,
typename __M_Compare, typename _Cleanup, typename _LeafMerge>
......@@ -439,7 +443,7 @@ __merge_task<_RandomAccessIterator1, _RandomAccessIterator2, _RandomAccessIterat
typedef typename std::iterator_traits<_RandomAccessIterator2>::difference_type _DifferenceType2;
typedef typename std::common_type<_DifferenceType1, _DifferenceType2>::type _SizeType;
const _SizeType __n = (_M_xe - _M_xs) + (_M_ye - _M_ys);
const _SizeType __merge_cut_off = __PSTL_MERGE_CUT_OFF;
const _SizeType __merge_cut_off = _PSTL_MERGE_CUT_OFF;
if (__n <= __merge_cut_off)
{
_M_leaf_merge(_M_xs, _M_xe, _M_ys, _M_ye, _M_zs, _M_comp);
......@@ -504,13 +508,13 @@ class __stable_sort_task : public tbb::task
//! Binary operator that does nothing
struct __binary_no_op
{
template <typename _T>
void operator()(_T, _T)
template <typename _Tp>
void operator()(_Tp, _Tp)
{
}
};
#define __PSTL_STABLE_SORT_CUT_OFF 500
#define _PSTL_STABLE_SORT_CUT_OFF 500
template <typename _RandomAccessIterator1, typename _RandomAccessIterator2, typename _Compare, typename _LeafSort>
tbb::task*
......@@ -518,7 +522,7 @@ __stable_sort_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, _Le
{
const _SizeType __n = _M_xe - _M_xs;
const _SizeType __nmerge = _M_nsort > 0 ? _M_nsort : __n;
const _SizeType __sort_cut_off = __PSTL_STABLE_SORT_CUT_OFF;
const _SizeType __sort_cut_off = _PSTL_STABLE_SORT_CUT_OFF;
if (__n <= __sort_cut_off)
{
_M_leaf_sort(_M_xs, _M_xe, _M_comp);
......@@ -536,20 +540,21 @@ __stable_sort_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, _Le
auto __move_sequences = [](_RandomAccessIterator2 __first1, _RandomAccessIterator2 __last1,
_RandomAccessIterator1 __first2) { return std::move(__first1, __last1, __first2); };
if (_M_inplace == 2)
__m = new (tbb::task::allocate_continuation())
__m = new (tbb::task::allocate_continuation())
__merge_task<_RandomAccessIterator2, _RandomAccessIterator2, _RandomAccessIterator1, _Compare,
__serial_destroy,
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>>(
_M_zs, __zm, __zm, __ze, _M_xs, _M_comp, __serial_destroy(),
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>(__nmerge, __move_values,
__move_sequences));
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>(
__nmerge, __move_values, __move_sequences));
else if (_M_inplace)
__m = new (tbb::task::allocate_continuation())
__merge_task<_RandomAccessIterator2, _RandomAccessIterator2, _RandomAccessIterator1, _Compare,
__par_backend::__binary_no_op, __par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>>(
__par_backend::__binary_no_op,
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>>(
_M_zs, __zm, __zm, __ze, _M_xs, _M_comp, __par_backend::__binary_no_op(),
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>(__nmerge, __move_values,
__move_sequences));
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>(
__nmerge, __move_values, __move_sequences));
else
{
auto __move_values = [](_RandomAccessIterator1 __x, _RandomAccessIterator2 __z) { *__z = std::move(*__x); };
......@@ -559,16 +564,17 @@ __stable_sort_task<_RandomAccessIterator1, _RandomAccessIterator2, _Compare, _Le
};
__m = new (tbb::task::allocate_continuation())
__merge_task<_RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, _Compare,
__par_backend::__binary_no_op, __par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>>(
__par_backend::__binary_no_op,
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>>(
_M_xs, __xm, __xm, _M_xe, _M_zs, _M_comp, __par_backend::__binary_no_op(),
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>(__nmerge, __move_values,
__move_sequences));
__par_backend::__serial_move_merge<decltype(__move_values), decltype(__move_sequences)>(
__nmerge, __move_values, __move_sequences));
}
__m->set_ref_count(2);
task* __right = new (__m->allocate_child())
__stable_sort_task(__xm, _M_xe, __zm, !_M_inplace, _M_comp, _M_leaf_sort, __nmerge);
tbb::task::spawn(*__right);
tbb::task::recycle_as_child_of(*__m);
tbb::task::spawn(*__right);
tbb::task::recycle_as_child_of(*__m);
_M_xe = __xm;
_M_inplace = !_M_inplace;
}
......@@ -588,10 +594,10 @@ __parallel_stable_sort(_ExecutionPolicy&&, _RandomAccessIterator __xs, _RandomAc
if (__nsort == 0)
__nsort = __n;
const _DifferenceType __sort_cut_off = __PSTL_STABLE_SORT_CUT_OFF;
const _DifferenceType __sort_cut_off = _PSTL_STABLE_SORT_CUT_OFF;
if (__n > __sort_cut_off)
{
__PSTL_ASSERT(__nsort > 0 && __nsort <= __n);
_PSTL_ASSERT(__nsort > 0 && __nsort <= __n);
__buffer<_ValueType> __buf(__n);
using tbb::task;
task::spawn_root_and_wait(*new (task::allocate_root())
......@@ -619,7 +625,7 @@ __parallel_merge(_ExecutionPolicy&&, _RandomAccessIterator1 __xs, _RandomAccessI
typedef typename std::iterator_traits<_RandomAccessIterator2>::difference_type _DifferenceType2;
typedef typename std::common_type<_DifferenceType1, _DifferenceType2>::type _SizeType;
const _SizeType __n = (__xe - __xs) + (__ye - __ys);
const _SizeType __merge_cut_off = __PSTL_MERGE_CUT_OFF;
const _SizeType __merge_cut_off = _PSTL_MERGE_CUT_OFF;
if (__n <= __merge_cut_off)
{
// Fall back on serial merge
......@@ -651,4 +657,4 @@ __parallel_invoke(_ExecutionPolicy&&, _F1&& __f1, _F2&& __f2)
} // namespace __par_backend
} // namespace __pstl
#endif /* __PSTL_parallel_backend_tbb_H */
#endif /* _PSTL_PARALLEL_BACKEND_TBB_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_parallel_backend_utils_H
#define __PSTL_parallel_backend_utils_H
#ifndef _PSTL_PARALLEL_BACKEND_UTILS_H
#define _PSTL_PARALLEL_BACKEND_UTILS_H
#include <iterator>
#include <utility>
......@@ -53,7 +53,7 @@ struct __serial_move_merge
_RandomAccessIterator2 __ye, _RandomAccessIterator3 __zs, _Compare __comp)
{
auto __n = _M_nmerge;
__PSTL_ASSERT(__n > 0);
_PSTL_ASSERT(__n > 0);
if (__xs != __xe)
{
if (__ys != __ye)
......@@ -145,7 +145,7 @@ class __stack
~__stack()
{
__PSTL_ASSERT(size() <= _M_maxsize);
_PSTL_ASSERT(size() <= _M_maxsize);
while (!empty())
pop();
}
......@@ -158,20 +158,20 @@ class __stack
size_t
size() const
{
__PSTL_ASSERT(_M_ptr - _M_buf.get() <= _M_maxsize);
__PSTL_ASSERT(_M_ptr - _M_buf.get() >= 0);
_PSTL_ASSERT(_M_ptr - _M_buf.get() <= _M_maxsize);
_PSTL_ASSERT(_M_ptr - _M_buf.get() >= 0);
return _M_ptr - _M_buf.get();
}
bool
empty() const
{
__PSTL_ASSERT(_M_ptr >= _M_buf.get());
_PSTL_ASSERT(_M_ptr >= _M_buf.get());
return _M_ptr == _M_buf.get();
}
void
push(const _ValueType& __v)
{
__PSTL_ASSERT(size() < _M_maxsize);
_PSTL_ASSERT(size() < _M_maxsize);
new (_M_ptr) _ValueType(__v);
++_M_ptr;
}
......@@ -183,7 +183,7 @@ class __stack
void
pop()
{
__PSTL_ASSERT(_M_ptr > _M_buf.get());
_PSTL_ASSERT(_M_ptr > _M_buf.get());
--_M_ptr;
(*_M_ptr).~_ValueType();
}
......@@ -192,4 +192,4 @@ class __stack
} // namespace __par_backend
} // namespace __pstl
#endif /* __PSTL_parallel_backend_utils_H */
#endif /* _PSTL_PARALLEL_BACKEND_UTILS_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_parallel_impl_H
#define __PSTL_parallel_impl_H
#ifndef _PSTL_PARALLEL_IMPL_H
#define _PSTL_PARALLEL_IMPL_H
#include <atomic>
// This header defines the minimum set of parallel routines required to support Parallel STL,
......@@ -78,4 +78,4 @@ __parallel_or(_ExecutionPolicy&& __exec, _Index __first, _Index __last, _Brick _
} // namespace __internal
} // namespace __pstl
#endif /* __PSTL_parallel_impl_H */
#endif /* _PSTL_PARALLEL_IMPL_H */
......@@ -7,124 +7,113 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_config_H
#define __PSTL_config_H
#define PSTL_VERSION 203
#define PSTL_VERSION_MAJOR (PSTL_VERSION / 100)
#define PSTL_VERSION_MINOR (PSTL_VERSION - PSTL_VERSION_MAJOR * 100)
// Check the user-defined macro for parallel policies
#if defined(PSTL_USE_PARALLEL_POLICIES)
#undef __PSTL_USE_PAR_POLICIES
#define __PSTL_USE_PAR_POLICIES PSTL_USE_PARALLEL_POLICIES
// Check the internal macro for parallel policies
#elif !defined(__PSTL_USE_PAR_POLICIES)
#define __PSTL_USE_PAR_POLICIES 1
#endif
#ifndef _PSTL_CONFIG_H
#define _PSTL_CONFIG_H
#if __PSTL_USE_PAR_POLICIES
#if !defined(__PSTL_PAR_BACKEND_TBB)
#define __PSTL_PAR_BACKEND_TBB 1
#endif
#else
#undef __PSTL_PAR_BACKEND_TBB
// The version is XYYZ, where X is major, YY is minor, and Z is patch (i.e. X.YY.Z)
#define _PSTL_VERSION 9000
#define _PSTL_VERSION_MAJOR (_PSTL_VERSION / 1000)
#define _PSTL_VERSION_MINOR ((_PSTL_VERSION % 1000) / 10)
#define _PSTL_VERSION_PATCH (_PSTL_VERSION % 10)
#if !defined(_PSTL_PAR_BACKEND_SERIAL) && !defined(_PSTL_PAR_BACKEND_TBB)
# error "The parallel backend is neither serial nor TBB"
#endif
// Check the user-defined macro for warnings
#if defined(PSTL_USAGE_WARNINGS)
#undef __PSTL_USAGE_WARNINGS
#define __PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
# undef _PSTL_USAGE_WARNINGS
# define _PSTL_USAGE_WARNINGS PSTL_USAGE_WARNINGS
// Check the internal macro for warnings
#elif !defined(__PSTL_USAGE_WARNINGS)
#define __PSTL_USAGE_WARNINGS 0
#elif !defined(_PSTL_USAGE_WARNINGS)
# define _PSTL_USAGE_WARNINGS 0
#endif
// Portability "#pragma" definition
#ifdef _MSC_VER
#define __PSTL_PRAGMA(x) __pragma(x)
# define _PSTL_PRAGMA(x) __pragma(x)
#else
#define __PSTL_PRAGMA(x) _Pragma(#x)
# define _PSTL_PRAGMA(x) _Pragma(# x)
#endif
#define __PSTL_STRING_AUX(x) #x
#define __PSTL_STRING(x) __PSTL_STRING_AUX(x)
#define __PSTL_STRING_CONCAT(x, y) x #y
#define _PSTL_STRING_AUX(x) #x
#define _PSTL_STRING(x) _PSTL_STRING_AUX(x)
#define _PSTL_STRING_CONCAT(x, y) x #y
// note that when ICC or Clang is in use, __PSTL_GCC_VERSION might not fully match
// note that when ICC or Clang is in use, _PSTL_GCC_VERSION might not fully match
// the actual GCC version on the system.
#define __PSTL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#define _PSTL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if __clang__
// according to clang documentation, version can be vendor specific
#define __PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
# define _PSTL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
#endif
// Enable SIMD for compilers that support OpenMP 4.0
#if (_OPENMP >= 201307) || (__INTEL_COMPILER >= 1600) || (!defined(__INTEL_COMPILER) && __PSTL_GCC_VERSION >= 40900)
#define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(omp simd)
#define __PSTL_PRAGMA_DECLARE_SIMD __PSTL_PRAGMA(omp declare simd)
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(omp simd reduction(PRM))
#if (_OPENMP >= 201307) || (__INTEL_COMPILER >= 1600) || (!defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900)
# define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
# define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
#elif !defined(_MSC_VER) //#pragma simd
#define __PSTL_PRAGMA_SIMD __PSTL_PRAGMA(simd)
#define __PSTL_PRAGMA_DECLARE_SIMD
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM) __PSTL_PRAGMA(simd reduction(PRM))
# define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(simd)
# define _PSTL_PRAGMA_DECLARE_SIMD
# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(simd reduction(PRM))
#else //no simd
#define __PSTL_PRAGMA_SIMD
#define __PSTL_PRAGMA_DECLARE_SIMD
#define __PSTL_PRAGMA_SIMD_REDUCTION(PRM)
# define _PSTL_PRAGMA_SIMD
# define _PSTL_PRAGMA_DECLARE_SIMD
# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
#endif //Enable SIMD
#if (__INTEL_COMPILER)
#define __PSTL_PRAGMA_FORCEINLINE __PSTL_PRAGMA(forceinline)
# define _PSTL_PRAGMA_FORCEINLINE _PSTL_PRAGMA(forceinline)
#else
#define __PSTL_PRAGMA_FORCEINLINE
# define _PSTL_PRAGMA_FORCEINLINE
#endif
#if (__INTEL_COMPILER >= 1900)
#define __PSTL_PRAGMA_SIMD_SCAN(PRM) __PSTL_PRAGMA(omp simd reduction(inscan, PRM))
#define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan inclusive(PRM))
#define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) __PSTL_PRAGMA(omp scan exclusive(PRM))
# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
#else
#define __PSTL_PRAGMA_SIMD_SCAN(PRM)
#define __PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
#define __PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
# define _PSTL_PRAGMA_SIMD_SCAN(PRM)
# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
#endif
// Should be defined to 1 for environments with a vendor implementation of C++17 execution policies
#define __PSTL_CPP17_EXECUTION_POLICIES_PRESENT (_MSC_VER >= 1912)
#define _PSTL_CPP17_EXECUTION_POLICIES_PRESENT (_MSC_VER >= 1912)
#define __PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT \
#define _PSTL_CPP14_2RANGE_MISMATCH_EQUAL_PRESENT \
(_MSC_VER >= 1900 || __cplusplus >= 201300L || __cpp_lib_robust_nonmodifying_seq_ops == 201304)
#define __PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT \
#define _PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT \
(_MSC_VER >= 1900 || __cplusplus >= 201402L || __cpp_lib_make_reverse_iterator == 201402)
#define __PSTL_CPP14_INTEGER_SEQUENCE_PRESENT (_MSC_VER >= 1900 || __cplusplus >= 201402L)
#define __PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT \
#define _PSTL_CPP14_INTEGER_SEQUENCE_PRESENT (_MSC_VER >= 1900 || __cplusplus >= 201402L)
#define _PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT \
(!__INTEL_COMPILER || __INTEL_COMPILER >= 1700) && (_MSC_FULL_VER >= 190023918 || __cplusplus >= 201402L)
#define __PSTL_EARLYEXIT_PRESENT (__INTEL_COMPILER >= 1800)
#define __PSTL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)
#define _PSTL_EARLYEXIT_PRESENT (__INTEL_COMPILER >= 1800)
#define _PSTL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)
#if (__INTEL_COMPILER >= 1900 || !defined(__INTEL_COMPILER) && __PSTL_GCC_VERSION >= 40900 || _OPENMP >= 201307)
#define __PSTL_UDR_PRESENT 1
#if (__INTEL_COMPILER >= 1900 || !defined(__INTEL_COMPILER) && _PSTL_GCC_VERSION >= 40900 || _OPENMP >= 201307)
# define _PSTL_UDR_PRESENT 1
#else
#define __PSTL_UDR_PRESENT 0
# define _PSTL_UDR_PRESENT 0
#endif
#define __PSTL_UDS_PRESENT (__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626)
#define _PSTL_UDS_PRESENT (__INTEL_COMPILER >= 1900 && __INTEL_COMPILER_BUILD_DATE >= 20180626)
#if __PSTL_EARLYEXIT_PRESENT
#define __PSTL_PRAGMA_SIMD_EARLYEXIT __PSTL_PRAGMA(omp simd early_exit)
#if _PSTL_EARLYEXIT_PRESENT
# define _PSTL_PRAGMA_SIMD_EARLYEXIT _PSTL_PRAGMA(omp simd early_exit)
#else
#define __PSTL_PRAGMA_SIMD_EARLYEXIT
# define _PSTL_PRAGMA_SIMD_EARLYEXIT
#endif
#if __PSTL_MONOTONIC_PRESENT
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) __PSTL_PRAGMA(omp ordered simd monotonic(PRM))
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) __PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
#if _PSTL_MONOTONIC_PRESENT
# define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM) _PSTL_PRAGMA(omp ordered simd monotonic(PRM))
# define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2) _PSTL_PRAGMA(omp ordered simd monotonic(PRM1, PRM2))
#else
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
#define __PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
# define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(PRM)
# define _PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(PRM1, PRM2)
#endif
// Declaration of reduction functor, where
......@@ -134,41 +123,41 @@
// omp_out - refers to the final value of the combiner operator
// omp_priv - refers to the private copy of the initial value
// omp_orig - refers to the original variable to be reduced
#define __PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
__PSTL_PRAGMA(omp declare reduction(NAME : OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
#define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
_PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
#if (__INTEL_COMPILER >= 1600)
#define __PSTL_PRAGMA_VECTOR_UNALIGNED __PSTL_PRAGMA(vector unaligned)
# define _PSTL_PRAGMA_VECTOR_UNALIGNED _PSTL_PRAGMA(vector unaligned)
#else
#define __PSTL_PRAGMA_VECTOR_UNALIGNED
# define _PSTL_PRAGMA_VECTOR_UNALIGNED
#endif
// Check the user-defined macro to use non-temporal stores
#if defined(PSTL_USE_NONTEMPORAL_STORES) && (__INTEL_COMPILER >= 1600)
#define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED __PSTL_PRAGMA(vector nontemporal)
# define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED _PSTL_PRAGMA(vector nontemporal)
#else
#define __PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
# define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
#endif
#if _MSC_VER || __INTEL_COMPILER //the preprocessors don't type a message location
#define __PSTL_PRAGMA_LOCATION __FILE__ ":" __PSTL_STRING(__LINE__) ": [Parallel STL message]: "
# define _PSTL_PRAGMA_LOCATION __FILE__ ":" _PSTL_STRING(__LINE__) ": [Parallel STL message]: "
#else
#define __PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
# define _PSTL_PRAGMA_LOCATION " [Parallel STL message]: "
#endif
#define __PSTL_PRAGMA_MESSAGE_IMPL(x) __PSTL_PRAGMA(message(__PSTL_STRING_CONCAT(__PSTL_PRAGMA_LOCATION, x)))
#define _PSTL_PRAGMA_MESSAGE_IMPL(x) _PSTL_PRAGMA(message(_PSTL_STRING_CONCAT(_PSTL_PRAGMA_LOCATION, x)))
#if __PSTL_USAGE_WARNINGS
#define __PSTL_PRAGMA_MESSAGE(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
#define __PSTL_PRAGMA_MESSAGE_POLICIES(x) __PSTL_PRAGMA_MESSAGE_IMPL(x)
#if _PSTL_USAGE_WARNINGS
# define _PSTL_PRAGMA_MESSAGE(x) _PSTL_PRAGMA_MESSAGE_IMPL(x)
# define _PSTL_PRAGMA_MESSAGE_POLICIES(x) _PSTL_PRAGMA_MESSAGE_IMPL(x)
#else
#define __PSTL_PRAGMA_MESSAGE(x)
#define __PSTL_PRAGMA_MESSAGE_POLICIES(x)
# define _PSTL_PRAGMA_MESSAGE(x)
# define _PSTL_PRAGMA_MESSAGE_POLICIES(x)
#endif
// broken macros
#define __PSTL_CPP11_STD_ROTATE_BROKEN ((__GLIBCXX__ && __GLIBCXX__ < 20150716) || (_MSC_VER && _MSC_VER < 1800))
#define _PSTL_CPP11_STD_ROTATE_BROKEN ((__GLIBCXX__ && __GLIBCXX__ < 20150716) || (_MSC_VER && _MSC_VER < 1800))
#define __PSTL_ICC_18_OMP_SIMD_BROKEN (__INTEL_COMPILER == 1800)
#define _PSTL_ICC_18_OMP_SIMD_BROKEN (__INTEL_COMPILER == 1800)
#endif /* __PSTL_config_H */
#endif /* _PSTL_CONFIG_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_unseq_backend_simd_H
#define __PSTL_unseq_backend_simd_H
#ifndef _PSTL_UNSEQ_BACKEND_SIMD_H
#define _PSTL_UNSEQ_BACKEND_SIMD_H
#include <type_traits>
......@@ -28,7 +28,7 @@ template <class _Iterator, class _DifferenceType, class _Function>
_Iterator
__simd_walk_1(_Iterator __first, _DifferenceType __n, _Function __f) noexcept
{
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
__f(__first[__i]);
......@@ -39,7 +39,7 @@ template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Func
_Iterator2
__simd_walk_2(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept
{
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
__f(__first1[__i], __first2[__i]);
return __first2 + __n;
......@@ -50,7 +50,7 @@ _Iterator3
__simd_walk_3(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Iterator3 __first3,
_Function __f) noexcept
{
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
__f(__first1[__i], __first2[__i], __first3[__i]);
return __first3 + __n;
......@@ -61,10 +61,10 @@ template <class _Index, class _DifferenceType, class _Pred>
bool
__simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept
{
#if __PSTL_EARLYEXIT_PRESENT
#if _PSTL_EARLYEXIT_PRESENT
_DifferenceType __i;
__PSTL_PRAGMA_VECTOR_UNALIGNED
__PSTL_PRAGMA_SIMD_EARLYEXIT
_PSTL_PRAGMA_VECTOR_UNALIGNED
_PSTL_PRAGMA_SIMD_EARLYEXIT
for (__i = 0; __i < __n; ++__i)
if (__pred(__first[__i]))
break;
......@@ -75,7 +75,7 @@ __simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept
while (__last != __first)
{
int32_t __flag = 1;
__PSTL_PRAGMA_SIMD_REDUCTION(& : __flag)
_PSTL_PRAGMA_SIMD_REDUCTION(& : __flag)
for (_DifferenceType __i = 0; __i < __block_size; ++__i)
if (__pred(*(__first + __i)))
__flag = 0;
......@@ -101,10 +101,10 @@ template <class _Index, class _DifferenceType, class _Compare>
_Index
__simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp) noexcept
{
#if __PSTL_EARLYEXIT_PRESENT
#if _PSTL_EARLYEXIT_PRESENT
_DifferenceType __i = __begin;
__PSTL_PRAGMA_VECTOR_UNALIGNED // Do not generate peel loop part
__PSTL_PRAGMA_SIMD_EARLYEXIT for (; __i < __end; ++__i)
_PSTL_PRAGMA_VECTOR_UNALIGNED // Do not generate peel loop part
_PSTL_PRAGMA_SIMD_EARLYEXIT for (; __i < __end; ++__i)
{
if (__comp(__first, __i))
{
......@@ -119,10 +119,10 @@ __simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Co
while (__end - __begin >= __block_size)
{
_DifferenceType __found = 0;
__PSTL_PRAGMA_VECTOR_UNALIGNED // Do not generate peel loop part
__PSTL_PRAGMA_SIMD_REDUCTION(|
: __found) for (_DifferenceType __i = __begin; __i < __begin + __block_size;
++__i)
_PSTL_PRAGMA_VECTOR_UNALIGNED // Do not generate peel loop part
_PSTL_PRAGMA_SIMD_REDUCTION(|
: __found) for (_DifferenceType __i = __begin; __i < __begin + __block_size;
++__i)
{
const _DifferenceType __t = __comp(__first, __i);
__lane[__i - __begin] = __t;
......@@ -154,17 +154,17 @@ __simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Co
++__begin;
}
return __first + __end;
#endif //__PSTL_EARLYEXIT_PRESENT
#endif //_PSTL_EARLYEXIT_PRESENT
}
template <class _Index1, class _DifferenceType, class _Index2, class _Pred>
std::pair<_Index1, _Index2>
__simd_first(_Index1 __first1, _DifferenceType __n, _Index2 __first2, _Pred __pred) noexcept
{
#if __PSTL_EARLYEXIT_PRESENT
#if _PSTL_EARLYEXIT_PRESENT
_DifferenceType __i = 0;
__PSTL_PRAGMA_VECTOR_UNALIGNED
__PSTL_PRAGMA_SIMD_EARLYEXIT
_PSTL_PRAGMA_VECTOR_UNALIGNED
_PSTL_PRAGMA_SIMD_EARLYEXIT
for (; __i < __n; ++__i)
if (__pred(__first1[__i], __first2[__i]))
break;
......@@ -179,8 +179,8 @@ __simd_first(_Index1 __first1, _DifferenceType __n, _Index2 __first2, _Pred __pr
{
_DifferenceType __found = 0;
_DifferenceType __i;
__PSTL_PRAGMA_VECTOR_UNALIGNED // Do not generate peel loop part
__PSTL_PRAGMA_SIMD_REDUCTION(|
_PSTL_PRAGMA_VECTOR_UNALIGNED // Do not generate peel loop part
_PSTL_PRAGMA_SIMD_REDUCTION(|
: __found) for (__i = 0; __i < __block_size; ++__i)
{
const _DifferenceType __t = __pred(__first1[__i], __first2[__i]);
......@@ -208,7 +208,7 @@ __simd_first(_Index1 __first1, _DifferenceType __n, _Index2 __first2, _Pred __pr
return std::make_pair(__first1, __first2);
return std::make_pair(__last1, __last2);
#endif //__PSTL_EARLYEXIT_PRESENT
#endif //_PSTL_EARLYEXIT_PRESENT
}
template <class _Index, class _DifferenceType, class _Pred>
......@@ -216,7 +216,7 @@ _DifferenceType
__simd_count(_Index __index, _DifferenceType __n, _Pred __pred) noexcept
{
_DifferenceType __count = 0;
__PSTL_PRAGMA_SIMD_REDUCTION(+ : __count)
_PSTL_PRAGMA_SIMD_REDUCTION(+ : __count)
for (_DifferenceType __i = 0; __i < __n; ++__i)
if (__pred(*(__index + __i)))
++__count;
......@@ -235,10 +235,10 @@ __simd_unique_copy(_InputIterator __first, _DifferenceType __n, _OutputIterator
_DifferenceType __cnt = 1;
__result[0] = __first[0];
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 1; __i < __n; ++__i)
{
__PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(__cnt : 1)
_PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(__cnt : 1)
if (!__pred(__first[__i], __first[__i - 1]))
{
__result[__cnt] = __first[__i];
......@@ -252,8 +252,8 @@ template <class _InputIterator, class _DifferenceType, class _OutputIterator, cl
_OutputIterator
__simd_assign(_InputIterator __first, _DifferenceType __n, _OutputIterator __result, _Assigner __assigner) noexcept
{
__PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
__PSTL_PRAGMA_SIMD
_PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
__assigner(__first + __i, __result + __i);
return __result + __n;
......@@ -265,10 +265,10 @@ __simd_copy_if(_InputIterator __first, _DifferenceType __n, _OutputIterator __re
{
_DifferenceType __cnt = 0;
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
{
__PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(__cnt : 1)
_PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(__cnt : 1)
if (__pred(__first[__i]))
{
__result[__cnt] = __first[__i];
......@@ -284,7 +284,7 @@ __simd_calc_mask_2(_InputIterator __first, _DifferenceType __n, bool* __mask, _B
{
_DifferenceType __count = 0;
__PSTL_PRAGMA_SIMD_REDUCTION(+ : __count)
_PSTL_PRAGMA_SIMD_REDUCTION(+ : __count)
for (_DifferenceType __i = 0; __i < __n; ++__i)
{
__mask[__i] = !__pred(__first[__i], __first[__i - 1]);
......@@ -299,7 +299,7 @@ __simd_calc_mask_1(_InputIterator __first, _DifferenceType __n, bool* __mask, _U
{
_DifferenceType __count = 0;
__PSTL_PRAGMA_SIMD_REDUCTION(+ : __count)
_PSTL_PRAGMA_SIMD_REDUCTION(+ : __count)
for (_DifferenceType __i = 0; __i < __n; ++__i)
{
__mask[__i] = __pred(__first[__i]);
......@@ -314,12 +314,12 @@ __simd_copy_by_mask(_InputIterator __first, _DifferenceType __n, _OutputIterator
_Assigner __assigner) noexcept
{
_DifferenceType __cnt = 0;
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
{
if (__mask[__i])
{
__PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(__cnt : 1)
_PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(__cnt : 1)
{
__assigner(__first + __i, __result + __cnt);
++__cnt;
......@@ -334,10 +334,10 @@ __simd_partition_by_mask(_InputIterator __first, _DifferenceType __n, _OutputIte
_OutputIterator2 __out_false, bool* __mask) noexcept
{
_DifferenceType __cnt_true = 0, __cnt_false = 0;
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
{
__PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(__cnt_true : 1, __cnt_false : 1)
_PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(__cnt_true : 1, __cnt_false : 1)
if (__mask[__i])
{
__out_true[__cnt_true] = __first[__i];
......@@ -355,8 +355,8 @@ template <class _Index, class _DifferenceType, class _Tp>
_Index
__simd_fill_n(_Index __first, _DifferenceType __n, const _Tp& __value) noexcept
{
__PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
__PSTL_PRAGMA_SIMD
_PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
__first[__i] = __value;
return __first + __n;
......@@ -366,8 +366,8 @@ template <class _Index, class _DifferenceType, class _Generator>
_Index
__simd_generate_n(_Index __first, _DifferenceType __size, _Generator __g) noexcept
{
__PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
__PSTL_PRAGMA_SIMD
_PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __size; ++__i)
__first[__i] = __g();
return __first + __size;
......@@ -383,11 +383,11 @@ __simd_adjacent_find(_Index __first, _Index __last, _BinaryPredicate __pred, boo
typedef typename std::iterator_traits<_Index>::difference_type _DifferenceType;
_DifferenceType __i = 0;
#if __PSTL_EARLYEXIT_PRESENT
#if _PSTL_EARLYEXIT_PRESENT
//Some compiler versions fail to compile the following loop when iterators are used. Indices are used instead
const _DifferenceType __n = __last - __first - 1;
__PSTL_PRAGMA_VECTOR_UNALIGNED
__PSTL_PRAGMA_SIMD_EARLYEXIT
_PSTL_PRAGMA_VECTOR_UNALIGNED
_PSTL_PRAGMA_SIMD_EARLYEXIT
for (; __i < __n; ++__i)
if (__pred(__first[__i], __first[__i + 1]))
break;
......@@ -401,8 +401,8 @@ __simd_adjacent_find(_Index __first, _Index __last, _BinaryPredicate __pred, boo
while (__last - __first >= __block_size)
{
_DifferenceType __found = 0;
__PSTL_PRAGMA_VECTOR_UNALIGNED // Do not generate peel loop part
__PSTL_PRAGMA_SIMD_REDUCTION(|
_PSTL_PRAGMA_VECTOR_UNALIGNED // Do not generate peel loop part
_PSTL_PRAGMA_SIMD_REDUCTION(|
: __found) for (__i = 0; __i < __block_size - 1; ++__i)
{
//TODO: to improve SIMD vectorization
......@@ -446,7 +446,7 @@ template <typename _DifferenceType, typename _Tp, typename _BinaryOperation, typ
typename std::enable_if<is_arithmetic_plus<_Tp, _BinaryOperation>::value, _Tp>::type
__simd_transform_reduce(_DifferenceType __n, _Tp __init, _BinaryOperation, _UnaryOperation __f) noexcept
{
__PSTL_PRAGMA_SIMD_REDUCTION(+ : __init)
_PSTL_PRAGMA_SIMD_REDUCTION(+ : __init)
for (_DifferenceType __i = 0; __i < __n; ++__i)
__init += __f(__i);
return __init;
......@@ -463,7 +463,7 @@ __simd_transform_reduce(_Size __n, _Tp __init, _BinaryOperation __binary_op, _Un
_Tp* __lane = reinterpret_cast<_Tp*>(__lane_);
// initializer
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_Size __i = 0; __i < __block_size; ++__i)
{
::new (__lane + __i) _Tp(__binary_op(__f(__i), __f(__block_size + __i)));
......@@ -473,14 +473,14 @@ __simd_transform_reduce(_Size __n, _Tp __init, _BinaryOperation __binary_op, _Un
const _Size last_iteration = __block_size * (__n / __block_size);
for (; __i < last_iteration; __i += __block_size)
{
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_Size __j = 0; __j < __block_size; ++__j)
{
__lane[__j] = __binary_op(__lane[__j], __f(__i + __j));
}
}
// remainder
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_Size __j = 0; __j < __n - last_iteration; ++__j)
{
__lane[__j] = __binary_op(__lane[__j], __f(last_iteration + __j));
......@@ -491,7 +491,7 @@ __simd_transform_reduce(_Size __n, _Tp __init, _BinaryOperation __binary_op, _Un
__init = __binary_op(__init, __lane[__i]);
}
// destroyer
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_Size __i = 0; __i < __block_size; ++__i)
{
__lane[__i].~_Tp();
......@@ -514,11 +514,11 @@ typename std::enable_if<is_arithmetic_plus<_Tp, _BinaryOperation>::value, std::p
__simd_scan(_InputIterator __first, _Size __n, _OutputIterator __result, _UnaryOperation __unary_op, _Tp __init,
_BinaryOperation, /*Inclusive*/ std::false_type)
{
__PSTL_PRAGMA_SIMD_SCAN(+ : __init)
_PSTL_PRAGMA_SIMD_SCAN(+ : __init)
for (_Size __i = 0; __i < __n; ++__i)
{
__result[__i] = __init;
__PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(__init)
_PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(__init)
__init += __unary_op(__first[__i]);
}
return std::make_pair(__result + __n, __init);
......@@ -552,14 +552,14 @@ __simd_scan(_InputIterator __first, _Size __n, _OutputIterator __result, _UnaryO
typedef _Combiner<_Tp, _BinaryOperation> _CombinerType;
_CombinerType __init_{__init, &__binary_op};
__PSTL_PRAGMA_DECLARE_REDUCTION(__bin_op, _CombinerType)
_PSTL_PRAGMA_DECLARE_REDUCTION(__bin_op, _CombinerType)
__PSTL_PRAGMA_SIMD_SCAN(__bin_op : __init_)
_PSTL_PRAGMA_SIMD_SCAN(__bin_op : __init_)
for (_Size __i = 0; __i < __n; ++__i)
{
__result[__i] = __init_.__value;
__PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(__init_)
__PSTL_PRAGMA_FORCEINLINE
_PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(__init_)
_PSTL_PRAGMA_FORCEINLINE
__init_.__value = __binary_op(__init_.__value, __unary_op(__first[__i]));
}
return std::make_pair(__result + __n, __init_.__value);
......@@ -572,11 +572,11 @@ typename std::enable_if<is_arithmetic_plus<_Tp, _BinaryOperation>::value, std::p
__simd_scan(_InputIterator __first, _Size __n, _OutputIterator __result, _UnaryOperation __unary_op, _Tp __init,
_BinaryOperation, /*Inclusive*/ std::true_type)
{
__PSTL_PRAGMA_SIMD_SCAN(+ : __init)
_PSTL_PRAGMA_SIMD_SCAN(+ : __init)
for (_Size __i = 0; __i < __n; ++__i)
{
__init += __unary_op(__first[__i]);
__PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(__init)
_PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(__init)
__result[__i] = __init;
}
return std::make_pair(__result + __n, __init);
......@@ -592,14 +592,14 @@ __simd_scan(_InputIterator __first, _Size __n, _OutputIterator __result, _UnaryO
typedef _Combiner<_Tp, _BinaryOperation> _CombinerType;
_CombinerType __init_{__init, &__binary_op};
__PSTL_PRAGMA_DECLARE_REDUCTION(__bin_op, _CombinerType)
_PSTL_PRAGMA_DECLARE_REDUCTION(__bin_op, _CombinerType)
__PSTL_PRAGMA_SIMD_SCAN(__bin_op : __init_)
_PSTL_PRAGMA_SIMD_SCAN(__bin_op : __init_)
for (_Size __i = 0; __i < __n; ++__i)
{
__PSTL_PRAGMA_FORCEINLINE
_PSTL_PRAGMA_FORCEINLINE
__init_.__value = __binary_op(__init_.__value, __unary_op(__first[__i]));
__PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(__init_)
_PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(__init_)
__result[__i] = __init_.__value;
}
return std::make_pair(__result + __n, __init_.__value);
......@@ -633,7 +633,7 @@ __simd_min_element(_ForwardIterator __first, _Size __n, _Compare __comp) noexcep
{
}
__PSTL_PRAGMA_DECLARE_SIMD
_PSTL_PRAGMA_DECLARE_SIMD
void
operator()(const _ComplexType& __obj)
{
......@@ -648,9 +648,9 @@ __simd_min_element(_ForwardIterator __first, _Size __n, _Compare __comp) noexcep
_ComplexType __init{*__first, &__comp};
__PSTL_PRAGMA_DECLARE_REDUCTION(__min_func, _ComplexType)
_PSTL_PRAGMA_DECLARE_REDUCTION(__min_func, _ComplexType)
__PSTL_PRAGMA_SIMD_REDUCTION(__min_func : __init)
_PSTL_PRAGMA_SIMD_REDUCTION(__min_func : __init)
for (_Size __i = 1; __i < __n; ++__i)
{
const _ValueType __min_val = __init.__min_val;
......@@ -727,9 +727,9 @@ __simd_minmax_element(_ForwardIterator __first, _Size __n, _Compare __comp) noex
_ComplexType __init{*__first, *__first, &__comp};
__PSTL_PRAGMA_DECLARE_REDUCTION(__min_func, _ComplexType);
_PSTL_PRAGMA_DECLARE_REDUCTION(__min_func, _ComplexType);
__PSTL_PRAGMA_SIMD_REDUCTION(__min_func : __init)
_PSTL_PRAGMA_SIMD_REDUCTION(__min_func : __init)
for (_Size __i = 1; __i < __n; ++__i)
{
auto __min_val = __init.__min_val;
......@@ -757,10 +757,10 @@ __simd_partition_copy(_InputIterator __first, _DifferenceType __n, _OutputIterat
{
_DifferenceType __cnt_true = 0, __cnt_false = 0;
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
{
__PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(__cnt_true : 1, __cnt_false : 1)
_PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC_2ARGS(__cnt_true : 1, __cnt_false : 1)
if (__pred(__first[__i]))
{
__out_true[__cnt_true] = __first[__i];
......@@ -837,10 +837,10 @@ __simd_remove_if(_RandomAccessIterator __first, _DifferenceType __n, _UnaryPredi
}
_DifferenceType __cnt = 0;
__PSTL_PRAGMA_SIMD
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 1; __i < __n; ++__i)
{
__PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(__cnt : 1)
_PSTL_PRAGMA_SIMD_ORDERED_MONOTONIC(__cnt : 1)
if (!__pred(__current[__i]))
{
__current[__cnt] = std::move(__current[__i]);
......@@ -852,4 +852,4 @@ __simd_remove_if(_RandomAccessIterator __first, _DifferenceType __n, _UnaryPredi
} // namespace __unseq_backend
} // namespace __pstl
#endif /* __PSTL_unseq_backend_simd_H */
#endif /* _PSTL_UNSEQ_BACKEND_SIMD_H */
......@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_utils_H
#define __PSTL_utils_H
#ifndef _PSTL_UTILS_H
#define _PSTL_UTILS_H
#include <new>
#include <iterator>
......@@ -219,4 +219,4 @@ __cmp_iterators_by_values(_ForwardIterator __a, _ForwardIterator __b, _Compare _
} // namespace __internal
} // namespace __pstl
#endif /* __PSTL_utils_H */
#endif /* _PSTL_UTILS_H */
......@@ -63,13 +63,13 @@
#if __cplusplus > 201402L
// Parallel STL algorithms
# if __PSTL_EXECUTION_POLICIES_DEFINED
# if _PSTL_EXECUTION_POLICIES_DEFINED
// If <execution> has already been included, pull in implementations
# include <pstl/glue_algorithm_impl.h>
# else
// Otherwise just pull in forward declarations
# include <pstl/glue_algorithm_defs.h>
# define __PSTL_ALGORITHM_FORWARD_DECLARED 1
# define _PSTL_ALGORITHM_FORWARD_DECLARED 1
# endif
// Feature test macro for parallel algorithms
......
......@@ -31,20 +31,20 @@
# include <bits/c++config.h>
# include <pstl/glue_execution_defs.h>
# define __PSTL_EXECUTION_POLICIES_DEFINED 1
# define _PSTL_EXECUTION_POLICIES_DEFINED 1
// Algorithm implementation
# if __PSTL_ALGORITHM_FORWARD_DECLARED
# if _PSTL_ALGORITHM_FORWARD_DECLARED
# include <pstl/glue_algorithm_impl.h>
# endif
// Numeric implementation
# if __PSTL_NUMERIC_FORWARD_DECLARED
# if _PSTL_NUMERIC_FORWARD_DECLARED
# include <pstl/glue_numeric_impl.h>
# endif
// Memory implementation
# if __PSTL_NUMERIC_FORWARD_DECLARED
# if _PSTL_NUMERIC_FORWARD_DECLARED
# include <pstl/glue_memory_impl.h>
# endif
......
......@@ -398,7 +398,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
#if __cplusplus > 201402L
// Parallel STL algorithms
# if __PSTL_EXECUTION_POLICIES_DEFINED
# if _PSTL_EXECUTION_POLICIES_DEFINED
// If <execution> has already been included, pull in implementations
# include <pstl/glue_memory_impl.h>
# else
......
......@@ -206,13 +206,13 @@ _GLIBCXX_END_NAMESPACE_VERSION
#if __cplusplus > 201402L
// Parallel STL algorithms
# if __PSTL_EXECUTION_POLICIES_DEFINED
# if _PSTL_EXECUTION_POLICIES_DEFINED
// If <execution> has already been included, pull in implementations
# include <pstl/glue_numeric_impl.h>
# else
// Otherwise just pull in forward declarations
# include <pstl/glue_numeric_defs.h>
# define __PSTL_NUMERIC_FORWARD_DECLARED 1
# define _PSTL_NUMERIC_FORWARD_DECLARED 1
# endif
// Feature test macro for parallel algorithms
......
......@@ -116,7 +116,7 @@ main()
{
// for user-defined types
#if !__PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN
#if !_PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN
test_uninit_construct_by_type<Wrapper<int32_t>>();
test_uninit_construct_by_type<Wrapper<std::vector<std::string>>>();
#endif
......
......@@ -80,7 +80,7 @@ struct test_uninitialized_copy_move
std::destroy_n(exec, out_first, n);
}
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || __PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || _PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN
template <typename InputIterator, typename OutputIterator>
void
operator()(pstl::execution::unsequenced_policy, InputIterator first, InputIterator last, OutputIterator out_first,
......@@ -142,8 +142,8 @@ main()
test_uninitialized_copy_move_by_type<float64_t>();
// for user-defined types
#if !__PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN && !__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN && \
!__PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN
#if !_PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN && !_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN && \
!_PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN
test_uninitialized_copy_move_by_type<Wrapper<int8_t>>();
#endif
......
......@@ -29,8 +29,8 @@ using namespace TestUtils;
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
template <typename BiDirIt1, typename Size, typename Generator1, typename Generator2, typename Compare>
void
operator()(pstl::execution::unsequenced_policy, BiDirIt1 first1, BiDirIt1 last1, BiDirIt1 first2, BiDirIt1 last2,
......
......@@ -111,7 +111,7 @@ main()
test_merge_by_type<int32_t>([](size_t v) { return (v % 2 == 0 ? v : -v) * 3; }, [](size_t v) { return v * 2; });
test_merge_by_type<float64_t>([](size_t v) { return float64_t(v); }, [](size_t v) { return float64_t(v - 100); });
#if !__PSTL_ICC_16_17_TEST_64_TIMEOUT
#if !_PSTL_ICC_16_17_TEST_64_TIMEOUT
test_merge_by_type<Wrapper<int16_t>>([](size_t v) { return Wrapper<int16_t>(v % 100); },
[](size_t v) { return Wrapper<int16_t>(v % 10); });
#endif
......
......@@ -28,7 +28,7 @@ using namespace TestUtils;
struct run_copy_if
{
#if __PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN // dummy specializations to skip testing in case of broken configuration
#if _PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN // dummy specializations to skip testing in case of broken configuration
template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size,
typename Predicate, typename T>
void
......@@ -139,11 +139,11 @@ main()
test<int32_t>(-666, [](const int32_t& x) { return x != 42; },
[](size_t j) { return ((j + 1) % 5 & 2) != 0 ? int32_t(j + 1) : 42; });
#if !__PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
#if !_PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
test<Number>(Number(42, OddTag()), IsMultiple(3, OddTag()), [](int32_t j) { return Number(j, OddTag()); });
#endif
#if !__PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
test<int32_t>(-666, [](const int32_t& x) { return true; }, [](size_t j) { return j; }, false);
#endif
......
......@@ -30,8 +30,8 @@ using namespace TestUtils;
struct run_copy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size, typename T>
void
operator()(pstl::execution::unsequenced_policy, InputIterator first, InputIterator last, OutputIterator out_first,
......@@ -83,8 +83,8 @@ template <typename T>
struct run_move
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size>
void
operator()(pstl::execution::unsequenced_policy, InputIterator first, InputIterator last, OutputIterator out_first,
......@@ -126,8 +126,8 @@ template <typename T>
struct run_move<Wrapper<T>>
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size>
void
operator()(pstl::execution::unsequenced_policy, InputIterator first, InputIterator last, OutputIterator out_first,
......@@ -199,7 +199,7 @@ main()
test<int32_t>(-666, [](size_t j) { return int32_t(j); });
test<Wrapper<float64_t>>(Wrapper<float64_t>(-666.0), [](int32_t j) { return Wrapper<float64_t>(j); });
#if !__PSTL_ICC_16_17_TEST_64_TIMEOUT
#if !_PSTL_ICC_16_17_TEST_64_TIMEOUT
test<float64_t>(-666.0, [](size_t j) { return float64_t(j); });
test<Number>(Number(42, OddTag()), [](int32_t j) { return Number(j, OddTag()); });
#endif
......
......@@ -28,7 +28,7 @@ using namespace TestUtils;
struct test_one_policy
{
//dummy specialization by policy type, in case of broken configuration
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || __PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || _PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN
template <typename Iterator1, typename Predicate>
void
......@@ -97,7 +97,7 @@ main()
test<float64_t>([](const float64_t x) { return x < 0; });
test<int32_t>([](const int32_t x) { return x > 1000; });
test<uint16_t>([](const uint16_t x) { return x % 5 < 3; });
#if !__PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN && !__PSTL_ICC_19_TEST_IS_PARTITIONED_RELEASE_BROKEN
#if !_PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN && !_PSTL_ICC_19_TEST_IS_PARTITIONED_RELEASE_BROKEN
test<LocalWrapper<float64_t>>([](const LocalWrapper<float64_t>& x) { return true; });
#endif
......
......@@ -72,8 +72,8 @@ is_equal(Iterator first, Iterator last, Iterator d_first)
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specializations to skip testing in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specializations to skip testing in case of broken configuration
template <typename BiDirIt, typename Size, typename UnaryOp, typename Generator>
void
operator()(__pstl::execution::unsequenced_policy, BiDirIt first, BiDirIt last, BiDirIt exp_first, BiDirIt exp_last,
......@@ -87,7 +87,7 @@ struct test_one_policy
BiDirIt exp_last, Size n, UnaryOp unary_op, Generator generator)
{
}
#elif __PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN //dummy specializations to skip testing in case of broken configuration
#elif _PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN //dummy specializations to skip testing in case of broken configuration
template <typename BiDirIt, typename Size, typename UnaryOp, typename Generator>
void
operator()(__pstl::execution::parallel_policy, BiDirIt first, BiDirIt last, BiDirIt exp_first, BiDirIt exp_last,
......@@ -172,7 +172,7 @@ struct test_non_const
int32_t
main()
{
#if !__PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
test_by_type<int32_t>([](int32_t i) { return i; }, [](int32_t) { return true; });
#endif
test_by_type<float64_t>([](int32_t i) { return -i; }, [](const float64_t x) { return x < 0; });
......
......@@ -48,7 +48,7 @@ struct test_partition_copy
}
//dummy specialization by iterator type and policy type, in case of broken configuration
#if __PSTL_ICC_1800_TEST_MONOTONIC_RELEASE_64_BROKEN
#if _PSTL_ICC_1800_TEST_MONOTONIC_RELEASE_64_BROKEN
template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename UnaryOp>
void
operator()(pstl::execution::unsequenced_policy, std::reverse_iterator<InputIterator> first,
......@@ -110,7 +110,7 @@ main()
{
test<int32_t>([](const int32_t value) { return value % 2; });
#if !__PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
test<int32_t>([](const int32_t value) { return true; });
#endif
......
......@@ -28,8 +28,8 @@ using namespace TestUtils;
struct run_remove
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename InputIterator, typename OutputIterator, typename Size, typename T>
void
operator()(pstl::execution::unsequenced_policy, InputIterator first, InputIterator last, OutputIterator out_first,
......@@ -66,8 +66,8 @@ struct run_remove
struct run_remove_if
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename InputIterator, typename OutputIterator, typename Size, typename Predicate>
void
operator()(pstl::execution::unsequenced_policy, InputIterator first, InputIterator last, OutputIterator out_first,
......@@ -140,7 +140,7 @@ struct test_non_const
int32_t
main()
{
#if !__PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN
#if !_PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN
test<int32_t>(666, 42, [](int32_t val) { return true; }, [](size_t j) { return j; });
#endif
......@@ -149,7 +149,7 @@ main()
test<float64_t>(-666.0, 8.5, [](const float64_t& val) { return val != 8.5; },
[](size_t j) { return ((j + 1) % 7 & 2) != 0 ? 8.5 : float64_t(j % 32 + j); });
#if !__PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
#if !_PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
test<Number>(Number(-666, OddTag()), Number(42, OddTag()), IsMultiple(3, OddTag()),
[](int32_t j) { return Number(j, OddTag()); });
#endif
......
......@@ -100,7 +100,7 @@ main()
test<int32_t>(-666, 42, 99, [](const int32_t& x) { return x != 42; },
[](size_t j) { return ((j + 1) % 5 & 2) != 0 ? 42 : -1 - int32_t(j); });
#if !__PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
#if !_PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
test<Number>(Number(42, OddTag()), Number(2001, OddTag()), Number(2017, OddTag()), IsMultiple(3, OddTag()),
[](int32_t j) { return ((j + 1) % 3 & 2) != 0 ? Number(2001, OddTag()) : Number(j, OddTag()); });
#endif
......
......@@ -82,8 +82,8 @@ struct compare<wrapper<T>>
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specializations to skip testing in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specializations to skip testing in case of broken configuration
template <typename Iterator, typename Size>
void
operator()(__pstl::execution::unsequenced_policy, Iterator data_b, Iterator data_e, Iterator actual_b,
......
......@@ -77,8 +77,8 @@ struct comparator
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
template <typename Iterator1, typename Iterator2>
typename std::enable_if<is_same_iterator_category<Iterator1, std::random_access_iterator_tag>::value, void>::type
operator()(pstl::execution::unsequenced_policy, Iterator1 data_b, Iterator1 data_e, Iterator2 actual_b,
......
......@@ -28,8 +28,8 @@ using namespace TestUtils;
struct run_unique
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename ForwardIt, typename Generator>
void
operator()(pstl::execution::unsequenced_policy, ForwardIt first1, ForwardIt last1, ForwardIt first2,
......@@ -146,7 +146,7 @@ struct test_non_const
int32_t
main()
{
#if !__PSTL_ICC_16_17_18_TEST_UNIQUE_MASK_RELEASE_BROKEN
#if !_PSTL_ICC_16_17_18_TEST_UNIQUE_MASK_RELEASE_BROKEN
test<int32_t>([](size_t j) { return j / 3; },
[](const int32_t& val1, const int32_t& val2) { return val1 * val1 == val2 * val2; });
test<float64_t>([](size_t) { return float64_t(1); },
......
......@@ -28,7 +28,7 @@ using namespace TestUtils;
struct run_unique_copy
{
#if __PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN // dummy specializations to skip testing in case of broken configuration
#if _PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN // dummy specializations to skip testing in case of broken configuration
template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size,
typename Predicate, typename T>
void
......@@ -130,7 +130,7 @@ main(int32_t argc, char* argv[])
test<float32_t>(float32_t(42), std::equal_to<float32_t>(),
[](int32_t j) { return float32_t(5 * j / 23 ^ (j / 7)); });
#if !__PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
test<float32_t>(float32_t(42), [](float32_t x, float32_t y) { return false; },
[](int32_t j) { return float32_t(j); }, false);
#endif
......
......@@ -113,7 +113,7 @@ main()
test<int32_t>(8 * sizeof(int32_t));
test<uint16_t>(8 * sizeof(uint16_t));
test<float64_t>(53);
#if !__PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
test<bool>(1);
#endif
......
......@@ -99,7 +99,7 @@ main()
test<int32_t>(8 * sizeof(int32_t));
test<uint16_t>(8 * sizeof(uint16_t));
test<float64_t>(53);
#if !__PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
test<bool>(1);
#endif
......
......@@ -101,7 +101,7 @@ int32_t
main()
{
test<int32_t>(42, IsEqual<int32_t>(50, OddTag()), [](int32_t j) { return j; });
#if !__PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
test<int32_t>(42, [](const int32_t& x) { return true; }, [](int32_t j) { return j; });
#endif
test<float64_t>(42, IsEqual<float64_t>(50, OddTag()), [](int32_t j) { return float64_t(j); });
......
......@@ -163,7 +163,7 @@ main()
test<int32_t>(8 * sizeof(int32_t));
test<uint16_t>(8 * sizeof(uint16_t));
test<float64_t>(53);
#if !__PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
test<bool>(1);
#endif
test<UserType>(256);
......
......@@ -28,8 +28,8 @@ using namespace TestUtils;
struct test_find
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename Iterator, typename Value>
void
operator()(pstl::execution::unsequenced_policy, Iterator first, Iterator last, Value value)
......
......@@ -27,8 +27,8 @@ using namespace TestUtils;
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename Iterator1, typename Iterator2, typename Predicate>
void
operator()(pstl::execution::unsequenced_policy, Iterator1 b, Iterator1 e, Iterator2 bsub, Iterator2 esub,
......@@ -119,7 +119,7 @@ main()
test<int32_t>(8 * sizeof(int32_t));
test<uint16_t>(8 * sizeof(uint16_t));
test<float64_t>(53);
#if !__PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
test<bool>(1);
#endif
......
......@@ -27,8 +27,8 @@ using namespace TestUtils;
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename Iterator1, typename Iterator2, typename Predicate>
void
operator()(pstl::execution::unsequenced_policy, Iterator1 b, Iterator1 e, Iterator2 bsub, Iterator2 esub,
......
......@@ -28,8 +28,8 @@ using namespace TestUtils;
struct test_find_if
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename Iterator, typename Predicate, typename NotPredicate>
void
operator()(pstl::execution::unsequenced_policy, Iterator first, Iterator last, Predicate pred,
......@@ -99,7 +99,7 @@ struct test_non_const
int32_t
main()
{
#if !__PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
#if !_PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
// Note that the "hit" and "miss" functions here avoid overflow issues.
test<Number>(IsMultiple(5, OddTag()), [](int32_t j) { return Number(j - j % 5, OddTag()); }, // hit
[](int32_t j) { return Number(j % 5 == 0 ? j ^ 1 : j, OddTag()); }); // miss
......
......@@ -97,7 +97,7 @@ main()
test<int32_t>(8 * sizeof(int32_t));
test<uint16_t>(8 * sizeof(uint16_t));
test<float64_t>(53);
#if !__PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
test<bool>(1);
#endif
......
......@@ -77,8 +77,8 @@ is_equal(const T& x, const T& y)
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
template <typename Iterator1, typename Size, typename Generator1, typename Generator2, typename Compare>
typename std::enable_if<is_same_iterator_category<Iterator1, std::random_access_iterator_tag>::value, void>::type
operator()(pstl::execution::unsequenced_policy, Iterator1 first1, Iterator1 last1, Iterator1 first2,
......
......@@ -29,8 +29,8 @@ using namespace TestUtils;
struct test_one_policy
{
#if __PSTL_ICC_18_VC141_TEST_SIMD_LAMBDA_RELEASE_BROKEN || __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_18_VC141_TEST_SIMD_LAMBDA_RELEASE_BROKEN || _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
template <typename Iterator1, typename Iterator2>
typename std::enable_if<is_same_iterator_category<Iterator1, std::random_access_iterator_tag>::value, void>::type
operator()(pstl::execution::unsequenced_policy, Iterator1 data_b, Iterator1 data_e, Iterator2 actual_b,
......@@ -103,7 +103,7 @@ main()
test<int32_t>();
test<uint16_t>();
test<float64_t>();
#if !__PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
#if !_PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN
test<wrapper<float64_t>>();
#endif
......
......@@ -69,8 +69,8 @@ struct test_one_policy
Iterator data_e;
test_one_policy(Iterator b, Iterator e) : data_b(b), data_e(e) {}
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
template <typename Iterator1>
typename std::enable_if<is_same_iterator_category<Iterator1, std::random_access_iterator_tag>::value, void>::type
operator()(pstl::execution::unsequenced_policy, Iterator1 actual_b, Iterator1 actual_e)
......
......@@ -27,8 +27,8 @@ using namespace TestUtils;
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename Iterator, typename Size, typename T, typename Predicate>
void
operator()(pstl::execution::unsequenced_policy, Iterator b, Iterator e, Size count, const T& value, Predicate pred)
......@@ -105,7 +105,7 @@ main()
test<int32_t>();
test<uint16_t>();
test<float64_t>();
#if !__PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
#if !_PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN
test<bool>();
#endif
......
......@@ -42,8 +42,8 @@ struct WithCmpOp
struct test_is_heap
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename Iterator, typename Predicate>
typename std::enable_if<is_same_iterator_category<Iterator, std::random_access_iterator_tag>::value, void>::type
operator()(pstl::execution::unsequenced_policy, Iterator first, Iterator last, Predicate pred)
......
......@@ -169,7 +169,7 @@ main()
{
test<uint16_t, float64_t>(std::less<float64_t>());
test<float32_t, int32_t>(std::greater<float32_t>());
#if !__PSTL_ICC_18_TEST_EARLY_EXIT_AVX_RELEASE_BROKEN
#if !_PSTL_ICC_18_TEST_EARLY_EXIT_AVX_RELEASE_BROKEN
test<float64_t, int32_t>([](const float64_t x, const int32_t y) { return x * x < y * y; });
#endif
test<LocalWrapper<int32_t>, LocalWrapper<int32_t>>(
......
......@@ -90,7 +90,7 @@ struct test_brick_partial_sort
if (m1 - first > 1)
{
auto complex = std::ceil(n * std::log(float32_t(m1 - first)));
#if __PSTL_USE_PAR_POLICIES
#if _PSTL_USE_PAR_POLICIES
auto p = tbb::this_task_arena::max_concurrency();
#else
auto p = 1;
......
......@@ -63,8 +63,8 @@ struct test_one_policy
: d_first(b1), d_last(e1), exp_first(b2), exp_last(e2)
{
}
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
template <typename InputIterator, typename Size, typename T, typename Compare>
void
operator()(pstl::execution::unsequenced_policy, InputIterator first, InputIterator last, Size n1, Size n2,
......
......@@ -101,8 +101,8 @@ compute_and_check(Iterator1 first, Iterator1 last, Iterator2 d_first, T, Functio
struct test_one_policy
{
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \
_PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specialization by policy type, in case of broken configuration
template <typename Iterator1, typename Iterator2, typename T, typename Function>
typename std::enable_if<is_same_iterator_category<Iterator1, std::random_access_iterator_tag>::value, void>::type
operator()(pstl::execution::unsequenced_policy, Iterator1 data_b, Iterator1 data_e, Iterator2 actual_b,
......
......@@ -61,7 +61,7 @@ test_long_form(T init, BinaryOp binary_op, F f)
struct test_two_short_forms
{
#if __PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN //dummy specialization by policy type, in case of broken configuration
#if _PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN //dummy specialization by policy type, in case of broken configuration
template <typename Iterator>
void
operator()(__pstl::execution::parallel_policy, Iterator first, Iterator last, Sum init, Sum expected)
......
......@@ -191,7 +191,7 @@ main()
for (int32_t mode = 0; mode < 2; ++mode)
{
inclusive = mode != 0;
#if !__PSTL_ICC_19_TEST_SIMD_UDS_WINDOWS_RELEASE_BROKEN
#if !_PSTL_ICC_19_TEST_SIMD_UDS_WINDOWS_RELEASE_BROKEN
// Test with highly restricted type and associative but not commutative operation
test_matrix<Matrix2x2<int32_t>, Matrix2x2<int32_t>>(Matrix2x2<int32_t>(), multiply_matrix<int32_t>,
Matrix2x2<int32_t>(-666, 666));
......
......@@ -172,7 +172,7 @@ main()
for (int32_t mode = 0; mode < 2; ++mode)
{
inclusive = mode != 0;
#if !__PSTL_ICC_19_TEST_SIMD_UDS_WINDOWS_RELEASE_BROKEN
#if !_PSTL_ICC_19_TEST_SIMD_UDS_WINDOWS_RELEASE_BROKEN
test_matrix<Matrix2x2<int32_t>, Matrix2x2<int32_t>>([](const Matrix2x2<int32_t> x) { return x; },
Matrix2x2<int32_t>(), multiply_matrix<int32_t>,
Matrix2x2<int32_t>(-666, 666));
......
......@@ -7,43 +7,43 @@
//
//===----------------------------------------------------------------------===//
#ifndef __PSTL_TEST_config_H
#define __PSTL_TEST_config_H
#ifndef _PSTL_TEST_CONFIG_H
#define _PSTL_TEST_CONFIG_H
#if defined(_MSC_VER) && defined(_DEBUG)
#define _SCL_SECURE_NO_WARNINGS //to prevent the compilation warning. Microsoft STL implementation has specific checking of an iterator range in DEBUG mode for the containers from the standard library.
#endif
#define __PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN \
#define _PSTL_ICC_16_17_TEST_REDUCTION_BOOL_TYPE_RELEASE_64_BROKEN \
(__x86_64 && !_DEBUG && __INTEL_COMPILER && __INTEL_COMPILER <= 1700 && !__APPLE__)
#define __PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN \
#define _PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN \
(!_DEBUG && __INTEL_COMPILER && \
(__INTEL_COMPILER < 1800 || (__INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 1)))
#define __PSTL_ICC_1800_TEST_MONOTONIC_RELEASE_64_BROKEN \
#define _PSTL_ICC_1800_TEST_MONOTONIC_RELEASE_64_BROKEN \
(__x86_64 && !_DEBUG && __INTEL_COMPILER && __INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 1)
#define __PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN \
#define _PSTL_ICC_17_TEST_MAC_RELEASE_32_BROKEN \
(__i386__ && !_DEBUG && __INTEL_COMPILER >= 1700 && __INTEL_COMPILER < 1800 && __APPLE__)
#define __PSTL_ICC_18_VC141_TEST_SIMD_LAMBDA_RELEASE_BROKEN \
#define _PSTL_ICC_18_VC141_TEST_SIMD_LAMBDA_RELEASE_BROKEN \
(!_DEBUG && __INTEL_COMPILER >= 1800 && __INTEL_COMPILER < 1900 && _MSC_VER == 1910)
#define __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN \
#define _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN \
(_M_IX86 && _DEBUG && __INTEL_COMPILER >= 1700 && __INTEL_COMPILER < 1800 && _MSC_VER >= 1900)
#define __PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN \
#define _PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN \
(_M_IX86 && _DEBUG && __INTEL_COMPILER >= 1600 && __INTEL_COMPILER < 1700 && _MSC_VER == 1900)
#define __PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN \
(__PSTL_USE_PAR_POLICIES && ((_M_X64 && _MSC_VER == 1900) || __x86_64) && !_DEBUG && __INTEL_COMPILER < 1700)
#define __PSTL_ICC_16_17_TEST_64_TIMEOUT (__x86_64 && __INTEL_COMPILER && __INTEL_COMPILER < 1800 && !__APPLE__)
#define __PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN (!_DEBUG && __INTEL_COMPILER && __INTEL_COMPILER == 1800)
#define __PSTL_CLANG_TEST_BIG_OBJ_DEBUG_32_BROKEN \
(__i386__ && PSTL_USE_DEBUG && __clang__ && __PSTL_CLANG_VERSION <= 90000)
#define __PSTL_ICC_16_17_18_TEST_UNIQUE_MASK_RELEASE_BROKEN \
#define _PSTL_ICC_16_VC14_TEST_PAR_TBB_RT_RELEASE_64_BROKEN \
(_PSTL_USE_PAR_POLICIES && ((_M_X64 && _MSC_VER == 1900) || __x86_64) && !_DEBUG && __INTEL_COMPILER < 1700)
#define _PSTL_ICC_16_17_TEST_64_TIMEOUT (__x86_64 && __INTEL_COMPILER && __INTEL_COMPILER < 1800 && !__APPLE__)
#define _PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN (!_DEBUG && __INTEL_COMPILER && __INTEL_COMPILER == 1800)
#define _PSTL_CLANG_TEST_BIG_OBJ_DEBUG_32_BROKEN \
(__i386__ && PSTL_USE_DEBUG && __clang__ && _PSTL_CLANG_VERSION <= 90000)
#define _PSTL_ICC_16_17_18_TEST_UNIQUE_MASK_RELEASE_BROKEN \
(!_DEBUG && __INTEL_COMPILER && \
(__INTEL_COMPILER < 1800 || (__INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 3)))
#define __PSTL_ICC_18_TEST_EARLY_EXIT_AVX_RELEASE_BROKEN \
#define _PSTL_ICC_18_TEST_EARLY_EXIT_AVX_RELEASE_BROKEN \
(!_DEBUG && __INTEL_COMPILER == 1800 && __AVX__ && !__AVX2__ && !__AVX512__)
#define __PSTL_ICC_19_TEST_IS_PARTITIONED_RELEASE_BROKEN \
#define _PSTL_ICC_19_TEST_IS_PARTITIONED_RELEASE_BROKEN \
(!PSTL_USE_DEBUG && (__linux__ || __APPLE__) && __INTEL_COMPILER == 1900)
#define __PSTL_ICL_19_VC14_VC141_TEST_SCAN_RELEASE_BROKEN \
#define _PSTL_ICL_19_VC14_VC141_TEST_SCAN_RELEASE_BROKEN \
(__INTEL_COMPILER == 1900 && _MSC_VER >= 1900 && _MSC_VER <= 1910)
#define __PSTL_ICC_19_TEST_SIMD_UDS_WINDOWS_RELEASE_BROKEN (__INTEL_COMPILER == 1900 && _MSC_VER && !_DEBUG)
#define _PSTL_ICC_19_TEST_SIMD_UDS_WINDOWS_RELEASE_BROKEN (__INTEL_COMPILER == 1900 && _MSC_VER && !_DEBUG)
#endif /* __PSTL_TEST_config_H */
#endif /* _PSTL_TEST_CONFIG_H */
......@@ -10,14 +10,15 @@
// File contains common utilities that tests rely on
// Do not #include <algorithm>, because if we do we will not detect accidental dependencies.
#include <sstream>
#include <iostream>
#include <atomic>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iterator>
#include <vector>
#include <atomic>
#include <memory>
#include <cstdint>
#include <sstream>
#include <vector>
#include "pstl_test_config.h"
......@@ -38,32 +39,30 @@ template <typename T>
class Sequence;
// Handy macros for error reporting
#define EXPECT_TRUE(condition, message) TestUtils::expect<true>(condition, __FILE__, __LINE__, message)
#define EXPECT_FALSE(condition, message) TestUtils::expect<false>(condition, __FILE__, __LINE__, message)
#define EXPECT_TRUE(condition, message) ::TestUtils::expect(true, condition, __FILE__, __LINE__, message)
#define EXPECT_FALSE(condition, message) ::TestUtils::expect(false, condition, __FILE__, __LINE__, message)
// Check that expected and actual are equal and have the same type.
#define EXPECT_EQ(expected, actual, message) TestUtils::expect_equal(expected, actual, __FILE__, __LINE__, message)
#define EXPECT_EQ(expected, actual, message) ::TestUtils::expect_equal(expected, actual, __FILE__, __LINE__, message)
// Check that sequences started with expected and actual and have had size n are equal and have the same type.
#define EXPECT_EQ_N(expected, actual, n, message) \
TestUtils::expect_equal(expected, actual, n, __FILE__, __LINE__, message)
::TestUtils::expect_equal(expected, actual, n, __FILE__, __LINE__, message)
// Issue error message from outstr, adding a newline.
// Real purpose of this routine is to have a place to hang a breakpoint.
static void
inline void
issue_error_message(std::stringstream& outstr)
{
outstr << std::endl;
std::cerr << outstr.str();
std::exit(EXIT_FAILURE);
}
template <bool B>
void
expect(bool condition, const char* file, int32_t line, const char* message)
inline void
expect(bool expected, bool condition, const char* file, int32_t line, const char* message)
{
// Templating this function is somewhat silly, but avoids the need to declare it static
// or have a separate translation unit.
if (condition != B)
if (condition != expected)
{
std::stringstream outstr;
outstr << "error at " << file << ":" << line << " - " << message;
......@@ -573,7 +572,7 @@ struct Matrix2x2
T a[2][2];
Matrix2x2() : a{{1, 0}, {0, 1}} {}
Matrix2x2(T x, T y) : a{{0, x}, {x, y}} {}
#if !__PSTL_ICL_19_VC14_VC141_TEST_SCAN_RELEASE_BROKEN
#if !_PSTL_ICL_19_VC14_VC141_TEST_SCAN_RELEASE_BROKEN
Matrix2x2(const Matrix2x2& m) : a{{m.a[0][0], m.a[0][1]}, {m.a[1][0], m.a[1][1]}} {}
Matrix2x2&
operator=(const Matrix2x2& m)
......@@ -607,13 +606,6 @@ multiply_matrix(const Matrix2x2<T>& left, const Matrix2x2<T>& right)
return result;
}
// Check that Intel(R) Threading Building Blocks header files are not used when parallel policies are off
#if !__PSTL_USE_PAR_POLICIES
#if defined(TBB_INTERFACE_VERSION)
#error The parallel backend is used while it should not (__PSTL_USE_PAR_POLICIES==0)
#endif
#endif
//============================================================================
// Adapters for creating different types of iterators.
//
......@@ -659,7 +651,7 @@ struct ReverseAdapter
iterator_type
operator()(Iterator it)
{
#if __PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT
#if _PSTL_CPP14_MAKE_REVERSE_ITERATOR_PRESENT
return std::make_reverse_iterator(it);
#else
return iterator_type(it);
......@@ -1052,10 +1044,8 @@ invoke_on_all_policies(Op op, T&&... rest)
// Try static execution policies
invoke_on_all_iterator_types()(seq, op, std::forward<T>(rest)...);
invoke_on_all_iterator_types()(unseq, op, std::forward<T>(rest)...);
#if __PSTL_USE_PAR_POLICIES
invoke_on_all_iterator_types()(par, op, std::forward<T>(rest)...);
invoke_on_all_iterator_types()(par_unseq, op, std::forward<T>(rest)...);
#endif
}
template <typename F>
......@@ -1201,7 +1191,7 @@ transform_reduce_serial(InputIterator first, InputIterator last, T init, BinaryO
static const char*
done()
{
#if __PSTL_TEST_SUCCESSFUL_KEYWORD
#if _PSTL_TEST_SUCCESSFUL_KEYWORD
return "done";
#else
return "passed";
......@@ -1238,7 +1228,7 @@ template <typename Policy, typename F>
static void
invoke_if(Policy&& p, F f)
{
#if __PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN
#if _PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || _PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN
__pstl::__internal::invoke_if_not(__pstl::__internal::allow_unsequenced<Policy>(), f);
#else
f();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment