Skip to content

async_mpi: harden transform_mpi callback helpers with static_asserts on receiver shape#7277

Merged
hkaiser merged 2 commits into
TheHPXProject:masterfrom
guptapratykshh:feat/async-mpi-polling-native
May 19, 2026
Merged

async_mpi: harden transform_mpi callback helpers with static_asserts on receiver shape#7277
hkaiser merged 2 commits into
TheHPXProject:masterfrom
guptapratykshh:feat/async-mpi-polling-native

Conversation

@guptapratykshh
Copy link
Copy Markdown
Contributor

Proposed Changes

  • Add static_assert guards to the two transform_mpi callback helpers in transform_mpi.hpp (set_value_request_callback_void and set_value_request_callback_non_void) that check the receiver-shape contract at the helper boundary: the void path asserts the receiver is invocable as set_value(rcv), the non-void path asserts both that InvokeResult is non-void and that the receiver is invocable as set_value(rcv, res).
  • Add a contract comment on each helper documenting the single-move invariant on Ts... and the fact that the captured lambda fires on the polling thread (not the receiver's preferred completion scheduler).
  • Pure additive hardening: no API change, no removed code, ~44 LOC of static_asserts + comments in a single file.

Any background context you want to provide?

Checklist

Not all points below apply to all pull requests.

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

…on receiver shape

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 19, 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.

@guptapratykshh guptapratykshh force-pushed the feat/async-mpi-polling-native branch from 16eee05 to 810da06 Compare May 19, 2026 13:13
@StellarBot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented May 19, 2026

Could you please add compile-time only tests that make the asserts fire? You can do that using the HPX testing build system infrastructure. Please look around in other modules to see examples.

Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
@guptapratykshh guptapratykshh force-pushed the feat/async-mpi-polling-native branch from d1c153c to e2f837c Compare May 19, 2026 14:08
@guptapratykshh guptapratykshh marked this pull request as ready for review May 19, 2026 14:09
@guptapratykshh guptapratykshh requested a review from hkaiser as a code owner May 19, 2026 14:09
Copilot AI review requested due to automatic review settings May 19, 2026 14:09
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

Adds defensive static_asserts at the boundary of the two transform_mpi completion-callback helpers (set_value_request_callback_void / set_value_request_callback_non_void) so receiver-shape misuse fails with a clear diagnostic at the helper rather than deep inside the captured lambda, and documents the single-move and polling-thread invariants. Two FAILURE_EXPECTED compile-only tests are added to lock in the new diagnostics.

Changes:

  • Add receiver-shape (and non-void result) static_asserts plus contract comments to both callback helpers in transform_mpi.hpp.
  • Add two negative compile-only tests that pass mismatched receivers and are expected to fail compilation.
  • Wire the new tests through libs/core/async_mpi/tests/unit/CMakeLists.txt behind HPX_WITH_COMPILE_ONLY_TESTS / HPX_WITH_FAIL_COMPILE_TESTS.

Reviewed changes

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

File Description
libs/core/async_mpi/include/hpx/async_mpi/transform_mpi.hpp Adds static_asserts and contract comments to the two callback helpers.
libs/core/async_mpi/tests/unit/fail_compile_set_value_request_callback_void.cpp New negative compile test for the void-return path's receiver-shape assert.
libs/core/async_mpi/tests/unit/fail_compile_set_value_request_callback_non_void.cpp New negative compile test for the non-void path's receiver-shape assert.
libs/core/async_mpi/tests/unit/CMakeLists.txt Registers the two FAILURE_EXPECTED compile-only tests, gated on the standard HPX compile-test options.

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.

LGTM, thanks!

@hkaiser hkaiser added this to the 2.0.0 milestone May 19, 2026
@hkaiser hkaiser merged commit ed201ce into TheHPXProject:master May 19, 2026
72 of 73 checks passed
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.

4 participants