Skip to content

fix(shared): enforce typed shared-memory alignment - #1345

Open
YunusMutlu wants to merge 1 commit into
NVIDIA:mainfrom
YunusMutlu:fix/shared-memory-alignment
Open

YunusMutlu wants to merge 1 commit into
NVIDIA:mainfrom
YunusMutlu:fix/shared-memory-alignment

Conversation

@YunusMutlu

Copy link
Copy Markdown
Contributor

Fixes #1344

Summary

Enforce the alignment contract for static and dynamic shared memory so invalid explicit alignments are rejected before reaching LLVM and physical shared-memory storage is never weaker than the ABI alignment required by its typed pointee.

Changes

  • Validate explicit static and dynamic shared-memory alignments as non-zero powers of two.
  • Compute static shared-memory storage alignment as the maximum of the requested alignment and the element type's required ABI alignment.
  • Preserve MIR aggregate ABI over-alignment instead of relying only on the structurally lowered LLVM type.
  • Compute dynamic shared-memory pool alignment from the strongest typed pointee requirement in the function and combine it with the existing launch-contract requirement.
  • Generalize and reuse the existing MIR type-alignment helper instead of duplicating alignment rules.
  • Add regression tests for invalid alignments, scalar under-alignment, aggregate over-alignment, and multiple typed dynamic shared-memory requirements.

Testing

Verified with the affected crate test suites and the repository's full local CI mirror:

cargo test -p dialect-mir
cargo test -p mir-lower
cargo fmt --all -- --check
git diff --check
just check

All completed successfully.

  • just check passes (the local mirror of CI: fmt, clippy, tests, guards, docs)
  • cargo oxide run <example> passes, or scripts/smoketest.sh -o '^<example>$'
  • New example added (if applicable)

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files (no new source files added)

@nihalpasham nihalpasham added the cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book label Oct 11, 2026
Signed-off-by: Yunus Mutlu <mutluyunus708@gmail.com>
@YunusMutlu
YunusMutlu force-pushed the fix/shared-memory-alignment branch from db617fa to 9966a04 Compare October 13, 2026 11:41
@copy-pr-bot

copy-pr-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shared memory alignment can be invalid or weaker than the pointee ABI requirement

3 participants