Skip to content

Implement P2300 bulk adapter for HPX executors#7240

Open
shivansh023023 wants to merge 1 commit intoTheHPXProject:masterfrom
shivansh023023:feat/p2300-bulk-integration
Open

Implement P2300 bulk adapter for HPX executors#7240
shivansh023023 wants to merge 1 commit intoTheHPXProject:masterfrom
shivansh023023:feat/p2300-bulk-integration

Conversation

@shivansh023023
Copy link
Copy Markdown
Contributor

P2300 bulk Integration for HPX Executors

Description

This PR implements the P2300 bulk sender adapter specifically for HPX's legacy executors, including the parallel_executor and sequenced_executor. By bridging the hpx::execution::experimental::bulk algorithm with HPX's internal bulk_sync_execute mechanism, this change ensures that data-parallel workloads are properly load-balanced and optimized using HPX's high-performance partitioners.

Key Technical Improvements:

  • Algorithmic Bridging: Successfully mapped the C++23 bulk sender to the underlying HPX execution engine for native parallel performance.
  • Robust tag_invoke Overloads: Implemented a full suite of connect_t overloads (supporting &&, &, and const&) to ensure compatibility with consumer algorithms like sync_wait.
  • Reference Stability: Utilized std::decay_t within the bulk_receiver to prevent reference collapsing and ensure the safety of deferred functional object execution.
  • Architectural Integrity: Resolved a potential circular dependency by situating the implementation within the executors module rather than the core execution module.

Proposed Changes

  • [New] libs/core/executors/include/hpx/executors/executor_scheduler_bulk.hpp: Implements executor_bulk_sender and executor_bulk_receiver.
  • [Modified] libs/core/executors/include/hpx/executors/executor_scheduler.hpp: Exposes get_completion_scheduler_t for ADL discovery.
  • [Modified] libs/core/executors/include/hpx/executors/parallel_executor.hpp & sequenced_executor.hpp: Integrated the new bulk headers.
  • [New Test] libs/core/executors/tests/unit/executor_algorithm_bulk.cpp: Comprehensive validation for sequential and parallel policies.

Background context

This work is part of the ongoing effort to modernize HPX's execution model to align with the C++23 Sender/Receiver (P2300) standard. Implementing bulk is a "Big Impact" milestone because it allows modern asynchronous pipelines to tap into the mature, multi-threaded performance of the HPX runtime.

Checklist

  • I have added a new feature and have added tests to go along with it.
  • I have verified the implementation with a local build of the executor_algorithm_bulk_test target.
  • I have ensured all includes are strictly alphabetically sorted to comply with the HPX inspect tool.

@shivansh023023 shivansh023023 requested a review from hkaiser as a code owner May 2, 2026 17:39
@StellarBot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@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.

- Integrated hpx::execution::experimental::bulk with internal bulk_sync_execute
- Implemented robust tag_invoke(connect_t) with full const-correctness
- Fixed receiver reference collapsing using std::decay_t
- Added executor_algorithm_bulk unit tests for parallel and sequenced execution
@shivansh023023 shivansh023023 force-pushed the feat/p2300-bulk-integration branch from 5cdcfbd to 7b3fc5f Compare May 2, 2026 17:50
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented May 3, 2026

@shivansh023023 Just FYI, before you invest more time into our old sender/receiver implementation: #7123 will soon remove almost all of our code related to this. Please focus your efforts on whatever stays after this has been merged.

@hkaiser hkaiser added category: senders/receivers Implementations of the p0443r14 / p2300 + p1897 proposals type: enhancement type: compatibility issue labels May 3, 2026
@shivansh023023
Copy link
Copy Markdown
Contributor Author

@hkaiser

Thank you for the heads-up regarding #7123. I appreciate the guidance to avoid spending effort on code that will soon be deprecated.

I will pause my work on the current P2300 bulk adapter and follow the progress of #7123 closely. Once that is merged, I’ll re-evaluate how to implement the bulk functionality within the new framework.

In the meantime, I’ll focus on finishing the review items for PR #7070 (local convenience header) and cleaning up any remaining issues on my other active PRs that are unaffected by the sender/receiver removal.

HPX_NO_UNIQUE_ADDRESS std::decay_t<Shape> shape_;
HPX_NO_UNIQUE_ADDRESS std::decay_t<F> f_;

#if defined(HPX_HAVE_STDEXEC)
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.

Please remove the case !defined(HPX_HAVE_STDEXEC) as we have dropped our own implementation of senders&receivers.


#include <hpx/config.hpp>
#include <hpx/assert.hpp>
#include <hpx/execution/queries/get_scheduler.hpp>
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.

This file does not exist anymore. Please adapt.

#include <hpx/executors/detail/index_queue_spawning.hpp>
#include <hpx/executors/execution_policy_mappings.hpp>
#include <hpx/executors/executor_scheduler.hpp>
#include <hpx/executors/executor_scheduler_bulk.hpp>
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.

Can we get away without pulling this into the executor file? Would forward declaring some of the stdexec types be sufficient?

#include <hpx/config.hpp>
#include <hpx/executors/execution_policy_mappings.hpp>
#include <hpx/executors/executor_scheduler.hpp>
#include <hpx/executors/executor_scheduler_bulk.hpp>
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.

Same here: can avoid pulling in the stdexec types here?

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