Skip to content

feat(cco): fix the SDMA ring, rework signals and multi-lane thread scope - #502

Merged
jhchouuu merged 26 commits into
ROCm:mainfrom
jhchouuu:jhchouuu/cco-sdma-fast-trigger
Jul 30, 2026
Merged

jhchouuu merged 26 commits into
ROCm:mainfrom
jhchouuu:jhchouuu/cco-sdma-fast-trigger

Conversation

@jhchouuu

@jhchouuu jhchouuu commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

Reworks the CCO SDMA device path: two ring-buffer correctness fixes, a completion/signal rework, safe multi-lane thread scope, and a ~2x faster trigger.

Correctness

  • Slots could be written past the end of the ring. Slots were 64B/128B and placed linearly from the wrapped offset, so once a queue carried mixed slot sizes a slot could straddle the end of the queue buffer. A slot is now a whole number of 32B units and each unit start is wrapped individually, so a packet is never split. This survives mixed slot sizes, which "slot size divides the ring" would not.
  • The read-index hint was never published. cachedHwReadIndex is a by-value field, so a refreshed rptr was thrown away and every put re-read it — an uncached SYSTEM load, paid once the monotonic wptr passes the ring size.
  • Several lanes of one wavefront on one queue deadlocked. Lock-step prevents the lane that must publish committedWptr from leaving the spin loop until the lane waiting on it does. Lanes are now grouped per queue, and the group leader makes one reservation and rings once.
  • The Aggregate solo post never issued s_waitcnt, so a commit() from another wave could ring over a half-written packet.

API changes (breaking)

  • ccoSdmaOptFlags is a template parameter instead of a runtime argument. The C ABI is unchanged — cco_device_wrapper.cpp selects the instantiation — so the Python/FlyDSL aggregate kwarg still works.
  • expectSignals is removed from ccoSdmaContext. Completion no longer depends on signals: quiet/quietQueue drain via rptr/committedWptr and work whatever a put's signal targeted.
  • Signal slots are indexed by sender: signalBuf[srcLsaRank * numQueue + queueId]. put/get take independent localSignal and remoteSignal template flags; the receiver polls with waitSignal.
  • New ccoSdmaThreadMode. SameQueue promises every active lane shares (peer, queueId) and skips the runtime matching; Independent (default) groups lanes at runtime.
  • quiet and commit are templated on coop scope.

Performance (MI355X, gfx950)

Put trigger cost and register pressure, measured against origin/main with the same harness:

scope trigger, no signal trigger, one signal SGPR, no signal SGPR, one signal
thread 6500 -> 2500 cyc 9400 -> 2720 cyc 48 -> 37 50 -> 42
warp 6900 -> 2500 cyc 12800 -> 2695 cyc 64 -> 37 70 -> 42
block 9400 -> 2500 cyc 12900 -> 2695 cyc 64 -> 37 70 -> 42

The trigger is now flat across scopes and nearly flat in the number of signals; on main it grew with both. VGPR is unchanged without a signal (25 -> 26) and higher with one (27 -> 36), which buys the 32B-unit slot fill.

With ccoSdmaThreadSameQueue, 8 lanes of one wave on one queue cost 2612 cyc against 3377 spread over 8 queues -- a whole wave's worth of packets for about what one costs.

End-to-end put latency is unchanged at ~5.9 us: that floor is the engine, not the trigger. Bandwidth is a function of bytes per op only -- 52 GB/s at 1 MB, 60 GB/s at 8 MB, identical across scopes and directions.

Tests and docs

  • New test_sdma_signal (local/remote signal, waitSignal, slot non-contamination) and test_sdma_warp_issue (several thread-scope issuers per wavefront). test_sdma_edge gains a mixed-slot-size ring-wrap phase that faults the GPU without the straddle fix.
  • CI runs both new tests and a benchmark smoke over all three coop scopes, both completion modes, and put/get latency and bandwidth.
  • .claude/skills/cco-sdma-api/ documents which template arguments and scope to pick, the build flags and env vars, and the failure modes.

Note

The commit chain assumes the wptr / doorbell / committedWptr stores land in order; upstream anvil_device.hpp separates them with s_waitcnt. Adding one back costs ~42% of the trigger, and 19200 puts contending on a single queue showed no reordering, so this is deliberate. Called out in the code.

jhchouuu and others added 3 commits July 27, 2026 11:37
The device-side SDMA put trigger (packet build + doorbell) took ~3.4us on
MI355X, dominated by per-dword atomic queue writes and 4 serialized fence
groups in submitPacket.

- ccoSdmaPostCopy reserves one fixed 64B slot (COPY + ATOMIC + NOP filler) with
  a single atomic_fetch_add (ReserveSlot) instead of two CAS-loop reservations,
  then writes the packet dwords as plain stores. The contiguous slot also makes
  concurrent same-queue issuers safe (they can no longer interleave and break
  the commit chain).
- submitPacket keeps the in-order committedWptr chain but drops wave_barrier and
  3 redundant fence groups; one s_waitcnt(0) publishes the packet dwords before
  the doorbell. Spin/stores stay RELAXED to avoid a coherence storm under
  contention.

MI355X (gfx950, readcyclecounter @2.404GHz): uncontended trigger ~8137 -> ~2369
cycles (3.39us -> 0.99us, ~3.4x). Correctness verified single-issuer (8B..16MB
incl. odd/unaligned) and multi-issuer (up to 512 blocks on one queue).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The retry/deadlock guard's counter + noreturn trap inflates SGPR usage of the
device SDMA path (put 28->48, commit 14->46). It is a debug-only hang->trap
converter, not a correctness mechanism, so gate it behind MORI_CCO_SDMA_DEBUG
(off by default). NDEBUG is unsuitable because the JIT path compiles device code
without it, which would keep the guard on for JIT kernels.

- CCO_SDMA_BREAK_ON_RETRIES is now false unless MORI_CCO_SDMA_DEBUG is defined.
- Add the same debug-only bound to ReserveSlot (previously the only unguarded
  spin), so debug builds trap on both reserve- and submit-side deadlocks.
- Mark the retry counters [[maybe_unused]] so the default (off) build is clean
  under -Wall.

Correctness (verify 8B..16MB, multi-issuer stress up to 512 blocks) unchanged.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ng template

warp/block put now targets the caller's queueId (one queue, no scatter) via a
leader-only single writer; the extra lanes no-op. Cooperative 16-lane WQE fill
was measured ~13% slower than the single writer for a 64B packet, so it is not
used. `ring` (Aggregate) becomes a compile-time `<bool Ring>` template threaded
through PostCopy/PutThread and a new ccoSdmaDispatchPut; put/get branch once on
the runtime flag. Removes the now-unused ccoSdmaPutMultiQueue. commit/quiet are
unchanged.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@jhchouuu jhchouuu closed this Jul 28, 2026
jhchouuu and others added 11 commits July 28, 2026 13:46
…itSignal

quiet/quietQueue now drain via the queue read pointer (rptr>=committedWptr),
decoupling local completion from signals — a signal may target the peer without
deadlocking the sender's quiet. put/get take two bool template flags
localSignal/remoteSignal (composable): each fires a trailing ATOMIC into the
src-dimensioned slot signalBuf[myLsaRank*n+q], locally or into the peer's pool
via peerSignalPtrs; the slot is 64B for <=1 atomic, 128B for 2. New
waitSignal(srcRank, queueId, expected) polls the local slot (>=), with expected
maintained by the caller. Removes expectSignals auto-bookkeeping and the
signal-based quiet path.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
test_sdma_signal exercises what the quiet rework changed and the existing
SDMA tests never touched: explicit queueId, aggregate mode, and the two
signal template flags. Ranks form a ring (peer=rank+1, src=rank-1).

  A  scope x queueId x aggregate x size matrix, no signals — quiet() drains
     via rptr for every shape (84 configs, host-verified).
  B  remoteSignal only: receiver waitSignal(src) then verifies IN-KERNEL with
     no barrier, so the signal alone must prove the data landed at the peer.
  C  localSignal only: waitSignal(self) returns and the src-dimensioned slots
     do not contaminate each other.
  D  both flags (128B slot): local and remote slots each advance by exactly N.

Every signal part also calls quiet() afterwards — a peer-targeted signal must
no longer deadlock the sender. Expected counts are per (src, queue) since the
slots are never reset. CCO_TEST_PARTS / CCO_TEST_VERBOSE narrow a failing run.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The SDMA path ignored -s and always ran one thread. Template the latency
kernel on the coop scope so -s thread|warp|block selects the issue
granularity; the copy is never split, so all three move the same bytes over
queue 0 and the delta is pure issue overhead.

Completion stays on quietQueue(peer, 0). quiet<Coop>() would drain every
queue, and the extra uncached rptr read on an idle queue costs ~1.3us at
small sizes — real, but an artifact of quiet's all-queue semantics rather
than of the issue scope.

PerfArgs gains put_scope_explicit so SDMA keeps its historical thread-scope
default (the global default is block) and existing -t sdma numbers stay
comparable. thread_agg has no SDMA analogue and runs as thread.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Since the quiet rework, a sender has two ways to wait for local completion,
with the same sender-side guarantee but different cost:

  -C quiet   quietQueue() — engine read pointer passed our committed wptr
  -C signal  put carries a trailing localSignal ATOMIC into our own
             signalBuf[myLsaRank*n+q] slot; waitSignal() polls it

Both options are named after the API the kernel calls.

The signal slot is never reset, so the kernel snapshots it on entry and
counts up from there rather than assuming zero.

Measured (gfx950, 2 ranks, thread scope): signal is ~1.9us faster at every
size — 8B 6.98 -> 5.09, 1MB 26.8 -> 25.0. That recovers the pre-rework
numbers, so the rptr penalty is a property of the default, not of the
rework: callers that want the old latency opt into localSignal.

Default stays quiet (no caller-side bookkeeping).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
ccoSdmaPostCopy sizes its slot by signal count, so a queue that carries a mix
of no-signal / one-signal / two-signal puts sees several reservation sizes.
Phase 1 cannot catch what that breaks: same-size puts keep the ring offset
slot-aligned forever, so a slot never reaches the ring end.

Phase 4 interleaves the three sizes over several laps of the ring. On the
current layout it faults the GPU — the slot straddles the end and the write
runs past queueBuf.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
ccoSdmaPostCopy reserved 64B for <=1 trailing ATOMIC and 128B for two, and
wrote the slot linearly from WrapIntoRing(base) with no wrap handling. That
relies on "slot size divides the ring" to keep the offset slot-aligned, which
only holds while every put on the queue reserves the same size. Mix a
two-signal put into a queue of 64B slots and the offset goes to 64 (mod 128);
once it reaches 262080 the slot straddles the ring end, writing 64B past
queueBuf and splitting the packet. Reproduced with a probe (the 128B slot
lands at [262080, 262208) against a 262144B ring) and by the new phase 4 of
test_sdma_edge, which faults the GPU.

Lay the slot out in 32B units instead, one packet per unit: COPY (28B) padded
with a NOP dword, then a unit per ATOMIC (32B exactly) — 32/64/96B for 0/1/2
signals. Every reservation and the ring are multiples of 32B, so a unit is
always 32B-aligned within the ring and only the unit start needs wrapping; no
packet is ever split, so the engine's requirement holds for any mix of sizes.

Measured on gfx950 (same-process A/B, min of 15): no-signal put drops from 16
to 8 ring dwords and gets ~1.5% faster; two signals drop from 32 to 24 dwords;
one signal costs ~2.5% of trigger (~0.7% of an 8B put+quiet round trip) since
its NOP no longer merges into the trailing store. Storing each unit as one 16B-
aligned object and keeping a contiguous fast path recovers most of that.

Also drops ReserveQueueSpace / placePacket / CanWriteUpto, dead here since the
switch to ReserveSlot and stale enough to have misled test_sdma_edge's own
comments; guards waitSignal's srcRank and documents it as an LSA rank; and
traps under MORI_CCO_SDMA_DEBUG when quiet() is called with un-committed
Aggregate puts, which otherwise returns as if drained.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
quiet<Coop> had the leader walk every queue in sequence. Draining is a spin on
an uncached rptr and even an idle queue costs one such read, so with one busy
queue the leader paid the idle ones back to back. Give each lane a queue
(strided, so a group smaller than the queue count still covers all of them):
20% faster when one queue has traffic, unchanged when all do. Thread scope
keeps the sequential loop.

quietQueue took no scope at all, so a warp or block had every thread polling
the same uncached rptr. Template it and poll from the leader only: 4-7% off
block-scope put latency at 8B-16KB, and no slower elsewhere. Existing callers
default to thread scope and are unaffected.

test_sdma_signal was passing devComm.rank where the signal slot is indexed by
lsaRank — equal on a single node, wrong across nodes, and silently so.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
optFlags was a runtime argument that put()/get() immediately branched on to
pick a compile-time Ring, so the flag had two representations and the public
one could silently be a runtime value. When it is, both the ringing and the
aggregate path get emitted: 94 -> 157 instructions for an 8B put on gfx950.
Constant callers were already folded to one path, so this changes no codegen
for them (94 with the default, 75 with Aggregate, unchanged), but it makes
that guarantee part of the type rather than something the optimizer has to
find.

Fold Ring into optFlags and thread it through PostCopy / PutThread / PutWarp /
PutBlock / DispatchPut, deriving the doorbell decision where it is used. Add a
static_assert on unknown flag bits, which the runtime parameter could not check.

API break: callers passing optFlags positionally must move it to the template
argument list. In tree that is the two bw benchmarks and test_sdma_signal's
matrix kernel, which now template on the flag and pick the instantiation at
launch instead of branching inside the kernel.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
ReserveSlot skips reading the queue read pointer while the cached read index
says there is room. cachedHwReadIndex is a by-value field, though, and every
caller works on a copy of the handle (`handle = **(deviceHandles + qId)`), so
the refreshed value was written to the stack and dropped. It stayed at its
initial 0 forever, which makes the check fail for good once the monotonic wptr
passes the ring size: from then on every put took the slow path and paid an
uncached SYSTEM read of rptr.

Store the refreshed index back into the shared handle. The hint only ever moves
to a value rptr actually had and is used conservatively (a stale hint can only
cause an extra read, never skip backpressure), so racing writers are fine.

Trigger on gfx950 drops from ~4800 to ~2500 cycles, uniformly across sizes.
This also explains the "8B is fast, >=16B is not" behaviour that looked
intrinsic to the doorbell path: it was whichever size ran first, before the
write pointer had passed 256KB. Nothing about it was size-dependent.

Visible effect is narrower than the trigger number suggests: small-message
put+quiet is bound by the engine's ~5.9us round trip and does not move, and
bandwidth is link-bound and does not move. Latency at >=64KB improves 4-12%.
The saving is CU-side, so it lands where the issuing kernel has other work to
do rather than in a put-then-wait loop.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…per wave

Thread scope posts per lane and has no threadIdx guard, so a wavefront can have
many lanes in put() at once. Lanes on the same queue deadlocked: each ran
submitPacket, and the lane that has to publish committedWptr cannot leave the
spin loop until the lane waiting on it does, which lock-step will not allow. The
contract was therefore stricter than the comment admitted — one issuer per
(peer, queue) AND issuers in different warps — and violating it hung rather than
just running slowly.

Group the wave's lanes by the queue they target and post a group as a unit: the
leader makes one reservation for all of them, every lane fills its own slot, and
only the leader touches the commit chain and the doorbell. The chain spin then
only ever waits on other warps. Groups are posted one at a time so a warp never
holds two un-published reservations, which two warps could otherwise deadlock
on. Modelled on shmem_ibgda_kernels.hpp's thread-scope post.

Lanes on distinct queues keep posting independently and in parallel — one lane
per peer is a shape the grouping must not serialise — so the mode is detected
first with a ballot per key bit.

ccoSdmaThreadMode lets a caller skip that detection, mirroring ccoGdaThreadMode.
The second value is SameQueue rather than Aggregate because that word is already
ccoSdmaOptFlagsAggregate here, which batches doorbells and is a different axis.
Breaking the promise makes lanes write slots reserved on another queue, so it is
checked under MORI_CCO_SDMA_DEBUG.

Measured on gfx950, N lanes of one wave on one queue, against the same N issuing
from separate warps (the only shape that worked before): 1.29x at N=2 rising to
6.9x at N=16, and near-flat from N=1 to N=16 with SameQueue. Register cost is
+5 SGPR for SameQueue and +14 for Independent, no spills, occupancy unchanged at
8. quiet, quietQueue, waitSignal and commit are untouched.

ccoSdmaPostCopy splits into ccoSdmaFillSlot so both the solo and grouped paths
write a slot the same way.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
put's comment still said "Single-issuer per (peer, queue)", which the lane
grouping removed, and did not mention threadMode at all. Correct both, and trim
the rest of the SDMA comments to what a reader cannot recover from the code: the
lock-step reason lanes on one queue have to be grouped, the one-reservation-at-a-
time invariant, that waitSignal's expected is per (srcRank, queueId), and that
srcRank is an LSA rank. Measurements that justified a choice belong in the commit
that made it, not in the header.

The skill covers what someone writing a kernel against this API needs: the build
flags and env vars that turn the path on, the six calls, which template arguments
and coop scope to reach for, how completion and signals work, and the failure
modes. Every snippet in it compiles.

Two points it leads with, since both are easy to get backwards:
  - Prefer ccoSdmaThreadSameQueue. Lanes of one warp should share a queue, not
    spread over queues — spreading is measurably worse, because each lane still
    issues its own uncached reservation and doorbell. Queues buy parallelism
    between warps, not between lanes.
  - Queue count belongs in reqs.sdmaQueueCount, not MORI_SDMA_NUM_CHANNELS, and
    is fixed by the first ccoDevCommCreate on a comm.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@jhchouuu jhchouuu reopened this Jul 29, 2026
Nothing in tree had more than one lane of a wave in put() at once, so neither
the shape that used to deadlock nor the grouping that fixed it was exercised —
and ccoSdmaThreadSameQueue could be ignored entirely without a test noticing.

Five shapes, each lane writing its own chunk so the receiver can tell them
apart: many lanes of one warp on one queue (2/4/16/64), the same with gaps so
the active set is not a prefix, the SameQueue path, mixed queues in one warp,
and one issuer per warp on a shared queue.

Built against the pre-grouping header the same-queue shapes do not return.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@jhchouuu jhchouuu changed the title perf(cco): fast SDMA put trigger via single-slot reserve + lean commit feat(cco): SDMA device path — ring-wrap and read-index fixes, quiet/signal rework, multi-lane thread scope Jul 29, 2026
jhchouuu added 2 commits July 29, 2026 03:03
Put latency already took -s; the other three SDMA benchmarks were
thread-only, so two of the three coop scopes had no benchmark at all.

Template the get-latency and put/get-bandwidth kernels on Coop and add
the launch dispatch, keeping thread as the default when -s is absent so
existing invocations report the same numbers. The bandwidth kernels'
_warp helper is renamed _coop now that it serves all three.

Also fix the bandwidth printer, which fell through to the thread branch
for block scope and reported the wrong scope name and message size.
The SDMA test list predated test_sdma_signal and test_sdma_warp_issue,
so neither ran in CI. Add them.

Add a benchmark smoke step covering all three coop scopes for put/get
latency (both completion modes) and put/get bandwidth, plus one
aggregate-doorbell config. This is a smoke check, not a perf gate: a
shared runner cannot give stable numbers, but the sizes are chosen so a
gross regression is visible in the log. Needs BUILD_BENCHMARK=ON, which
the build step did not set. The whole step is ~25s.

Bandwidth runs at the default depth of one op per transfer; splitting a
transfer costs bandwidth in proportion to how small the pieces get, so
-A 8 there would have measured a degenerate config (17 vs 52 GB/s).

Drop the trailing copy of the Python API step, which is a verbatim
duplicate of the one already above.
@jhchouuu
jhchouuu force-pushed the jhchouuu/cco-sdma-fast-trigger branch from 571fe45 to f60fdbf Compare July 29, 2026 03:05
jhchouuu added 4 commits July 29, 2026 03:07
The skill said splitting a transfer costs bandwidth but gave no numbers,
so a reader had no way to tell whether their message size was in the
latency-bound or bandwidth-bound regime. Add the measured 64KB-8MB curve
and the two thresholds that follow from it: half the achievable
bandwidth is gone by 512KB, and below ~256KB the fixed dispatch cost
dominates.

State once, up front, that every number in the file is MI355X (gfx950)
intra-node xGMI, and drop the per-table repetitions of that.
Comments-only; the code is byte-identical. Cuts the ones that restated
the code or repeated what the skill and the surrounding names already
say, and keeps the ones that record a decision: the anvil fork contract,
why the read-index hint is published back, why the commit chain stays
RELAXED, why grouping is what makes lanes share a queue safely, why
nothing in the group walk may read exec, and the 32B slot invariant.

Also fixes the ccoSdmaBallot comment, which described a `mask` parameter
the function does not have.
… slots

Two defects found reviewing the branch against origin/main.

cco_device_wrapper.cpp still passed optFlags as an eighth runtime
argument, so the whole file failed to compile once optFlags became a
template parameter. Nothing caught it: the static build never defines
BUILD_CCO_SDMA (build_cco_bitcode.sh omits it) so the block is compiled
out, and only the runtime JIT, which setup.py hands -DBUILD_CCO_SDMA=1,
ever instantiates it. The wrapper now selects the instantiation from the
runtime flag, which keeps the C ABI and the FlyDSL binding unchanged --
aggregate stays a runtime kwarg for callers.

The thread-scope solo post skipped s_waitcnt entirely under Aggregate,
where nothing rings and the eventual commit() may come from another wave
whose waitcnt cannot cover our stores; that wave could ring over a
half-written packet. The other two post paths already waited
unconditionally. Verified by compiling the wrapper with
BUILD_CCO_SDMA=1, and the seven SDMA tests pass 8/8.
The old comment claimed the RELAXED stores were safe because visibility
came from the leading s_waitcnt. That is not what it does -- it publishes
the packet dwords, and says nothing about the order of the three stores
after it. Say plainly that we rely on those landing in order, and that
upstream anvil_device.hpp separates them with waitcnts and we do not.
Comment thread include/mori/cco/cco.hpp Resolved
… wave width

ccoSdmaBallot / LanesBelow / LaneId / BcastLane / BcastFirstLane / MatchQueue
carry no SDMA semantics -- they are wavefront primitives that happened to be
written where they were first needed. Move them to mori::cco::impl, next to
warpSize/threadIdxX, under names that say what they do. cco_scale_out.hpp grows
the same per-peer grouping walk out of HIP's __ballot/__shfl; converging the two
is left for a follow-up, since GDA is already wave-width correct through HIP.

The move fixes a latent bug. The ballot was hardcoded to __builtin_amdgcn_
ballot_w64, and gfx10+ default to wave32: ballot_w64 still compiles there, it
just reads the wrong width, so the failure would have been silent results rather
than a build break. waveBallot now selects w32 or w64 from the target, verified
by a static_assert on impl::kWaveSize compiled for gfx950 and gfx1250.
Masks stay uint64_t, with only the low half populated on wave32.

The seven SDMA tests pass 8/8, and the device wrapper compiles for both targets.
@jhchouuu
jhchouuu force-pushed the jhchouuu/cco-sdma-fast-trigger branch from ec670a8 to fad55f7 Compare July 29, 2026 06:40
jhchouuu added 2 commits July 29, 2026 08:37
At thread scope a group of lanes sharing a queue used to emit one ATOMIC
per lane, all incrementing the same counter. An ATOMIC costs the engine
about what a COPY does, so a 64-lane scatter spent half its time on
redundant signals: 248 us, against 132 us with no signal at all.

Signal the group once, after all of its copies. The engine runs a queue
in order, so that one signal still means every copy landed, and it makes
`expected` advance by one per put() call whatever the scope and however
many lanes joined -- previously the receiver had to know the lane count.
ccoSdmaOptFlagsSignalPerCopy restores the old behavior for a caller that
must observe copies landing one at a time.

Measured on MI355X: 64 signalled copies of 4 KB go from 256 us to 141 us,
and the marginal cost per signalled packet from 3.9 us to 2.1 us, which
is what an unsignalled one costs. Issue cost is unchanged.

The slot layout follows: a group reserves [COPY]xn [ATOMIC]xsignals and
each lane writes its own 32B units, rather than every lane writing an
equal-sized [COPY][ATOMIC...] slot. Since a unit is 32B and the ring is a
multiple of 32B, a unit can never straddle the ring end, so the separate
wrap path -- and the class of bug it was added for in da8fbe7 -- is gone
along with the now-unused WrapIntoRing.

Nothing in the tree signalled from more than one lane, so no in-tree
caller changes behavior. Verified the counter advances by 1 (group) and
by the lane count (SignalPerCopy) for 1/2/8/64 lanes with the data
checked, and the seven SDMA tests pass 8/8.
Covers the new default in the skill: one signal per put() call, what
ccoSdmaOptFlagsSignalPerCopy changes, and the failure mode of counting
`expected` per lane against a sender that signals per group.

Adds what the engine costs per packet, which is the number a kernel
author actually needs to decide whether to scatter at all: ~2 us
regardless of payload up to a few KB, so 64 x 4 KB takes 138 us where
the same bytes in one copy take 11 us. Packing first is usually the
faster answer, since a local gather runs at ~7 TB/s; scatter when the
chunks are large, the CU must stay free, or the receiver would otherwise
have to unpack.

Also extends the lane-count table from 8 to 64 lanes. It previously
stopped at 8 while the text claimed the cost "barely moves" up to 64 --
it grows 43%, and the real point is that per packet it drops 45x.
Comment thread include/mori/cco/cco.hpp Resolved
Parts B-D all post from a single thread, so the layout a group of lanes
produces had no cover at all -- and that layout is exactly what changed
when the default became one signal per put() rather than one per copy.

Part E posts from 1/2/8/64 lanes of a wavefront on one queue and checks
the counter advanced by one, then repeats it with
ccoSdmaOptFlagsSignalPerCopy and checks it advanced by the lane count.
Both directions are checked, so an implementation that ignored the flag
fails whichever way it ignored it. It reads the slot before and after
instead of resetting it, since B-D keep a running total in the same slot,
and it verifies every lane's chunk landed, which is what would catch a
wrong stride between lanes.

Separately: every SDMA test prints SKIP and exits 0 when the comm has no
queues, so a runner or build that quietly lost SDMA turned the whole
suite green. Confirmed by running one without MORI_ENABLE_SDMA: it prints
SKIP and reports 2/2 PASSED. CI now treats a SKIP as a failure.
@jhchouuu jhchouuu changed the title feat(cco): SDMA device path — ring-wrap and read-index fixes, quiet/signal rework, multi-lane thread scope feat(cco): fix the SDMA ring, rework signals and multi-lane thread scope Jul 30, 2026
@jhchouuu
jhchouuu merged commit eaa07c7 into ROCm:main Jul 30, 2026
14 checks passed
@jhchouuu
jhchouuu deleted the jhchouuu/cco-sdma-fast-trigger branch July 30, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants