Index: include/pstl/internal/algorithm_impl.h =================================================================== --- include/pstl/internal/algorithm_impl.h +++ include/pstl/internal/algorithm_impl.h @@ -23,8 +23,8 @@ #if __PSTL_USE_PAR_POLICIES #include "parallel_backend.h" -#endif #include "parallel_impl.h" +#endif namespace __pstl { @@ -59,6 +59,7 @@ return internal::brick_any_of(__first, __last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template bool pattern_any_of(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred, @@ -71,6 +72,7 @@ }); }); } +#endif // [alg.foreach] // for_each_n with no policy @@ -113,6 +115,7 @@ internal::brick_walk1(__first, __last, __f, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template void pattern_walk1(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Function __f, @@ -126,6 +129,7 @@ }); }); } +#endif template void @@ -135,6 +139,7 @@ __brick(__first, __last); } +#if __PSTL_USE_PAR_POLICIES template void pattern_walk_brick(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Brick __brick, @@ -145,6 +150,7 @@ [__brick](_ForwardIterator __i, _ForwardIterator __j) { __brick(__i, __j); }); }); } +#endif //------------------------------------------------------------------------ // walk1_n @@ -191,6 +197,7 @@ return __brick(__first, __n); } +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator pattern_walk_brick_n(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Size __n, _Brick __brick, @@ -203,6 +210,7 @@ return __first + __n; }); } +#endif //------------------------------------------------------------------------ // walk2 (pseudo) @@ -253,6 +261,7 @@ return internal::brick_walk2(__first1, __last1, __first2, __f, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator2 pattern_walk2(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, @@ -266,6 +275,7 @@ return __first2 + (__last1 - __first1); }); } +#endif template @@ -294,6 +304,7 @@ return __brick(__first1, __last1, __first2); } +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator2 pattern_walk2_brick(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, @@ -308,7 +319,9 @@ return __first2 + (__last1 - __first1); }); } +#endif +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator2 pattern_walk2_brick_n(_ExecutionPolicy&& __exec, _RandomAccessIterator1 __first1, _Size __n, @@ -323,6 +336,7 @@ return __first2 + __n; }); } +#endif template _ForwardIterator2 @@ -364,6 +378,7 @@ return internal::brick_walk3(__first1, __last1, __first2, __first3, __f, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator3 @@ -381,6 +396,7 @@ return __first3 + (__last1 - __first1); }); } +#endif //------------------------------------------------------------------------ // equal @@ -412,6 +428,7 @@ return internal::brick_equal(__first1, __last1, __first2, __p, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template bool @@ -427,6 +444,7 @@ }); }); } +#endif //------------------------------------------------------------------------ // find_if @@ -459,6 +477,7 @@ return internal::brick_find_if(__first, __last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator pattern_find_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, @@ -474,6 +493,7 @@ /*is_first=*/true); }); } +#endif //------------------------------------------------------------------------ // find_end @@ -600,6 +620,7 @@ return internal::brick_find_end(__first, __last, __s_first, __s_last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator1 @@ -626,6 +647,7 @@ }); } } +#endif //------------------------------------------------------------------------ // find_first_of @@ -656,6 +678,7 @@ return internal::brick_find_first_of(__first, __last, __s_first, __s_last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator1 @@ -672,6 +695,7 @@ std::less::difference_type>(), /*is_first=*/true); }); } +#endif //------------------------------------------------------------------------ // search @@ -702,6 +726,7 @@ return internal::brick_search(__first, __last, __s_first, __s_last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator1 @@ -727,6 +752,7 @@ }); } } +#endif //------------------------------------------------------------------------ // search_n @@ -757,6 +783,7 @@ return internal::brick_search_n(__first, __last, __count, __value, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator @@ -784,6 +811,7 @@ }); } } +#endif //------------------------------------------------------------------------ // copy_n @@ -989,6 +1017,7 @@ return internal::brick_copy_if(__first, __last, __result, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator @@ -1023,6 +1052,7 @@ // trivial sequence - use serial algorithm return brick_copy_if(__first, __last, __result, __pred, __is_vector); } +#endif //------------------------------------------------------------------------ // count @@ -1051,6 +1081,7 @@ return brick_count(__first, __last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template typename std::iterator_traits<_ForwardIterator>::difference_type pattern_count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, @@ -1066,6 +1097,7 @@ std::plus<_SizeType>()); }); } +#endif //------------------------------------------------------------------------ // unique @@ -1096,6 +1128,7 @@ 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 @@ -1172,7 +1205,9 @@ return __first + __m; }); } +#endif +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator pattern_unique(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred, @@ -1198,6 +1233,7 @@ }, __is_vector); } +#endif //------------------------------------------------------------------------ // unique_copy @@ -1254,6 +1290,7 @@ return unseq_backend::simd_calc_mask_2(__first, __last - __first, __mask, __pred); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator @@ -1303,6 +1340,7 @@ // trivial sequence - use serial algorithm return brick_unique_copy(__first, __last, __result, __pred, __is_vector); } +#endif //------------------------------------------------------------------------ // reverse @@ -1364,6 +1402,7 @@ brick_reverse(__first, __last, _is_vector); } +#if __PSTL_USE_PAR_POLICIES template void pattern_reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last, @@ -1375,6 +1414,7 @@ brick_reverse(__inner_first, __inner_last, __last - (__inner_first - __first), __is_vector); }); } +#endif //------------------------------------------------------------------------ // reverse_copy @@ -1408,6 +1448,7 @@ return internal::brick_reverse_copy(__first, __last, __d_first, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator pattern_reverse_copy(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last, @@ -1422,6 +1463,7 @@ }); return __d_first + __len; } +#endif //------------------------------------------------------------------------ // rotate @@ -1487,6 +1529,7 @@ return internal::brick_rotate(__first, __middle, __last, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator pattern_rotate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, @@ -1546,6 +1589,7 @@ }); } } +#endif //------------------------------------------------------------------------ // rotate_copy @@ -1576,6 +1620,7 @@ return internal::brick_rotate_copy(__first, __middle, __last, __result, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator pattern_rotate_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __middle, @@ -1605,6 +1650,7 @@ }); return __result + (__last - __first); } +#endif //------------------------------------------------------------------------ // is_partitioned @@ -1653,6 +1699,7 @@ return internal::brick_is_partitioned(__first, __last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template bool pattern_is_partitioned(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, @@ -1751,6 +1798,7 @@ }); } } +#endif //------------------------------------------------------------------------ // partition @@ -1781,6 +1829,7 @@ return internal::brick_partition(__first, __last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator pattern_partition(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _UnaryPredicate __pred, @@ -1848,6 +1897,7 @@ return __result.__pivot; }); } +#endif //------------------------------------------------------------------------ // stable_partition @@ -1878,6 +1928,7 @@ return internal::brick_stable_partition(__first, __last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _BidirectionalIterator pattern_stable_partition(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last, @@ -1930,6 +1981,7 @@ return __result.__pivot; }); } +#endif //------------------------------------------------------------------------ // partition_copy @@ -1965,6 +2017,7 @@ return internal::brick_partition_copy(__first, __last, __out_true, __out_false, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template std::pair<_OutputIterator1, _OutputIterator2> @@ -2003,6 +2056,7 @@ // trivial sequence - use serial algorithm return internal::brick_partition_copy(__first, __last, __out_true, __out_false, __pred, __is_vector); } +#endif //------------------------------------------------------------------------ // sort @@ -2017,6 +2071,7 @@ std::sort(__first, __last, __comp); } +#if __PSTL_USE_PAR_POLICIES template void pattern_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, @@ -2029,6 +2084,7 @@ __last - __first); }); } +#endif //------------------------------------------------------------------------ // stable_sort @@ -2042,6 +2098,7 @@ std::stable_sort(__first, __last, __comp); } +#if __PSTL_USE_PAR_POLICIES template void pattern_stable_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, @@ -2053,6 +2110,7 @@ _Compare __comp) { std::stable_sort(__first, __last, __comp); }); }); } +#endif //------------------------------------------------------------------------ // partial_sort @@ -2066,6 +2124,7 @@ std::partial_sort(__first, __middle, __last, __comp); } +#if __PSTL_USE_PAR_POLICIES template void pattern_partial_sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __middle, @@ -2084,6 +2143,7 @@ __n); }); } +#endif //------------------------------------------------------------------------ // partial_sort_copy @@ -2098,6 +2158,7 @@ return std::partial_sort_copy(__first, __last, __d_first, __d_last, __comp); } +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator pattern_partial_sort_copy(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, @@ -2166,6 +2227,7 @@ } }); } +#endif //------------------------------------------------------------------------ // adjacent_find @@ -2194,6 +2256,7 @@ return internal::brick_adjacent_find(__first, __last, __pred, __is_vector, __or_semantic); } +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator pattern_adjacent_find(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, @@ -2239,6 +2302,7 @@ ); }); } +#endif //------------------------------------------------------------------------ // nth_element @@ -2252,6 +2316,7 @@ std::nth_element(__first, __nth, __last, __comp); } +#if __PSTL_USE_PAR_POLICIES template void pattern_nth_element(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __nth, @@ -2297,6 +2362,7 @@ } } while (__x != __nth); } +#endif //------------------------------------------------------------------------ // fill, fill_n @@ -2325,6 +2391,7 @@ internal::brick_fill(__first, __last, __value, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator pattern_fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, @@ -2338,6 +2405,7 @@ return __last; }); } +#endif template _OutputIterator @@ -2397,6 +2465,7 @@ internal::brick_generate(__first, __last, __g, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator pattern_generate(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Generator __g, @@ -2410,6 +2479,7 @@ return __last; }); } +#endif template OutputIterator @@ -2476,6 +2546,7 @@ return internal::brick_remove_if(__first, __last, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator pattern_remove_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _UnaryPredicate __pred, @@ -2496,6 +2567,7 @@ }, __is_vector); } +#endif //------------------------------------------------------------------------ // merge @@ -2530,6 +2602,7 @@ return internal::brick_merge(__first1, __last1, __first2, __last2, __d_first, __comp, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator @@ -2544,6 +2617,7 @@ _Compare __comp) { return brick_merge(__f1, __l1, __f2, __l2, __f3, __comp, __is_vector); }); return __d_first + (__last1 - __first1) + (__last2 - __first2); } +#endif //------------------------------------------------------------------------ // inplace_merge @@ -2574,6 +2648,7 @@ internal::brick_inplace_merge(__first, __middle, __last, __comp, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template void pattern_inplace_merge(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __middle, @@ -2614,6 +2689,7 @@ }); }); } +#endif //------------------------------------------------------------------------ // includes @@ -2628,6 +2704,7 @@ return std::includes(__first1, __last1, __first2, __last2, __comp); } +#if __PSTL_USE_PAR_POLICIES template bool pattern_includes(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, @@ -2682,9 +2759,11 @@ }); }); } +#endif constexpr auto __set_algo_cut_off = 1000; +#if __PSTL_USE_PAR_POLICIES template _OutputIterator @@ -2773,7 +2852,9 @@ return __result + __m; }); } +#endif +#if __PSTL_USE_PAR_POLICIES //a shared parallel pattern for 'pattern_set_union' and 'pattern_set_symmetric_difference' template @@ -2888,6 +2969,7 @@ __comp, [](_DifferenceType __n, _DifferenceType __m) { return __n + __m; }, __set_union_op, __is_vector); } +#endif //------------------------------------------------------------------------ // set_union @@ -2922,6 +3004,7 @@ return internal::brick_set_union(__first1, __last1, __first2, __last2, __result, __comp, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator @@ -2945,6 +3028,7 @@ _Compare __comp) { return std::set_union(__first1, __last1, __first2, __last2, __result, __comp); }, __is_vector); } +#endif //------------------------------------------------------------------------ // set_intersection @@ -2979,6 +3063,7 @@ return internal::brick_set_intersection(__first1, __last1, __first2, __last2, __result, __comp, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator @@ -3040,6 +3125,7 @@ // [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 @@ -3074,6 +3160,7 @@ return internal::brick_set_difference(__first1, __last1, __first2, __last2, __result, __comp, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator @@ -3135,6 +3222,7 @@ // use serial algorithm return std::set_difference(__first1, __last1, __first2, __last2, __result, __comp); } +#endif //------------------------------------------------------------------------ // set_symmetric_difference @@ -3170,6 +3258,7 @@ __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _OutputIterator @@ -3194,6 +3283,7 @@ }, __is_vector); } +#endif //------------------------------------------------------------------------ // is_heap_until @@ -3254,6 +3344,7 @@ [&__comp](_RandomAccessIterator __it, _DifferenceType __i) { return __comp(__it[(__i - 1) / 2], __it[__i]); }); } +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator pattern_is_heap_until(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, @@ -3271,6 +3362,7 @@ std::less::difference_type>(), /*is_first=*/true); }); } +#endif //------------------------------------------------------------------------ // min_element @@ -3304,6 +3396,7 @@ return internal::brick_min_element(__first, __last, __comp, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _RandomAccessIterator pattern_min_element(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, @@ -3325,6 +3418,7 @@ }); }); } +#endif //------------------------------------------------------------------------ // minmax_element @@ -3358,6 +3452,7 @@ return internal::brick_minmax_element(__first, __last, __comp, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template std::pair<_ForwardIterator, _ForwardIterator> pattern_minmax_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp, @@ -3384,6 +3479,7 @@ }); }); } +#endif //------------------------------------------------------------------------ // mismatch @@ -3429,6 +3525,7 @@ return internal::brick_mismatch(__first1, __last1, __first2, __last2, __pred, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template std::pair<_RandomAccessIterator1, _RandomAccessIterator2> @@ -3449,6 +3546,7 @@ return std::make_pair(__result, __first2 + (__result - __first1)); }); } +#endif //------------------------------------------------------------------------ // lexicographical_compare @@ -3507,6 +3605,7 @@ return internal::brick_lexicographical_compare(__first1, __last1, __first2, __last2, __comp, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template bool pattern_lexicographical_compare(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, @@ -3550,6 +3649,7 @@ } } } +#endif } // namespace internal } // namespace __pstl Index: include/pstl/internal/numeric_impl.h =================================================================== --- include/pstl/internal/numeric_impl.h +++ include/pstl/internal/numeric_impl.h @@ -64,6 +64,7 @@ return brick_transform_reduce(__first1, __last1, __first2, __init, __binary_op1, __binary_op2, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _Tp @@ -86,6 +87,7 @@ }); }); } +#endif //------------------------------------------------------------------------ // transform_reduce (version with unary and binary functions) @@ -124,6 +126,7 @@ return brick_transform_reduce(__first, __last, __init, __binary_op, __unary_op, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _Tp @@ -140,6 +143,7 @@ }); }); } +#endif //------------------------------------------------------------------------ // transform_exclusive_scan @@ -225,6 +229,7 @@ .first; } +#if __PSTL_USE_PAR_POLICIES template typename std::enable_if::value, _OutputIterator>::type @@ -253,7 +258,9 @@ return __result + (__last - __first); }); } +#endif +#if __PSTL_USE_PAR_POLICIES template typename std::enable_if::value, _OutputIterator>::type @@ -289,6 +296,7 @@ return __result + (__last - __first); }); } +#endif //------------------------------------------------------------------------ // adjacent_difference @@ -329,6 +337,7 @@ return internal::brick_adjacent_difference(__first, __last, __d_first, __op, __is_vector); } +#if __PSTL_USE_PAR_POLICIES template _ForwardIterator2 @@ -352,6 +361,7 @@ }); return __d_first + (__last - __first); } +#endif } // namespace internal } // namespace __pstl