Skip to content

Size the algorithms that call a comparison more than once per element - #7966

Draft
hkaiser wants to merge 1 commit into
task-size-predicatesfrom
task-size-multi-call
Draft

hkaiser wants to merge 1 commit into
task-size-predicatesfrom
task-size-multi-call

Conversation

@hkaiser

@hkaiser hkaiser commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

This is the third part of the task-size series (#7926, #7946, #7947), it applies on top of #7947.

min_element, max_element, minmax_element and lexicographical_compare give an iteration the size of the comparison of two elements. minmax_element makes 1.5 comparisons per element and lexicographical_compare two, which stays within the size of one comparison. find_end and search do the same: most positions don't match the first element of the sequence. find_first_of compares an element with each element of the second range and search_n with count elements, so an iteration has the size of that many comparisons, computed at run time with bulk_task_size.

As for the other algorithms, a size given to the comparison wins, a comparison without a size has none, and a projection hides the type the comparison is called with. includes and the set algorithms stay unsized.

Tests: the new task_sizes_multi_call test and the existing tests of the changed algorithms pass on Windows.

min_element, max_element, minmax_element, lexicographical_compare,
find_end and search give an iteration the size of the comparison of two
elements. find_first_of and search_n compare an element with each element
of the second range or with count elements, an iteration has the size of
that many comparisons.

Signed-off-by: Hartmut Kaiser <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b49e58bb-8f21-40c1-859d-ab195f7cd311
Commits

Reviewing files that changed from the base of the PR and between d5720bb and 78ec4d7.

Files selected for processing: 6
  • libs/core/algorithms/include/hpx/parallel/algorithms/detail/search.hpp
  • libs/core/algorithms/include/hpx/parallel/algorithms/find.hpp
  • libs/core/algorithms/include/hpx/parallel/algorithms/lexicographical_compare.hpp
  • libs/core/algorithms/include/hpx/parallel/algorithms/minmax.hpp
  • libs/core/algorithms/tests/unit/task_sizes/CMakeLists.txt
  • libs/core/algorithms/tests/unit/task_sizes/task_sizes_multi_call.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

Summary

Summary by CodeRabbit

  • Performance
    • Improved workload sizing for parallel search, comparison, and min/max algorithms. This helps the runtime better account for the work involved, including searches over larger ranges.
  • Tests
    • Added coverage for task-size estimates across these algorithms, including cases where argument or range sizes affect the estimate.

Parallel search, comparison, and extrema algorithms now calculate task-size estimates and pass them to the partitioner. A new unit test checks task-size classifications for these algorithms and several callable and projection types.

Changes: Parallel algorithm task-size estimates

Layer / File(s) Summary
Estimate and validate partition task sizes
libs/core/algorithms/include/hpx/parallel/algorithms/detail/search.hpp, libs/core/algorithms/include/hpx/parallel/algorithms/find.hpp, libs/core/algorithms/include/hpx/parallel/algorithms/lexicographical_compare.hpp, libs/core/algorithms/include/hpx/parallel/algorithms/minmax.hpp, libs/core/algorithms/tests/unit/task_sizes/*
The parallel algorithms derive task-size estimates from callable and projected argument types, with range or count scaling for find_first_of and search_n. They pass the estimates to the partitioner through with_task_size. The new unit test checks task-size classifications.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Possibly related issues

Possibly related PRs

Suggested labels: type: optimization, category: tests

Suggested reviewers: v4xsh

Merge Risk: Minimal · up to 78ec4

No actionable merge-blocking risk was established for the new task-size hints.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: adding task-size estimates to algorithms that perform multiple comparisons per element.
Description check Passed The description directly explains the affected algorithms, task-size behavior, precedence rules, unchanged algorithms, and test results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 9 functions across 5 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant