Repository navigation
UCT/D2P: Add completion infra - #12135
Artemy-Mellanox wants to merge 3 commits into
Conversation
|
🤖 Starting review — findings will be posted here when done. |
| 0; | ||
|
|
||
| comp_id = READ_ONCE(ch->ci[pi & (depth - 1)].avail); | ||
| if ((comp_id & UCT_IB_D2P_AVAIL_STAMP) != stamp) { |
There was a problem hiding this comment.
A ring slot is now reusable only after a completion was returned to avail, not after the proxy consumed the descriptor. Ops posted without comp do not set UCT_IB_D2P_FLAG_CQ_UPDATE, so how does the completer learn they finished and return their id — don't we stall after depth unsignaled ops?
| UCT_IB_D2P_AVAIL_STAMP : | ||
| 0; | ||
|
|
||
| comp_id = READ_ONCE(ch->ci[pi & (depth - 1)].avail); |
There was a problem hiding this comment.
minor: pls use the same mask expression as the slot computation below.
| comp_id = READ_ONCE(ch->ci[pi & (depth - 1)].avail); | |
| comp_id = READ_ONCE(ch->ci[pi & UCS_MASK(iface->log_depth)].avail); |
| } | ||
|
|
||
| if (comp != nullptr) { | ||
| uct_dev_sync<level>(); |
There was a problem hiding this comment.
do we need this sync for UCS_DEVICE_LEVEL_BLOCK? uct_dev_bcast below already does __syncthreads() after lane 0 writes, so this adds a second barrier on the posting path.
| * completion to the pool. So the op has completed once done has reached its | ||
| * generation, which stays true after the completion is reused. | ||
| */ | ||
| #define UCT_IB_D2P_COMP_INDEX_BITS 16 |
There was a problem hiding this comment.
the comment says the ring is limited to UCS_BIT(UCT_IB_D2P_COMP_INDEX_BITS) entries, but nothing enforces it: log_depth is uint8_t, and with depth > 64K the index would alias into the generation bits. can we add a static assert / host-side check?
| #define UCT_IB_D2P_COMP_ID(_gen, _index) \ | ||
| (((uint64_t)(_gen) << UCT_IB_D2P_COMP_INDEX_BITS) | (_index)) | ||
| #define UCT_IB_D2P_COMP_ID_GEN(_id) ((_id) >> UCT_IB_D2P_COMP_INDEX_BITS) | ||
| #define UCT_IB_D2P_COMP_ID_INDEX(_id) ((_id)&UCT_IB_D2P_COMP_INDEX_MASK) |
There was a problem hiding this comment.
minor: single space around operators (docs/CodeStyle.md).
| #define UCT_IB_D2P_COMP_ID_INDEX(_id) ((_id)&UCT_IB_D2P_COMP_INDEX_MASK) | |
| #define UCT_IB_D2P_COMP_ID_INDEX(_id) ((_id) & UCT_IB_D2P_COMP_INDEX_MASK) |
Implement uct_ib_d2p_ep_check_completion, which was a stub returning UCS_OK. Every operation holds a completion from the moment it is posted to the moment it completes. A channel has as many completions as its ring has entries, so at most that many operations are in flight: there is always room in the ring and in the send queues, and a slow operation holds back one completion and nothing else. The GPU takes the next position of the ring together with the completion of that position, from a pool in GPU memory, and only once that completion has been returned. The first completions are in the pool from the start, and the completer returns the others. A completion id is the index of the completion and its generation, the number of times it was taken. The GPU passes it in the descriptor and keeps it in the completion object. When the operation completes, the completer writes the generation to the done entry of the completion and returns the completion to the pool, for its next generation. The operation has completed once the done entry has reached its generation, which stays true when the completion is taken again, so an operation can be checked at any time, or never. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
15fe3c1 to
bf7ad71
Compare
|
🤖 Starting review — findings will be posted here when done. |
| typedef struct { | ||
| unsigned long long *pi; | ||
| unsigned long long *ci; | ||
| uct_ib_d2p_ci_t *ci; |
There was a problem hiding this comment.
ci is no longer a consumer index but the completion array; pls rename it (and uct_ib_d2p_ci_t) to something like comp / uct_ib_d2p_comp_t, otherwise it reads as the counterpart of pi.
|
|
||
| typedef struct { | ||
| uint64_t done; | ||
| uint64_t avail; |
There was a problem hiding this comment.
maybe keep done and avail as two separate arrays? they are unrelated (as the comment above says), and packing them in one 16B entry makes every proxy write to avail dirty the line of the done entry that check_completion polls.
| * depth + n. Every other lap has UCT_IB_D2P_AVAIL_STAMP set, to tell | ||
| * the entry of a position from the one of the lap before. | ||
| * | ||
| * The ring has at most UCS_BIT(UCT_IB_D2P_COMP_INDEX_BITS) entries. |
There was a problem hiding this comment.
where is this enforced? log_depth is uint8 and nothing checks depth <= UCS_BIT(UCT_IB_D2P_COMP_INDEX_BITS), so a larger ring configured by the proxy would silently alias completion indexes.
| const long long depth = UCS_BIT(iface->log_depth); | ||
| unsigned long long pi = READ_ONCE(*ch->pi); | ||
| auto iface = ep->iface; | ||
| uint64_t cid = channel_id & iface->channel_mask; |
There was a problem hiding this comment.
minor: cid can be unsigned, to match the channel_id parameter and uct_ib_d2p_completion_t::channel_id.
| uint64_t cid = channel_id & iface->channel_mask; | |
| unsigned cid = channel_id & iface->channel_mask; |
|
Residual coverage gap: there is no in-tree test or CI job that exercises |
|
🤖 CI Triage Agent — TL;DR: The build failed on a single unrelated unit test, Full analysisSummary: Root cause: Evidence from the log: exactly one failing test, and it is a pure UCS unit test ( Implicated commit: unknown — not from this PR; the fragile global-state assumptions date to 5bf3df8 (Roie Danino, "UCS/PROFILE: added ucx env to profiling output, changed profiling file structure") combined with 626e76c (Yossi Itigin, "Add UCS_PROFILE_xx_ALWAYS macros, enabled in release mode"). File: test/gtest/ucs/test_profile.cc:226 (and 264, 403, 407); src/ucs/profile/profile.c:161-168 Suggested fix: Re-trigger the Azure job for PR #12135 — the failure is unrelated to the change set. To remove the flakiness permanently, make Related: none found (searches for prior |
|
🤖 Starting review — findings will be posted here when done. |
|
|
||
| comp_id = READ_ONCE(ch->ci[slot].avail); | ||
| if ((comp_id & UCT_IB_D2P_AVAIL_STAMP) != stamp) { | ||
| /* Completion not returned yet: depth ops are in flight */ |
There was a problem hiding this comment.
a ring slot is now freed only when its completion is returned, but CQ_UPDATE is requested only when comp != nullptr - won't a stream of puts without comp stall here after depth ops? gda forces CQ_UPDATE every sq_fc_mask WQEs for exactly this.
| const uint64_t done = READ_ONCE(ci[UCT_IB_D2P_COMP_ID_INDEX(comp_id)].done); | ||
|
|
||
| /* done only grows: a completed op stays completed after the reuse */ | ||
| return (done >= UCT_IB_D2P_COMP_ID_GEN(comp_id)) ? UCS_OK : UCS_INPROGRESS; |
There was a problem hiding this comment.
how is an op error reported? on a failed op done never reaches the generation, so the caller spins in check_completion forever; rc_mlx5_gda returns UCS_ERR_IO_ERROR here.
| * completion to the pool. So the op has completed once done has reached its | ||
| * generation, which stays true after the completion is reused. | ||
| */ | ||
| #define UCT_IB_D2P_COMP_INDEX_BITS 16 |
There was a problem hiding this comment.
is depth <= UCS_BIT(UCT_IB_D2P_COMP_INDEX_BITS) enforced anywhere? log_depth is uint8_t, and a bigger ring would overflow the index into the generation bits and silently alias completions.
| * position p is in entry p mod depth. Position "pi" of the ring is | ||
| * position "pi" of the pool: the GPU takes both once the completion | ||
| * of that position was returned. The first depth positions hold the | ||
| * completions at generation 1, the n-th returned id goes to position |
There was a problem hiding this comment.
minor: reading "n-th" as 1-based, position depth is never written; pls say "the n-th returned id (n from 0) goes to position depth + n".
|
🤖 CI Triage Agent — TL;DR: The Full analysisSummary: Root cause: Evidence from the log (build 141892, step "Run ./contrib/test_jenkins.sh"):
Not a timeout/hang: the script ran continuously from 10:08:13 to 10:09:08 (~55 s) with no gap larger than the single
The failure is in UCP transport-selection/test-script territory and has no relationship to the content of PR #12135 ("UCT/D2P: Add completion infra", UCT device completion plumbing) — it is a RoCE-environment-specific gap in the test case rather than a regression from this commit. Implicated commit: File: Suggested fix:
Related: PR #12135 (build under test); commit |
| const uint64_t stamp = ((pi >> iface->log_depth) & 0x1) ? | ||
| UCT_IB_D2P_AVAIL_STAMP : | ||
| 0; | ||
| owner = (pi >> iface->log_depth) & 0x1; |
There was a problem hiding this comment.
maybe reuse depth?
owner = (pi & depth) != 0;
|
🤖 Starting review — findings will be posted here when done. |
| } | ||
|
|
||
| unsigned long long prev = atomicCAS(ch->pi, pi, pi + 1); | ||
| comp_id &= ~static_cast<uint64_t>(iface->depth); |
There was a problem hiding this comment.
why do we clear bit log_depth here? it only works if the proxy spaces per-slot comp_ids by 2*depth — otherwise two consecutive laps of the same slot get the same comp_id and check_completion returns UCS_OK one lap early. pls document the comp_id encoding (and the initial values of avail/done) in d2p_proto.h, since the proxy is a separate component.
| uint8_t log_depth; | ||
| uint8_t pad[2]; | ||
| uint32_t channel_mask; | ||
| uint32_t depth_mask; |
There was a problem hiding this comment.
minor: depth is just depth_mask + 1, IMO keep only one field and derive the other.
| typedef struct { | ||
| unsigned long long *pi; | ||
| unsigned long long *ci; | ||
| #include "d2p_proto.h" |
There was a problem hiding this comment.
minor: d2p.h doesn't use anything from d2p_proto.h, is this include needed?
|
Residual coverage gap (already noted in a prior review): still no in-tree test or CI job exercising |
|
🤖 CI Triage Agent — TL;DR: Both mlx5 RX-side gtests on the BlueField worker ( Full analysisSummary: gtest shard 3/4 of the AddressSanitizer BlueField job aborted: Root cause: No receive completions at all were generated on IB device
Implicated commit: none in the failing code path — File: Suggested fix:
Related: PR #12135 (#12135) — the PR under test; no existing issue found matching this RX-stall signature. |
What?
Implement uct_ib_d2p_ep_check_completion, which was a stub returning UCS_OK.