Skip to content

Implement P2300 get_scheduler bridge for executors#7238

Open
shivansh023023 wants to merge 3 commits intoTheHPXProject:masterfrom
shivansh023023:feat/executor-p2300-adapter
Open

Implement P2300 get_scheduler bridge for executors#7238
shivansh023023 wants to merge 3 commits intoTheHPXProject:masterfrom
shivansh023023:feat/executor-p2300-adapter

Conversation

@shivansh023023
Copy link
Copy Markdown
Contributor

@shivansh023023 shivansh023023 commented May 2, 2026

PR Description: Implement P2300 get_scheduler Bridge for HPX Executors

Fixes

This PR addresses the ongoing effort to align HPX Executors with the C++23 P2300 (std::execution) proposal.

Proposed Changes

  • Added executor_scheduler adapter: Implemented a new bridge header libs/core/executors/include/hpx/executors/executor_scheduler.hpp that provides a P2300-compatible scheduler interface for existing HPX executors.
  • Enabled get_scheduler for sequenced_executor: Added a tag_invoke overload for hpx::execution::experimental::get_scheduler in sequenced_executor.hpp, allowing it to be used directly in sender/receiver pipelines.
  • Implemented Sender/Operation State Logic: Created the internal structures executor_scheduler_sender and executor_scheduler_operation_state to manage task dispatching via the executor.
  • Added Unit Test: Introduced libs/core/executors/tests/unit/executor_scheduler.cpp to verify the end-to-end flow: schedule(get_scheduler(exec)) | then(...).

This work is part of the GSoC 2026 project: "Modernizing HPX Executors for P2300 Compatibility."

The implementation bridges the gap between traditional HPX executors and the newer sender/receiver paradigm. By providing an executor_scheduler adapter, we ensure that any standard HPX executor can be seamlessly integrated into P2300-style asynchronous pipelines.

Note: The implementation follows the architectural patterns established in the libs/core/executors module. While local linking encountered environment-specific hurdles regarding the __wrap_main entry point during the build process, the logic and header structures have been verified against the HPX core standards and are ready for CI validation.

Checklist

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

@shivansh023023 shivansh023023 requested a review from hkaiser as a code owner May 2, 2026 00:23
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 2, 2026

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.

@StellarBot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@shivansh023023 shivansh023023 force-pushed the feat/executor-p2300-adapter branch from 75fba86 to d384fd9 Compare May 2, 2026 07:40
@hkaiser hkaiser added type: enhancement type: compatibility issue category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals labels May 2, 2026
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented May 3, 2026

@shivansh023023 This is really a very interesting PR connecting our executor infrastructure to senders&receivers. Thanks for this.

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.

Could you please add get_scheduler_t overloads for the other executors as well?

Comment on lines +111 to +114
template <typename Exec,
typename = std::enable_if_t<
!std::is_same_v<std::decay_t<Exec>, executor_scheduler>>>
explicit executor_scheduler(Exec&& exec)
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.

Could you please use requires() instead of SFINAE:

Suggested change
template <typename Exec,
typename = std::enable_if_t<
!std::is_same_v<std::decay_t<Exec>, executor_scheduler>>>
explicit executor_scheduler(Exec&& exec)
template <typename Exec>
requires(!std::is_same_v<std::decay_t<Exec>, executor_scheduler>)
explicit executor_scheduler(Exec&& exec)

@shivansh023023
Copy link
Copy Markdown
Contributor Author

Thanks for the review, @hkaiser ! I've gone ahead and addressed your suggestions:

Modernization: Refactored the executor_scheduler constructor to use a C++20 requires clause, replacing the previous SFINAE/enable_if_t pattern.

Expanded Bridge: I’ve expanded the get_scheduler support across the executor ecosystem. This now includes parallel_executor (covering both policy variants) and restricted_thread_pool_executor.

Circular Dependencies: To avoid include loops with parallel_executor, I’ve implemented those specific tag_invoke overloads as free functions at the bottom of the header.

Verification: Updated the unit tests to verify scheduling through the bridge for these additional executors. Locally, executor_scheduler_test is passing cleanly.

@shivansh023023
Copy link
Copy Markdown
Contributor Author

By the way @hkaiser Since I'm looking to prepare specifically for GSoC 2027 and want to become a long-term contributor to HPX, I was wondering if you could suggest any specific areas or sub-modules of the library that are currently high-priority or in need of modernization?

I'd love to start focusing my efforts on a specific domain now so I can build the necessary expertise to make a meaningful impact by the time the next GSoC cycle begins. Any guidance on where a student's focus would be most valuable would be greatly appreciated!
or can i create a thread on the discord channel to discuss about this ?

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.

3 participants