Skip to content

docs(examples): vectorization misdescribes what f32x4_view_copy emits - #669

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:fix/vectorization-view-message
Aug 6, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:fix/vectorization-view-message

Conversation

@vyncint

@vyncint vyncint commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Split out of #657 as the part that needs no decision from you.

The failure message reads as though the transaction had been scalarized:

!! f32x4_view_copy has no 128-bit ld.global vector op

SASS on sm_86 says otherwise:

f32x4 (direct) f32x4_view_copy
global LDG.E.128 x1, STG.E.128 x1 —
generic — LD.E.128 x1, ST.E.128 x1
local — LDL.64 x2, STL.64 x2
total 2 6

The 128-bit access is there. What is missing is the global window: the view path addresses through the generic one and pays four local-memory accesses, plus 37 PRMT byte-permutes, on the way.

What this changes

The message and its comment only. The check is untouched and still fails — the pessimization it detects is real, and this PR does not paper over it. #657 remains open for the codegen question.

I am sending it separately because it is correct either way: if the codegen is fixed the message never prints, and if it is not, anyone who hits it currently gets pointed at the wrong thing. I spent a while chasing a scalarization that was never happening because I believed this string.

cargo fmt --check clean; no behaviour change.

The failure message says the kernel "has no 128-bit ld.global vector op",
which reads as though the transaction had been split into scalars. SASS on
sm_86 says otherwise:

  f32x4           LDG.E.128 x1, STG.E.128 x1                      (2 ops)
  f32x4_view_copy LD.E.128 x1, ST.E.128 x1, LDL.64 x2, STL.64 x2  (6 ops)

The 128-bit access is there. What is missing is the *global* window: the view
path addresses through the generic one and pays four local-memory accesses,
plus a chain of PRMT byte permutes, on the way.

Message and comment corrected to say that. The check itself is unchanged and
still fails, because the pessimization it detects is real -- only its
description was wrong.

Refs NVIDIA#657

Signed-off-by: Vyncint Ng <[email protected]>
@nihalpasham nihalpasham added documentation Improvements or additions to documentation examples Example kernels and host harnesses under crates/rustc-codegen-cuda/examples labels Aug 6, 2026
The comment described the generic-window fallback in the present tense, which
was accurate while NVIDIA#657 was open. NVIDIA#675 fixes it at the root, so on a tree with
that change the check passes and this branch is never taken. Left as-is the
comment would assert, in-tree, a pessimization that no longer happens.

Reword to describe what a *future* failure most likely means rather than what
the compiler currently does, so it stays true whichever order this and NVIDIA#675
land in. The printed message is unchanged: naming the address space rather than
the width is still the right thing to say when the check fires.

Refs NVIDIA#657, NVIDIA#675

Signed-off-by: Vyncint Ng <[email protected]>
@vyncint

vyncint commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Pushed d08ddb43, prompted by #675.

This PR reworded the failure message for a check that #675 makes pass — it fixes the generic-window fallback at the root, in the enum filler lowering. So on a tree with #675 the None arm here is never taken, and the comment I added, which described the fallback in the present tense, would be asserting in-tree a pessimization that no longer happens.

The comment is now framed as what a future failure most likely means rather than what the compiler currently does, so it reads correctly whichever order the two land in. The printed message is unchanged — naming the address space rather than the width is still the right thing to say when the check fires.

If you would rather this PR just went away now that the root cause is fixed, that is fine too: the message only matters on a regression. I have kept it because a regression here is easy to misread as scalarization, which is exactly the trap #657 set for me.

@nihalpasham

Copy link
Copy Markdown
Collaborator

makes sense on the wording — the SASS evidence in #657 shows the 128-bit access exists but sits in the generic window, and the old message sent readers hunting for a scalarization that never happened.

With #675 merged the check passes and neither message prints, but the corrected failure text is what we want on record if this ever regresses.

@nihalpasham
nihalpasham merged commit 984051b into NVIDIA:main Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation examples Example kernels and host harnesses under crates/rustc-codegen-cuda/examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants