async_mpi: harden transform_mpi callback helpers with static_asserts on receiver shape#7277
Conversation
…on receiver shape Signed-off-by: guptapratykshh <pratykshgupta9999@gmail.com>
Up to standards ✅🟢 Issues
|
16eee05 to
810da06
Compare
|
Can one of the admins verify this patch? |
|
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>
d1c153c to
e2f837c
Compare
There was a problem hiding this comment.
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 intransform_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.txtbehindHPX_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. |
Proposed Changes
static_assertguards to the twotransform_mpicallback helpers in transform_mpi.hpp (set_value_request_callback_voidandset_value_request_callback_non_void) that check the receiver-shape contract at the helper boundary: the void path asserts the receiver is invocable asset_value(rcv), the non-void path asserts both thatInvokeResultis non-void and that the receiver is invocable asset_value(rcv, res).Ts...and the fact that the captured lambda fires on the polling thread (not the receiver's preferred completion scheduler).static_asserts+ comments in a single file.Any background context you want to provide?
Checklist
Not all points below apply to all pull requests.