Use merge-path in merge/inplace_merge with host policies - #2809
dmitriy-sobolev wants to merge 23 commits into
Conversation
d87b8da to
0146705
Compare
There was a problem hiding this comment.
Pull request overview
Redirects host-policy merge operations to the shared merge-path algorithm.
Changes:
- Extracts merge-path intersection logic.
- Uses parallel merge-path partitioning for iterator and ranges APIs.
- Handles empty and bounded output ranges.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
algorithm_ranges_impl.h |
Implements bounded ranges merge-path execution. |
algorithm_impl.h |
Adds shared partitioning and redirects host merge. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8ba4149 to
339370e
Compare
88b9d1b to
c48f6d1
Compare
5e86df5 to
7ca3510
Compare
7cab853 to
52b695e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The small parallel inplace_merge path no longer preserves required execution-policy exception handling.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
include/oneapi/dpl/pstl/algorithm_impl.h:3309
- This serial-cutoff path runs outside
__except_handler, so a comparator exception escapes fromstd::inplace_mergeforpar/par_unseq. The previous backend path executed the merge inside__except_handler, and execution-policy overloads must terminate on non-bad_allocexceptions. Wrap this call so the small and large paths preserve the same exception semantics.
std::inplace_merge(__first, __middle, __last, __comp);
- Files reviewed: 10/10 changed files
- Comments generated: 1
- Review effort level: Balanced
a6608ab to
a1b1329
Compare
a1b1329 to
5608979
Compare
There was a problem hiding this comment.
🟡 Changes recommended
New fast paths bypass required host execution-policy exception handling.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
include/oneapi/dpl/pstl/algorithm_impl.h:3329
- The new preflight comparator calls, range-narrowing searches, and serial-cutoff merge all execute before the only
__except_handlerbelow. Consequently, a comparator exception can propagate from thepar/par_unseqoverload instead of terminating as required; previously comparator work was performed under the handler. Enclose the nontrivial algorithm body in__except_handler, retaining the empty-range early return if desired.
if (!__comp(*__middle, *(__middle - 1)))
- Files reviewed: 10/10 changed files
- Comments generated: 2
- Review effort level: Balanced
ee2b183 to
5afdd39
Compare
Most important changes:
dpl::mergeto the merge-path algorithm, already used bydpl::ranges::merge.inplace_mergefor bothdpl::inplace_mergeanddpl::ranges::inplace_merge.parallel_merge.Other:
Performance results
>1xis a speedup.The results is a geomean of the combinations of these runs:
int16_t,float,uint64_t,std::string(5-60 characters, lexicographical comparator),std::tuple<int, uint64_t>merged by the first element.n = n1 + n2, 4x per step;std::stringup to 16M.interleaved_equal(|A| = |B| = n/2),interleaved_unequal(|A| = 3n/4, |B| = n/4),non_interleaved(all of A precede all of B),few_unique(|A| = |B| = n/2, only 1% of the keys distinct).non_interleavedmeasurements are excluded from the summary for inplace_merge - this is a short-circuit now.Roofline for
dpl::merge:main/ rooflinePR/ rooflineint16_tint16_tfloatfloatuint64_tuint64_tstd::stringstd::stringstd::tuple<int, uint64_t>std::tuple<int, uint64_t>This is a "soft" roofline:
tbb::parallel_forwithmemcpy(trivial types) orstd::copy(std::string) and the same chunk size as the merge-path implementation. Geomean of all distributions and >=4M sizes.Investigation notes
I've tried these optimization strategies which have proved to be futile: