Skip to content

parallel_scheduler for P2079 Section 4.1 User Facing API (ref #6601)#6655

Draft
charan-003 wants to merge 7 commits intoTheHPXProject:masterfrom
charan-003:p2079-section-4.1
Draft

parallel_scheduler for P2079 Section 4.1 User Facing API (ref #6601)#6655
charan-003 wants to merge 7 commits intoTheHPXProject:masterfrom
charan-003:p2079-section-4.1

Conversation

@charan-003
Copy link
Copy Markdown
Contributor

@charan-003 charan-003 commented Mar 27, 2025

Fixes #6601

Implement P2079R7 parallel_scheduler in HPX Core

This issue tracks the implementation of hpx::execution::experimental::parallel_scheduler in HPX core, aligning with P2079R7 (Parallel scheduler, Section 4.1) by wrapping thread_pool_policy_scheduler with hpx::launch policies. The goal is to provide a standards-compliant parallel scheduler with global access, cancellation support, task chaining, and bulk operations.

Implementation Checklist

  • Phase 1: Core Implementation

  • Implement hpx::execution::experimental::parallel_scheduler class per P2079R7 Section 4.1.

  • Add schedule() returning parallel_sender with sender_concept and completion_signatures:

  • Supports set_value_t(), set_stopped_t(), set_error_t(std::exception_ptr).

  • Wrap thread_pool_policy_scheduler with hpx::launch (async/sync policies).

  • Implement noexcept move/copy constructors and assignment operators.

  • Add operator== returning true for scheduler comparison.

  • Return forward_progress_guarantee::parallel via get_forward_progress_guarantee_t.

  • Implement then operation for task chaining with parallel_sender.

  • Code to rely on STDEXEC.

  • Phase 2: Bulk Support

  • Extend bulk_t customization to delegate to thread_pool_scheduler_bulk.

  • Implement bulk_sender for parallel bulk execution per P2079R7.

  • Support bulk_chunked and bulk_unchunked operations.

  • Phase 3: Replaceability API

  • Implement std::execution::system_context_replaceability namespace per P2079R7 Section 4.2.

  • Add query_parallel_scheduler_backend() returning shared_ptr<parallel_scheduler>.

  • Support link-time replaceability using weak symbols.

  • Implement receiver and bulk_item_receiver interfaces for frontend-backend interaction.

  • Ensure storage handling for scheduling operations.

@StellarBot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Mar 28, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.45% 94.84%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (6e3a98b) 193599 164650 85.05%
Head commit (1267582) 214837 (+21238) 183682 (+19032) 85.50% (+0.45%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6655) 155 147 94.84%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@hkaiser hkaiser added type: enhancement type: compatibility issue category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals labels Mar 28, 2025
Copy link
Copy Markdown
Contributor Author

@charan-003 charan-003 left a comment

Choose a reason for hiding this comment

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

clang format

Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler.hpp Outdated
@charan-003
Copy link
Copy Markdown
Contributor Author

Update:

  • Moved parallel_scheduler, parallel_sender, and bulk_sender to a new header: hpx/executors/parallel_scheduler.hpp
  • Removed related code from thread_pool_scheduler.hpp

@hkaiser — ready for re-review when convenient. Thanks for the guidance!

@charan-003
Copy link
Copy Markdown
Contributor Author

@hkaiser Can you please verify it now? I'm not sure why those 2 tests are failing.

@charan-003 charan-003 marked this pull request as ready for review April 1, 2025 19:46
Copy link
Copy Markdown
Contributor

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

Wow, I'm impressed! I have a couple of minor comments, though.

Comment thread libs/core/executors/CMakeLists.txt Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Apr 2, 2025

Also, you may want to move all types that are don't have to visible by users into namespace detail to avoid name clashes with other code.

Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Fixed
@charan-003
Copy link
Copy Markdown
Contributor Author

Also, you may want to move all types that are don't have to visible by users into namespace detail to avoid name clashes with other code.

Sure, I'll do that soon
Thank you so much

@charan-003
Copy link
Copy Markdown
Contributor Author

i'm not sure why it's failing for clang_format. i used clang-format -i ` to make sure it's in the format

@charan-003
Copy link
Copy Markdown
Contributor Author

@hkaiser
The parallel_bulk_operation_state implements a custom chunking strategy for bulk operations. It divides the workload into chunks based on the number of threads in the underlying thread_pool_scheduler’s pool (get_os_thread_count()), then schedules each chunk as a separate task using exec.execute()

The custom bulk chunking might duplicate functionality in thread_pool_scheduler_bulk.hpp

Offers a parallel execution option that leverages HPX’s thread pool, maintaining high performance for CPU-bound tasks.

While this version lacks P2079R7’s replaceability API (section 4.2) and many more, it could be extended to support it ( query_parallel_scheduler_backend()). This would let HPX users swap in custom schedulers (integrating with GPUs or other runtimes like oneTBB), enhancing HPX’s flexibility and composability

will try to work on this :))

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 3, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.30% 88.81%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (15afc8b) 244963 210174 85.80%
Head commit (7025dfd) 219167 (-25796) 187374 (-22800) 85.49% (-0.30%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6655) 268 238 88.81%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Apr 4, 2025

i'm not sure why it's failing for clang_format. i used clang-format -i ` to make sure it's in the format

The CI uses an older version of clang-format that does not always agree with newer versions on how to format things. Simply surround the offending lines with

// clang-format off
    ....
// clang-format on

to disable it checking those.

Comment thread libs/core/executors/include/hpx/executors/parallel_scheduler.hpp Outdated
@charan-003 charan-003 marked this pull request as draft April 8, 2025 09:20
@charan-003
Copy link
Copy Markdown
Contributor Author

charan-003 commented Apr 14, 2025

@hkaiser @isidorostsa
This version is about adding P2079R7 parallel_scheduler to HPX core

Implement parallel_scheduler wrapping thread_pool_policy_schedulerhpx::launch, aligning with P2079R7 user-facing API:

  • Add get_parallel_scheduler() for global access with async/sync policy selection.
  • Include parallel_sender with set_value_t(), set_stopped_t(), set_error_t(std::exception_ptr).
  • Support cancellation via stop token in operation_state::start_t.
  • Ensure parallel forward progress guarantee.
  • Add then operation for task chaining.
  • Add tests for progress, single task, cancellation, and exceptions.

replaceability API , bulk operations is the next thing i will keep working on.
Thank you for your support

@charan-003 charan-003 marked this pull request as ready for review April 16, 2025 12:45
Comment thread libs/core/executors/include/hpx/executors/experimental/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/experimental/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/experimental/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/tests/unit/parallel_scheduler_test.cpp Outdated
Comment thread libs/core/executors/include/hpx/executors/experimental/parallel_scheduler.hpp Outdated
@charan-003
Copy link
Copy Markdown
Contributor Author

@hkaiser @isidorostsa this version is using stdexec

I'm not sure of the failing test case, any hint on the failing cases ?

@charan-003
Copy link
Copy Markdown
Contributor Author

@hkaiser @isidorostsa
Does the current implementation, now relying on stdexec, meet our expectations? If so, I’ll proceed with implementing bulk support. Please confirm.

Comment thread libs/core/executors/include/hpx/executors/guided_pool_executor.hpp Outdated
@charan-003 charan-003 requested a review from isidorostsa May 5, 2025 12:15
Comment thread libs/core/executors/include/hpx/executors/experimental/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/guided_pool_executor.hpp Outdated
@charan-003 charan-003 force-pushed the p2079-section-4.1 branch from 10b035e to 94403fc Compare May 11, 2025 15:55
@charan-003 charan-003 requested a review from isidorostsa May 12, 2025 16:18
Copy link
Copy Markdown
Contributor

@isidorostsa isidorostsa left a comment

Choose a reason for hiding this comment

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

Great work! Some changes needed, but I am very happy to see you getting the hang of things!

Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/experimental/parallel_scheduler.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp Outdated
Comment thread libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp Outdated
@charan-003 charan-003 force-pushed the p2079-section-4.1 branch 3 times, most recently from 6814725 to 25416ac Compare July 9, 2025 01:52
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Aug 23, 2025

@charan-003 please rebase your branch onto top of master to resolve the merge conflicts.

@charan-003 charan-003 marked this pull request as draft August 23, 2025 17:18
@charan-003 charan-003 marked this pull request as ready for review March 20, 2026 15:52
@charan-003 charan-003 marked this pull request as draft March 20, 2026 16:30
@charan-003 charan-003 marked this pull request as ready for review March 21, 2026 17:54
@charan-003 charan-003 requested a review from isidorostsa March 21, 2026 17:54
@StellarBot
Copy link
Copy Markdown

Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each(=)(=)(=)

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T14:08:29+00:002026-03-24T20:16:57+00:00
HPX Commit0eeca86ae805e8
Envfile
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T09:15:24.034803-05:002026-03-24T21:50:21.236223-05:00

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch++

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T14:08:29+00:002026-03-24T20:16:57+00:00
HPX Commit0eeca86ae805e8
Envfile
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T09:17:15.638328-05:002026-03-24T21:52:02.565982-05:00

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add(=)(=)--
Stream Benchmark - Scale(=)----
Stream Benchmark - Triad(=)----
Stream Benchmark - Copy(=)+++++

Info

PropertyBeforeAfter
HPX Datetime2026-03-09T18:50:37+00:002026-03-24T20:16:57+00:00
HPX Commitba89f5dae805e8
Envfile
Clusternamerostamrostam
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Datetime2026-03-09T17:49:10.837937-05:002026-03-24T21:52:22.801134-05:00

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@charan-003 charan-003 marked this pull request as draft March 25, 2026 18:35
@StellarBot
Copy link
Copy Markdown

Performance test report

HPX Performance

Comparison

BENCHMARKFORK_JOIN_EXECUTORPARALLEL_EXECUTORSCHEDULER_EXECUTOR
For Each(=)(=)(=)

Info

PropertyBeforeAfter
HPX Commit0eeca86aba2418
HPX Datetime2026-03-09T14:08:29+00:002026-03-30T14:32:36+00:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T09:15:24.034803-05:002026-03-30T10:01:23.803300-05:00
Clusternamerostamrostam
Envfile

Comparison

BENCHMARKNO-EXECUTOR
Future Overhead - Create Thread Hierarchical - Latch++

Info

PropertyBeforeAfter
HPX Commit0eeca86aba2418
HPX Datetime2026-03-09T14:08:29+00:002026-03-30T14:32:36+00:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T09:17:15.638328-05:002026-03-30T10:03:04.947346-05:00
Clusternamerostamrostam
Envfile

Comparison

BENCHMARKFORK_JOIN_EXECUTOR_DEFAULT_FORK_JOIN_POLICY_ALLOCATORPARALLEL_EXECUTOR_DEFAULT_PARALLEL_POLICY_ALLOCATORSCHEDULER_EXECUTOR_DEFAULT_SCHEDULER_EXECUTOR_ALLOCATOR
Stream Benchmark - Add(=)(=)---
Stream Benchmark - Scale(=)----
Stream Benchmark - Triad(=)----
Stream Benchmark - Copy(=)++++

Info

PropertyBeforeAfter
HPX Commitba89f5daba2418
HPX Datetime2026-03-09T18:50:37+00:002026-03-30T14:32:36+00:00
Compiler/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8/opt/apps/llvm/18.1.8/bin/clang++ 18.1.8
Hostnamemedusa08.rostam.cct.lsu.edumedusa08.rostam.cct.lsu.edu
Datetime2026-03-09T17:49:10.837937-05:002026-03-30T10:03:25.284297-05:00
Clusternamerostamrostam
Envfile

Explanation of Symbols

SymbolMEANING
=No performance change (confidence interval within ±1%)
(=)Probably no performance change (confidence interval within ±2%)
(+)/(-)Very small performance improvement/degradation (≤1%)
+/-Small performance improvement/degradation (≤5%)
++/--Large performance improvement/degradation (≤10%)
+++/---Very large performance improvement/degradation (>10%)
?Probably no change, but quite large uncertainty (confidence interval with ±5%)
??Unclear result, very large uncertainty (±10%)
???Something unexpected…

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 66 complexity · 22 duplication

Metric Results
Complexity 66
Duplication 22

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented Apr 21, 2026

Just FYI: https://wg21.link/p4031

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

Labels

category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals type: compatibility issue type: enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement P2079 for HPX (System execution context)

5 participants