Skip to content

add nvptx_target_feature and use unaligned barrier #1805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jedbrown
Copy link

  • Deprecate _syncthreads (the CUDA name) in favor of new _barrier_sync (NVPTX name barrier.sync).
  • The: barrier.sync instruction is equivalent to barrier.sync.aligned prior to sm_70, and will lead to errors/deadlock if passes (such as MIR JumpThreading) lose the aligned property.
  • Since: MIR does not currently have a way to apply something like LLVM's convergent attribute (and because convergent does not preserve alignment, which can be broken by inlining), we cannot prevent loss of alignment, and thus we require target feature sm_70. In short, we cannot prevent miscompilation of aligned barriers without hard-to-specify preconditions.

This requires rust-lang/rust#138689 (for nvptx_target_feature) and fixes rust-lang/rust#137086.

jedbrown added 2 commits May 19, 2025 13:33
* Deprecate _syncthreads (the CUDA name) in favor of new
_barrier_sync (NVPTX name barrier.sync).

* The: barrier.sync instruction is equivalent to barrier.sync.aligned
prior to sm_70, and will lead to errors/deadlock if passes (such as MIR
JumpThreading) lose the aligned property.
rust-lang/rust#137086
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-bar

* Since: MIR does not currently have a way to apply something like
LLVM's convergent attribute (and because convergent does not preserve
alignment, which can be broken by inlining), we cannot prevent loss of
alignment, and thus we require target feature sm_70.

https://llvm.org/docs/ConvergentOperations.html
@rustbot
Copy link
Collaborator

rustbot commented May 22, 2025

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

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.

MIR passes do not take into account if an operation is convergent
3 participants