Skip to content

Commit 39dbeed

Browse files
committed
[oneDPL][ranges][merge] + fix for __serial_merge_out_lim call; +comments
1 parent 6915343 commit 39dbeed

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/oneapi/dpl/pstl/algorithm_impl.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -3020,11 +3020,16 @@ std::pair<_It1, _It2>
30203020
___merge_path_out_lim(_Tag, _ExecutionPolicy&& __exec, _It1 __it_1, _Index1 __n_1, _It2 __it_2, _Index2 __n_2,
30213021
_OutIt __it_out, _Index3 __n_out, _Comp __comp)
30223022
{
3023-
return __serial_merge_out_lim(__it_1, __it_1 + __n_1, __it_2, __it_2 + __n_2, __it_out, __it_out + __n_out, __comp);
3023+
//___merge_path_out_lim is called with reverse order: (2nd sequience, 1st sequience)
3024+
//__serial_merge_out_lim does merging in direct order: (1st sequience and 2nd sequience).
3025+
// So, the following call passes 1st sequience 2nd sequience in "a revert maner".
3026+
return __serial_merge_out_lim(__it_2, __it_2 + __n_2, __it_1, __it_1 + __n_1, __it_out, __it_out + __n_out, __comp);
30243027
}
30253028

30263029
inline constexpr std::size_t __merge_path_cut_off = 2000;
30273030

3031+
//Parallel version of ___merge_path_out_lim merges 1st sequience and 2nd sequience in "revert maner":
3032+
//the identical elements from 2nd sequience are being merged first.
30283033
template <typename _IsVector, typename _ExecutionPolicy, typename _It1, typename _Index1, typename _It2,
30293034
typename _Index2, typename _OutIt, typename _Index3, typename _Comp>
30303035
std::pair<_It1, _It2>

include/oneapi/dpl/pstl/algorithm_ranges_impl.h

+3
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ __pattern_merge(_Tag __tag, _ExecutionPolicy&& __exec, _R1&& __r1, _R2&& __r2, _
471471
if (__n_out == 0)
472472
return __return_type{__it_1, __it_2, __it_out};
473473

474+
//Parallel version of ___merge_path_out_lim merges 1st sequience and 2nd sequience in "revert maner":
475+
//the identical elements from 2nd sequience are being merged first.
476+
//So, the following call passes 1st sequience 2nd sequience in "a revert maner".
474477
std::pair __res = ___merge_path_out_lim(__tag, std::forward<_ExecutionPolicy>(__exec), __it_2, __n_2, __it_1, __n_1,
475478
__it_out, __n_out, __comp_2);
476479

0 commit comments

Comments
 (0)