@@ -492,7 +492,7 @@ __brick_merge(It1 __it_1, It1 __it_1_e, It2 __it_2, It2 __it_2_e, ItOut __it_out
492
492
}
493
493
else
494
494
{
495
- assert (__it_2 == __it_2_e);
495
+ // assert(__it_2 == __it_2_e);
496
496
for (; __it_1 != __it_1_e && __it_out != __it_out_e; ++__it_1, ++__it_out)
497
497
*__it_out = *__it_1;
498
498
}
@@ -511,9 +511,14 @@ __pattern_merge(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _R1&& __r1
511
511
std::invoke (__proj1, std::forward<decltype (__val1)>(__val1)), std::invoke (__proj2,
512
512
std::forward<decltype (__val2)>(__val2)));};
513
513
514
- auto __n_1 = std::ranges::size (__r1);
515
- auto __n_2 = std::ranges::size (__r2);
516
- auto __n_out = std::min (__n_1 + __n_2, std::ranges::size (__out_r));
514
+ using _Index1 = std::ranges::range_difference_t <_R1>;
515
+ using _Index2 = std::ranges::range_difference_t <_R2>;
516
+ using _Index3 = std::ranges::range_difference_t <_OutRange>;
517
+
518
+ _Index1 __n_1 = std::ranges::size (__r1);
519
+ _Index2 __n_2 = std::ranges::size (__r2);
520
+
521
+ _Index3 __n_out = std::min<_Index3>(__n_1 + __n_2, std::ranges::size (__out_r));
517
522
518
523
auto __it_1 = std::ranges::begin (__r1);
519
524
auto __it_2 = std::ranges::begin (__r2);
@@ -523,8 +528,8 @@ __pattern_merge(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _R1&& __r1
523
528
std::ranges::borrowed_iterator_t <_R1> __it_res_2;
524
529
525
530
__internal::__except_handler ([&]() {
526
- __par_backend::__parallel_for (__backend_tag{}, ::std::forward<_ExecutionPolicy>(__exec), 0 , __n_out,
527
- [=, &__r1, &__r2, &__out_r, &__it_res_1, &__it_res_2](auto __i, auto __j)
531
+ __par_backend::__parallel_for (__backend_tag{}, ::std::forward<_ExecutionPolicy>(__exec), _Index3 ( 0 ) , __n_out,
532
+ [=, &__r1, &__r2, &__out_r, &__it_res_1, &__it_res_2](_Index3 __i, _Index3 __j)
528
533
{/* ...*/
529
534
530
535
// a start merging point on the merge path; for each thread
@@ -534,19 +539,18 @@ __pattern_merge(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _R1&& __r1
534
539
if (__i > 0 )
535
540
{
536
541
// calc merge path intersection:
537
- using _Index3 = std::ranges::range_difference_t <_OutRange>;
538
- _Index3 __d_size = std::abs (std::max (0 , __i - __n_2) - (std::min (__i, __n_1) - 1 )) + 1 ;
542
+ const _Index3 __d_size = std::abs (std::max<_Index2>(0 , __i - __n_2) - (std::min<_Index1>(__i, __n_1) - 1 )) + 1 ;
539
543
540
- auto __get_x = [__i, __n_1](auto __d) { return std::min (__i, __n_1) - __d; };
541
- auto __get_y = [__i, __n_1](auto __d) { return std::max (0 , __i - __n_1) + __d; };
544
+ auto __get_x = [__i, __n_1](auto __d) { return std::min<_Index1> (__i, __n_1) - __d; };
545
+ auto __get_y = [__i, __n_1](auto __d) { return std::max<_Index1> (0 , __i - __n_1) + __d; };
542
546
543
547
oneapi::dpl::counting_iterator<_Index3> __it_d (0 );
544
548
auto __res_d = *std::lower_bound (__it_d, __it_d + __d_size, 1 ,
545
- [](auto __d, auto __val) {
549
+ [& ](auto __d, auto __val) {
546
550
auto __x = __get_x (__d);
547
551
auto __y = __get_y (__d);
548
552
549
- const auto __res = __comp_2 (__r1[__x], __r2[__y]) ? 0 : 1
553
+ const auto __res = __comp_2 (__r1[__x], __r2[__y]) ? 0 : 1 ;
550
554
return __res < __val;
551
555
}
552
556
);
@@ -556,7 +560,7 @@ __pattern_merge(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _R1&& __r1
556
560
557
561
}
558
562
559
- const auto __n = __j - __i;
563
+ const _Index3 __n = __j - __i;
560
564
561
565
// serial merge n elements, starting from input x and y, to [i, j) output range
562
566
auto __res = __brick_merge (__it_1 + __x, __it_1 + __n_1,
@@ -647,7 +651,7 @@ __pattern_merge(__serial_tag</*IsVector*/std::false_type>, _ExecutionPolicy&& __
647
651
}
648
652
else
649
653
{
650
- assert (__it_2 == std::ranges::end (__r2);
654
+ // assert(__it_2 == std::ranges::end(__r2);
651
655
for (; __it_1 != std::ranges::end (__r1) && __it_out != std::ranges::end (__out_r); ++__it_1, ++__it_out)
652
656
*__it_out = *__it_1;
653
657
}
0 commit comments