@@ -2950,7 +2950,8 @@ __pattern_remove_if(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec,
2950
2950
2951
2951
template <std::random_access_iterator It1, std::random_access_iterator It2, std::random_access_iterator ItOut, typename _Comp>
2952
2952
std::pair<It1, It2>
2953
- __brick_merge (It1 __it_1, It1 __it_1_e, It2 __it_2, It2 __it_2_e, ItOut __it_out, ItOut __it_out_e, _Comp __comp)
2953
+ __brick_merge_2 (It1 __it_1, It1 __it_1_e, It2 __it_2, It2 __it_2_e, ItOut __it_out, ItOut __it_out_e, _Comp __comp,
2954
+ /* __is_vector = */ std::false_type)
2954
2955
{
2955
2956
while (__it_1 != __it_1_e && __it_2 != __it_2_e)
2956
2957
{
@@ -2982,6 +2983,14 @@ __brick_merge(It1 __it_1, It1 __it_1_e, It2 __it_2, It2 __it_2_e, ItOut __it_out
2982
2983
return {__it_1, __it_2};
2983
2984
}
2984
2985
2986
+ template <std::random_access_iterator It1, std::random_access_iterator It2, std::random_access_iterator ItOut, typename _Comp>
2987
+ std::pair<It1, It2>
2988
+ __brick_merge_2 (It1 __it_1, It1 __it_1_e, It2 __it_2, It2 __it_2_e, ItOut __it_out, ItOut __it_out_e, _Comp __comp,
2989
+ /* __is_vector = */ std::true_type)
2990
+ {
2991
+ return __unseq_backend::__simd_merge (__it_1, __it_1_e, __it_2, __it_2_e, __it_out, __it_out_e, __comp);
2992
+ }
2993
+
2985
2994
template <class _ForwardIterator1 , class _ForwardIterator2 , class _OutputIterator , class _Compare >
2986
2995
_OutputIterator
2987
2996
__brick_merge (_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
@@ -3014,6 +3023,16 @@ __pattern_merge(_Tag, _ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIt
3014
3023
typename _Tag::__is_vector{});
3015
3024
}
3016
3025
3026
+ template <class _Tag , typename _ExecutionPolicy, typename _It1, typename _Index1, typename _It2,
3027
+ typename _Index2, typename _OutIt, typename _Index3, typename _Comp>
3028
+ std::pair<_It1, _It2>
3029
+ __pattern_merge_2 (_Tag, _ExecutionPolicy&& __exec, _It1 __it_1, _Index1 __n_1, _It2 __it_2,
3030
+ _Index2 __n_2, _OutIt __it_out, _Index3 __n_out, _Comp __comp)
3031
+ {
3032
+ return __brick_merge_2 (__it_1, __it_1 + __n_1, __it_2, __it_2 + __n_2, __it_out, __it_out + __n_out, __comp,
3033
+ typename _Tag::__is_vector{});
3034
+ }
3035
+
3017
3036
template <typename _IsVector, typename _ExecutionPolicy, typename _It1, typename _Index1, typename _It2,
3018
3037
typename _Index2, typename _OutIt, typename _Index3, typename _Comp>
3019
3038
std::pair<_It1, _It2>
@@ -3062,16 +3081,16 @@ __pattern_merge_2(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _It1 __i
3062
3081
}
3063
3082
3064
3083
// serial merge n elements, starting from input x and y, to [i, j) output range
3065
- auto __res = __brick_merge (__it_1 + __r, __it_1 + __n_1,
3084
+ auto __res = __brick_merge_2 (__it_1 + __r, __it_1 + __n_1,
3066
3085
__it_2 + __c, __it_2 + __n_2,
3067
- __it_out + __i, __it_out + __j, __comp);
3086
+ __it_out + __i, __it_out + __j, __comp, _IsVector{} );
3068
3087
3069
3088
if (__j == __n_out)
3070
3089
{
3071
3090
__it_res_1 = __res.first ;
3072
3091
__it_res_2 = __res.second ;
3073
3092
}
3074
- }, _ONEDPL_MERGE_CUT_OFF);
3093
+ }, _ONEDPL_MERGE_CUT_OFF); // grainsize
3075
3094
});
3076
3095
3077
3096
return {__it_res_1, __it_res_2};
@@ -3084,7 +3103,6 @@ __pattern_merge(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _Ran
3084
3103
_RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2,
3085
3104
_RandomAccessIterator3 __d_first, _Compare __comp)
3086
3105
{
3087
- #if 0
3088
3106
using __backend_tag = typename __parallel_tag<_IsVector>::__backend_tag;
3089
3107
3090
3108
return __internal::__except_handler ([&]() {
@@ -3097,13 +3115,6 @@ __pattern_merge(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _Ran
3097
3115
});
3098
3116
return __d_first + (__last1 - __first1) + (__last2 - __first2);
3099
3117
});
3100
- #else
3101
- auto __n_1 = __last1 - __first1;
3102
- auto __n_2 = __last2 - __first2;
3103
- auto __n_3 = __n_1 + __n_2;
3104
- __pattern_merge_2 (__tag, std::forward<_ExecutionPolicy>(__exec), __first2, __n_2, __first1, __n_1, __d_first, __n_3, __comp);
3105
- return __d_first + __n_3;
3106
- #endif
3107
3118
}
3108
3119
3109
3120
// ------------------------------------------------------------------------
0 commit comments