diff --git a/include/oneapi/dpl/pstl/algorithm_impl.h b/include/oneapi/dpl/pstl/algorithm_impl.h index 3d7cdd91abc..3975bc12cc2 100644 --- a/include/oneapi/dpl/pstl/algorithm_impl.h +++ b/include/oneapi/dpl/pstl/algorithm_impl.h @@ -2949,44 +2949,44 @@ __pattern_remove_if(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, // merge //------------------------------------------------------------------------ -template +template std::pair __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, - /* __is_vector = */ std::false_type) + /* __is_vector = */ std::false_type) { - while(__it_1 != __it_1_e && __it_2 != __it_2_e) + while (__it_1 != __it_1_e && __it_2 != __it_2_e) { - if (__comp(*__it_1, *__it_2)) - { - *__it_out = *__it_1; - ++__it_out, ++__it_1; - } - else - { - *__it_out = *__it_2; - ++__it_out, ++__it_2; - } - if(__it_out == __it_out_e) + if (__comp(*__it_1, *__it_2)) + { + *__it_out = *__it_1; + ++__it_out, ++__it_1; + } + else + { + *__it_out = *__it_2; + ++__it_out, ++__it_2; + } + if (__it_out == __it_out_e) return {__it_1, __it_2}; } - if(__it_1 == __it_1_e) + if (__it_1 == __it_1_e) { - for(; __it_2 != __it_2_e && __it_out != __it_out_e; ++__it_2, ++__it_out) + for (; __it_2 != __it_2_e && __it_out != __it_out_e; ++__it_2, ++__it_out) *__it_out = *__it_2; } else { - for(; __it_1 != __it_1_e && __it_out != __it_out_e; ++__it_1, ++__it_out) + for (; __it_1 != __it_1_e && __it_out != __it_out_e; ++__it_1, ++__it_out) *__it_out = *__it_1; } return {__it_1, __it_2}; } -template +template std::pair __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, - /* __is_vector = */ std::true_type) + /* __is_vector = */ std::true_type) { return __unseq_backend::__simd_merge(__it_1, __it_1_e, __it_2, __it_2_e, __it_out, __it_out_e, __comp); } @@ -3023,21 +3023,21 @@ __pattern_merge(_Tag, _ExecutionPolicy&&, _ForwardIterator1 __first1, _ForwardIt typename _Tag::__is_vector{}); } -template +template std::pair<_It1, _It2> -__pattern_merge_2(_Tag, _ExecutionPolicy&& __exec, _It1 __it_1, _Index1 __n_1, _It2 __it_2, - _Index2 __n_2, _OutIt __it_out, _Index3 __n_out, _Comp __comp) +__pattern_merge_2(_Tag, _ExecutionPolicy&& __exec, _It1 __it_1, _Index1 __n_1, _It2 __it_2, _Index2 __n_2, + _OutIt __it_out, _Index3 __n_out, _Comp __comp) { return __brick_merge_2(__it_1, __it_1 + __n_1, __it_2, __it_2 + __n_2, __it_out, __it_out + __n_out, __comp, typename _Tag::__is_vector{}); } -template +template std::pair<_It1, _It2> __pattern_merge_2(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _It1 __it_1, _Index1 __n_1, _It2 __it_2, - _Index2 __n_2, _OutIt __it_out, _Index3 __n_out, _Comp __comp) + _Index2 __n_2, _OutIt __it_out, _Index3 __n_out, _Comp __comp) { using __backend_tag = typename __parallel_tag<_IsVector>::__backend_tag; @@ -3045,56 +3045,54 @@ __pattern_merge_2(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _It1 __i _It2 __it_res_2; __internal::__except_handler([&]() { - __par_backend::__parallel_for(__backend_tag{}, std::forward<_ExecutionPolicy>(__exec), _Index3(0), __n_out, - [=, &__it_res_1, &__it_res_2](_Index3 __i, _Index3 __j) - { - //a start merging point on the merge path; for each thread - _Index1 __r = 0; //row index - _Index2 __c = 0; //column index - - if(__i > 0) - { - //calc merge path intersection: - const _Index3 __d_size = - std::abs(std::max<_Index2>(0, __i - __n_2) - (std::min<_Index1>(__i, __n_1) - 1)) + 1; - - auto __get_row = [__i, __n_1](auto __d) - { return std::min<_Index1>(__i, __n_1) - __d - 1; }; - auto __get_column = [__i, __n_1](auto __d) - { return std::max<_Index1>(0, __i - __n_1 - 1) + __d + (__i / (__n_1 + 1) > 0 ? 1 : 0); }; - - oneapi::dpl::counting_iterator<_Index3> __it_d(0); - - auto __res_d = *std::lower_bound(__it_d, __it_d + __d_size, 1, - [&](auto __d, auto __val) { - auto __r = __get_row(__d); - auto __c = __get_column(__d); - - oneapi::dpl::__internal::__compare<_Comp, oneapi::dpl::identity> - __cmp{__comp, oneapi::dpl::identity{}}; - const auto __res = __cmp(__it_1[__r], __it_2[__c]) ? 1 : 0; - - return __res < __val; - } - ); - - //intersection point - __r = __get_row(__res_d); - __c = __get_column(__res_d); - ++__r; //to get a merge matrix ceil, lying on the current diagonal - } - - //serial merge n elements, starting from input x and y, to [i, j) output range - const auto __res = __brick_merge_2(__it_1 + __r, __it_1 + __n_1, - __it_2 + __c, __it_2 + __n_2, - __it_out + __i, __it_out + __j, __comp, _IsVector{}); - - if(__j == __n_out) - { - __it_res_1 = __res.first; - __it_res_2 = __res.second; - } - }, oneapi::dpl::__utils::__merge_algo_cut_off); //grainsize + __par_backend::__parallel_for( + __backend_tag{}, std::forward<_ExecutionPolicy>(__exec), _Index3(0), __n_out, + [=, &__it_res_1, &__it_res_2](_Index3 __i, _Index3 __j) { + //a start merging point on the merge path; for each thread + _Index1 __r = 0; //row index + _Index2 __c = 0; //column index + + if (__i > 0) + { + //calc merge path intersection: + const _Index3 __d_size = + std::abs(std::max<_Index2>(0, __i - __n_2) - (std::min<_Index1>(__i, __n_1) - 1)) + 1; + + auto __get_row = [__i, __n_1](auto __d) { return std::min<_Index1>(__i, __n_1) - __d - 1; }; + auto __get_column = [__i, __n_1](auto __d) { + return std::max<_Index1>(0, __i - __n_1 - 1) + __d + (__i / (__n_1 + 1) > 0 ? 1 : 0); + }; + + oneapi::dpl::counting_iterator<_Index3> __it_d(0); + + auto __res_d = *std::lower_bound(__it_d, __it_d + __d_size, 1, [&](auto __d, auto __val) { + auto __r = __get_row(__d); + auto __c = __get_column(__d); + + oneapi::dpl::__internal::__compare<_Comp, oneapi::dpl::identity> __cmp{__comp, + oneapi::dpl::identity{}}; + const auto __res = __cmp(__it_1[__r], __it_2[__c]) ? 1 : 0; + + return __res < __val; + }); + + //intersection point + __r = __get_row(__res_d); + __c = __get_column(__res_d); + ++__r; //to get a merge matrix ceil, lying on the current diagonal + } + + //serial merge n elements, starting from input x and y, to [i, j) output range + const auto __res = __brick_merge_2(__it_1 + __r, __it_1 + __n_1, __it_2 + __c, __it_2 + __n_2, + __it_out + __i, __it_out + __j, __comp, _IsVector{}); + + if (__j == __n_out) + { + __it_res_1 = __res.first; + __it_res_2 = __res.second; + } + }, + oneapi::dpl::__utils::__merge_algo_cut_off); //grainsize }); return {__it_res_1, __it_res_2}; diff --git a/include/oneapi/dpl/pstl/algorithm_ranges_impl.h b/include/oneapi/dpl/pstl/algorithm_ranges_impl.h index 2c7d9873079..dfc630fb1d5 100644 --- a/include/oneapi/dpl/pstl/algorithm_ranges_impl.h +++ b/include/oneapi/dpl/pstl/algorithm_ranges_impl.h @@ -448,9 +448,10 @@ auto __pattern_merge(_Tag __tag, _ExecutionPolicy&& __exec, _R1&& __r1, _R2&& __r2, _OutRange&& __out_r, _Comp __comp, _Proj1 __proj1, _Proj2 __proj2) { - using __return_type = std::ranges::merge_result, std::ranges::borrowed_iterator_t<_R2>, - std::ranges::borrowed_iterator_t<_OutRange>>; - + using __return_type = + std::ranges::merge_result, std::ranges::borrowed_iterator_t<_R2>, + std::ranges::borrowed_iterator_t<_OutRange>>; + auto __comp_2 = [__comp, __proj1, __proj2](auto&& __val1, auto&& __val2) { return std::invoke(__comp, std::invoke(__proj1, std::forward(__val1)), std::invoke(__proj2, std::forward(__val2)));}; @@ -467,10 +468,11 @@ __pattern_merge(_Tag __tag, _ExecutionPolicy&& __exec, _R1&& __r1, _R2&& __r2, _ auto __it_2 = std::ranges::begin(__r2); auto __it_out = std::ranges::begin(__out_r); - if(__n_out == 0) + if (__n_out == 0) return __return_type{__it_1, __it_2, __it_out}; - auto __res = __pattern_merge_2(__tag, std::forward<_ExecutionPolicy>(__exec), __it_2, __n_2, __it_1, __n_1, __it_out, __n_out, __comp_2); + auto __res = __pattern_merge_2(__tag, std::forward<_ExecutionPolicy>(__exec), __it_2, __n_2, __it_1, __n_1, + __it_out, __n_out, __comp_2); return __return_type{__res.second, __res.first, __it_out + __n_out}; } diff --git a/include/oneapi/dpl/pstl/glue_algorithm_ranges_impl.h b/include/oneapi/dpl/pstl/glue_algorithm_ranges_impl.h index f2fc3840632..048c3348cd6 100644 --- a/include/oneapi/dpl/pstl/glue_algorithm_ranges_impl.h +++ b/include/oneapi/dpl/pstl/glue_algorithm_ranges_impl.h @@ -1177,7 +1177,7 @@ merge(_ExecutionPolicy&& __exec, _Range1&& __rng1, _Range2&& __rng2, _Range3&& _ oneapi::dpl::__internal::__ranges::__pattern_merge( __dispatch_tag, ::std::forward<_ExecutionPolicy>(__exec), views::all_read(::std::forward<_Range1>(__rng1)), views::all_read(::std::forward<_Range2>(__rng2)), __view_res, __comp); - + return __view_res.size(); } diff --git a/include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h b/include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h index 7830a8545d0..472027a6f57 100644 --- a/include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h +++ b/include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h @@ -700,7 +700,7 @@ __pattern_merge(__hetero_tag<_BackendTag> __tag, _ExecutionPolicy&& __exec, _Ran ::std::forward<_ExecutionPolicy>(__exec)), oneapi::dpl::__internal::__brick_copy<__hetero_tag<_BackendTag>, _ExecutionPolicy>{}, ::std::forward<_Range2>(__rng2), ::std::forward<_Range3>(__rng3)); - return {0, __res}; + return {0, __res}; } if (__n2 == 0) @@ -714,9 +714,9 @@ __pattern_merge(__hetero_tag<_BackendTag> __tag, _ExecutionPolicy&& __exec, _Ran return {__res, 0}; } - auto __res = __par_backend_hetero::__parallel_merge(_BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec), - ::std::forward<_Range1>(__rng1), ::std::forward<_Range2>(__rng2), - ::std::forward<_Range3>(__rng3), __comp); + auto __res = __par_backend_hetero::__parallel_merge( + _BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec), ::std::forward<_Range1>(__rng1), + ::std::forward<_Range2>(__rng2), ::std::forward<_Range3>(__rng3), __comp); auto __val = __res.get(); return {__val.first, __val.second}; @@ -748,7 +748,7 @@ __pattern_merge(__hetero_tag<_BackendTag> __tag, _ExecutionPolicy&& __exec, _R1& using __return_t = std::ranges::merge_result, std::ranges::borrowed_iterator_t<_R2>, std::ranges::borrowed_iterator_t<_OutRange>>; - return __return_t{std::ranges::begin(__r1) + __res.first, std::ranges::begin(__r2) + __res.second, + return __return_t{std::ranges::begin(__r1) + __res.first, std::ranges::begin(__r2) + __res.second, std::ranges::begin(__out_r) + __n_out}; } #endif //_ONEDPL_CPP20_RANGES_PRESENT diff --git a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h index fc83f6ebb70..847880d8ef0 100644 --- a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h +++ b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h @@ -193,24 +193,27 @@ struct __parallel_merge_submitter<_IdType, __internal::__optional_kernel_name<_N using __val_t = _split_point_t<_IdType>; using __result_and_scratch_storage_t = __result_and_scratch_storage<_ExecutionPolicy, __val_t>; auto __p_res_storage = new __result_and_scratch_storage_t(__exec, 1, 0); - + // Save the raw pointer into a shared_ptr to return it in __future and extend the lifetime of the storage. std::shared_ptr<__result_and_scratch_storage_base> __p_result_base(__p_res_storage); - auto __event = __exec.queue().submit( - [&__rng1, &__rng2, &__rng3, __p_res_storage, __comp, __chunk, __steps, __n, __n1, __n2](sycl::handler& __cgh) { + auto __event = __exec.queue().submit([&__rng1, &__rng2, &__rng3, __p_res_storage, __comp, __chunk, __steps, __n, + __n1, __n2](sycl::handler& __cgh) { oneapi::dpl::__ranges::__require_access(__cgh, __rng1, __rng2, __rng3); - auto __result_acc = __p_res_storage->template __get_result_acc(__cgh, __dpl_sycl::__no_init{}); + auto __result_acc = + __p_res_storage->template __get_result_acc(__cgh, __dpl_sycl::__no_init{}); __cgh.parallel_for<_Name...>(sycl::range(__steps), [=](sycl::item __item_id) { auto __id = __item_id.get_linear_id(); const _IdType __i_elem = __id * __chunk; const auto __n_merge = std::min<_IdType>(__chunk, __n - __i_elem); - const auto __start = __find_start_point(__rng1, _IdType{0}, __n1, __rng2, _IdType{0}, __n2, __i_elem, __comp); - auto __ends = __serial_merge(__rng1, __rng2, __rng3, __start.first, __start.second, __i_elem, __n_merge, __n1, __n2, __comp, __n); + const auto __start = + __find_start_point(__rng1, _IdType{0}, __n1, __rng2, _IdType{0}, __n2, __i_elem, __comp); + auto __ends = __serial_merge(__rng1, __rng2, __rng3, __start.first, __start.second, __i_elem, __n_merge, + __n1, __n2, __comp, __n); - if(__id == __steps - 1) //the last WI does additional work + if (__id == __steps - 1) //the last WI does additional work { auto __res_ptr = __result_and_scratch_storage_t::__get_usm_or_buffer_accessor_ptr(__result_acc); *__res_ptr = __ends; @@ -243,7 +246,8 @@ struct __parallel_merge_submitter_large<_IdType, _CustomName, // Calculate nd-range parameters template nd_range_params - eval_nd_range_params(_ExecutionPolicy&& __exec, const _Range1& __rng1, const _Range2& __rng2, const std::size_t __n) const + eval_nd_range_params(_ExecutionPolicy&& __exec, const _Range1& __rng1, const _Range2& __rng2, + const std::size_t __n) const { // Empirical number of values to process per work-item const std::uint8_t __chunk = __exec.queue().get_device().is_cpu() ? 128 : 4; @@ -260,8 +264,8 @@ struct __parallel_merge_submitter_large<_IdType, _CustomName, // Calculation of split points on each base diagonal template sycl::event - eval_split_points_for_groups(_ExecutionPolicy&& __exec, _Range1&& __rng1, _Range2&& __rng2, _IdType __n, _Compare __comp, - const nd_range_params& __nd_range_params, + eval_split_points_for_groups(_ExecutionPolicy&& __exec, _Range1&& __rng1, _Range2&& __rng2, _IdType __n, + _Compare __comp, const nd_range_params& __nd_range_params, _Storage& __base_diagonals_sp_global_storage) const { const _IdType __n1 = __rng1.size(); @@ -311,7 +315,8 @@ struct __parallel_merge_submitter_large<_IdType, _CustomName, auto __base_diagonals_sp_global_acc = __base_diagonals_sp_global_storage.template __get_scratch_acc(__cgh); - auto __result_acc = __base_diagonals_sp_global_storage.template __get_result_acc(__cgh, __dpl_sycl::__no_init{}); + auto __result_acc = __base_diagonals_sp_global_storage.template __get_result_acc( + __cgh, __dpl_sycl::__no_init{}); __cgh.depends_on(__event); @@ -339,8 +344,8 @@ struct __parallel_merge_submitter_large<_IdType, _CustomName, } const auto __ends = __serial_merge(__rng1, __rng2, __rng3, __start.first, __start.second, __i_elem, - __nd_range_params.chunk, __n1, __n2, __comp, __n); - if(__global_idx == __nd_range_params.steps - 1) + __nd_range_params.chunk, __n1, __n2, __comp, __n); + if (__global_idx == __nd_range_params.steps - 1) { auto __res_ptr = _Storage::__get_usm_or_buffer_accessor_ptr(__result_acc); *__res_ptr = __ends; @@ -367,8 +372,8 @@ struct __parallel_merge_submitter_large<_IdType, _CustomName, // Create storage to save split-points on each base diagonal + 1 (for the right base diagonal in the last work-group) using __val_t = _split_point_t<_IdType>; - auto __p_base_diagonals_sp_global_storage = new __result_and_scratch_storage<_ExecutionPolicy, __val_t>(__exec, - 1, __nd_range_params.base_diag_count + 1); + auto __p_base_diagonals_sp_global_storage = new __result_and_scratch_storage<_ExecutionPolicy, __val_t>( + __exec, 1, __nd_range_params.base_diag_count + 1); // Save the raw pointer into a shared_ptr to return it in __future and extend the lifetime of the storage. std::shared_ptr<__result_and_scratch_storage_base> __p_result_and_scratch_storage_base( diff --git a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_utils.h b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_utils.h index 0fc8550f7a9..41f0de7f672 100644 --- a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_utils.h +++ b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_utils.h @@ -524,7 +524,8 @@ struct __usm_or_buffer_accessor struct __result_and_scratch_storage_base { virtual ~__result_and_scratch_storage_base() = default; - virtual std::size_t __get_data(sycl::event, std::size_t* __p_buf) const = 0; + virtual std::size_t + __get_data(sycl::event, std::size_t* __p_buf) const = 0; }; template @@ -666,7 +667,7 @@ struct __result_and_scratch_storage : __result_and_scratch_storage_base return __get_value(); } -private: + private: bool is_USM() const { @@ -678,7 +679,7 @@ struct __result_and_scratch_storage : __result_and_scratch_storage_base _T __get_value() const { - assert( __result_n == 1); + assert(__result_n == 1); if (__use_USM_host && __supports_USM_device) { return *(__result_buf.get()); @@ -695,7 +696,7 @@ struct __result_and_scratch_storage : __result_and_scratch_storage_base } } - template + template std::size_t __fill_data(std::pair<_Type, _Type>&& __p, std::size_t* __p_buf) const { @@ -704,7 +705,7 @@ struct __result_and_scratch_storage : __result_and_scratch_storage_base return 2; } - template + template std::size_t __fill_data(_Args&&...) const { @@ -712,7 +713,8 @@ struct __result_and_scratch_storage : __result_and_scratch_storage_base return 0; } - virtual std::size_t __get_data(sycl::event __event, std::size_t* __p_buf) const override + virtual std::size_t + __get_data(sycl::event __event, std::size_t* __p_buf) const override { if (is_USM()) __event.wait_and_throw(); @@ -761,7 +763,7 @@ class __future : private std::tuple<_Args...> __wait_and_get_value(const std::shared_ptr<__result_and_scratch_storage_base>& __p_storage) { std::size_t __buf[2] = {0, 0}; - auto __n = __p_storage->__get_data(__my_event, __buf); + auto __n = __p_storage->__get_data(__my_event, __buf); assert(__n == 2); return {__buf[0], __buf[1]}; diff --git a/include/oneapi/dpl/pstl/omp/parallel_for.h b/include/oneapi/dpl/pstl/omp/parallel_for.h index 917b3089059..7fd0ec78636 100644 --- a/include/oneapi/dpl/pstl/omp/parallel_for.h +++ b/include/oneapi/dpl/pstl/omp/parallel_for.h @@ -63,7 +63,10 @@ __parallel_for(oneapi::dpl::__internal::__omp_backend_tag, _ExecutionPolicy&&, _ // in any case (nested or non-nested) one parallel region is created and // only one thread creates a set of tasks _PSTL_PRAGMA(omp parallel) - _PSTL_PRAGMA(omp single nowait) { oneapi::dpl::__omp_backend::__parallel_for_body(__first, __last, __f, __grainsize); } + _PSTL_PRAGMA(omp single nowait) + { + oneapi::dpl::__omp_backend::__parallel_for_body(__first, __last, __f, __grainsize); + } } } diff --git a/include/oneapi/dpl/pstl/parallel_backend_tbb.h b/include/oneapi/dpl/pstl/parallel_backend_tbb.h index ac4ecfa69c9..3ae1ba31ba1 100644 --- a/include/oneapi/dpl/pstl/parallel_backend_tbb.h +++ b/include/oneapi/dpl/pstl/parallel_backend_tbb.h @@ -96,7 +96,8 @@ __parallel_for(oneapi::dpl::__internal::__tbb_backend_tag, _ExecutionPolicy&&, _ std::size_t __grainsize = 1) { tbb::this_task_arena::isolate([=]() { - tbb::parallel_for(tbb::blocked_range<_Index>(__first, __last, __grainsize), __parallel_for_body<_Index, _Fp>(__f)); + tbb::parallel_for(tbb::blocked_range<_Index>(__first, __last, __grainsize), + __parallel_for_body<_Index, _Fp>(__f)); }); } diff --git a/include/oneapi/dpl/pstl/unseq_backend_simd.h b/include/oneapi/dpl/pstl/unseq_backend_simd.h index e3379456837..cf60a762ba2 100644 --- a/include/oneapi/dpl/pstl/unseq_backend_simd.h +++ b/include/oneapi/dpl/pstl/unseq_backend_simd.h @@ -880,26 +880,27 @@ __simd_remove_if(_RandomAccessIterator __first, _DifferenceType __n, _UnaryPredi return __current + __cnt; } -template +template std::pair<_Iterator1, _Iterator2> -__simd_merge(_Iterator1 __x, _Iterator1 __x_e, _Iterator2 __y, _Iterator2 __y_e, _Iterator3 __i, _Iterator3 __j, _Comp __comp) +__simd_merge(_Iterator1 __x, _Iterator1 __x_e, _Iterator2 __y, _Iterator2 __y_e, _Iterator3 __i, _Iterator3 __j, + _Comp __comp) { _ONEDPL_PRAGMA_SIMD - for(_Iterator3 __k = __i; __k < __j; ++__k) + for (_Iterator3 __k = __i; __k < __j; ++__k) { - if(__x >= __x_e) + if (__x >= __x_e) { assert(__y < __y_e); *__k = *__y; ++__y; } - else if(__y >= __y_e) + else if (__y >= __y_e) { assert(__x < __x_e); *__k = *__x; ++__x; } - else if(std::invoke(__comp, *__x, *__y)) + else if (std::invoke(__comp, *__x, *__y)) { *__k = *__x; ++__x;