Skip to content

Improvements to set_intersection logic#2583

Open
danhoeflinger wants to merge 9 commits intomainfrom
dev/dhoeflin/fix_set_intersection_logic
Open

Improvements to set_intersection logic#2583
danhoeflinger wants to merge 9 commits intomainfrom
dev/dhoeflin/fix_set_intersection_logic

Conversation

@danhoeflinger
Copy link
Copy Markdown
Contributor

Improves the set_intersection parallel algorithm logic to be more efficient and correct when selecting which input range to partition.

Now we select the trimming strategy which minimizes the total data and always parallelize along the larger dimension.
This logic was oddly configured previously.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the set_intersection parallel algorithm to improve efficiency by selecting the optimal trimming strategy (which minimizes total data) and parallelizing along the larger range dimension. The changes affect two implementation files with parallel algorithms for set intersection operations.

Changes:

  • Refactored trimming strategy selection to choose the strategy that trims more elements
  • Changed parallelization decision to always partition the larger range after trimming
  • Changed variable types from auto to explicit std::size_t for size calculations
  • Simplified cutoff logic to check total work after applying the optimal trimming strategy

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

File Description
include/oneapi/dpl/pstl/algorithm_ranges_impl.h Updated __pattern_set_intersection to use improved trimming and parallelization logic for ranges-based interface; contains critical bugs in the implementation
include/oneapi/dpl/pstl/algorithm_impl.h Updated __pattern_set_intersection to use improved trimming and parallelization logic for iterator-based interface; complete implementation with minor issues

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/oneapi/dpl/pstl/algorithm_ranges_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_ranges_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_ranges_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_ranges_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_ranges_impl.h
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated

const auto __m2 = __last2 - __left_bound_seq_2 + __n1;
if (__m2 > __set_algo_cut_off)
const std::size_t __total_work = __n1 + __n2;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is rather a common type for _DifferenceType1 and _DifferenceType2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread include/oneapi/dpl/pstl/algorithm_ranges_impl.h Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Copy link
Copy Markdown
Contributor

@SergeyKopienko SergeyKopienko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think make sense also to think about __set_union_construct calls too.

Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_ranges_impl.h
@danhoeflinger
Copy link
Copy Markdown
Contributor Author

danhoeflinger commented Feb 19, 2026

I think make sense also to think about __set_union_construct calls too.

I created an issue, Id rather deal with them independently.
#2584

Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
Comment thread include/oneapi/dpl/pstl/algorithm_impl.h Outdated
danhoeflinger and others added 9 commits February 27, 2026 10:24
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Co-authored-by: Sergey Kopienko <sergey.kopienko@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
@danhoeflinger danhoeflinger force-pushed the dev/dhoeflin/fix_set_intersection_logic branch from 7516458 to 2427032 Compare February 27, 2026 15:24
@danhoeflinger danhoeflinger added this to the 2022.13.0 milestone Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants