Skip to content

Is a streamed local-memory band actually slower? ptxas cannot say, and the ladder now makes the question concrete #63

Closed

Description

@feitreim

Falls out of #60's register ladder, which surfaced a question it explicitly could not answer.

The observation

At several shapes the in-place spellings come in 81–130 registers under the fused one — but the stack-frame table shows the cheap form carrying a frame at least as large as the form it beat. At [32, 96]: assign is 47 registers on 1920 B where fused is 128 registers on 1536 B.

That is not the in-place form winning. It is ptxas deciding the band does not fit and leaving it in local memory, streaming values through a handful of registers. The register column cannot tell those apart, which is why #60 added the frame table beside it.

The question

Is that trade good? A kernel holding 255 registers with zero spill and one holding 47 registers on a 1920-byte frame are not obviously ordered. Local memory is backed by L1/L2, so a streamed band may cost very little — or it may serialize the inner loop. Occupancy pulls the other way: 255 registers/thread caps a B200 SM at one warp per scheduler slot, where 47 does not.

ptxas -v reports what was allocated, never what it cost. Every register claim in this repo currently assumes fewer-is-better, and at the shapes above that assumption is doing real work unexamined.

What would settle it

A timed kernel on a B200 — the first thing in this repo to put a clock on a register-count claim rather than a static count:

  • Pick the rungs where the effect is largest and unambiguous: [32, 96], [48, 64], [64, 64] (in-place far under fused, frame no smaller), with [32, 128] as a control where fused genuinely wins on both counters (168/0 vs 252/0).
  • Time the same arithmetic in both spellings, enough iterations to swamp launch overhead, and report ns/element alongside the existing regs/frame numbers.
  • Report achieved occupancy, not just time — if the register-heavy form is faster per-thread but runs fewer warps, that matters for a real kernel and not for a microbenchmark.
  • The existing bench.rs harness has the shape for this: it checks correctness before timing, and nothing prints a throughput number for a launch it did not verify. Keep that property.

Why it matters beyond curiosity

If streaming is cheap, the library should stop treating high register counts as failures at large shapes, and #60's ladder needs a "fits / streams" column rather than an implied ranking. If streaming is expensive, then several shapes on that ladder are worse than they look, and the shapes where in-place appears to win are actually the ones to avoid — which would change what examples/README.md's "in-place versus by-value" section recommends.

Either answer changes advice this repo is already giving.

Cost

Needs a B200, unlike everything else in #60. Should be one deliberate run, not a sweep — pick the four shapes above, not the whole ladder.

Related: #60 (the ladder), #31 (the materialization model), #47 (softmax's latency floor, the other place a clock beats a static count).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compute

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions