rust-lang / rust-lang/rust

Tracking Issue for the `gpu-kernel` ABI

Open
#135,467 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ABI A-LLVM C-tracking-issue O-amdgcn O-NVPTX T-compiler T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The feature gate for the issue is #![feature(abi_gpu_kernel)].

The extern "gpu-kernel" calling convention represents the entry points exposed to the host, which are then called to actually execute the GPU kernel. Functions built for a GPU target are instead "device functions". Device functions must not call these host functions (and LLVM will emit a compilation error if it is attempted for some targets).

It is implemented for the following targets

  • nvptx64 (translating to the ptx_kernel calling convention in LLVM)
  • amdgpu (translating to the amdgpu_kernel calling convention in LLVM)
About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps
Unresolved Questions
  • May need a story for how to handle breaking changes in ABIs (esp. re: ptx_kernel)
  • This may want to be extern "device-kernel" instead?
  • May want to address or dismiss the question of SPIRV's OpEntryPoint
  • What function signatures are actually valid? LLVM generally doesn't try to validate these, so we must determine that ourselves.
  • Devices shouldn't be able to call these functions, but who can?
  • Should these functions always be unsafe to call? If so, making them uncallable from device code may be redundant (but "my unsafe generated an LLVM error" would be kinda unsettling, even if we define it as UB)
Implementation history
  • Implement the ABI https://github.com/rust-lang/rust/pull/135047
  • Prevent safely calling extern "gpu-kernel" functions when compiling for GPU targets: #149991
  • Document valid function signatures
    • Must have no return value () or !
  • Bar invalid function signatures: #149991

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with implementation PR #135047 and the remaining work tracked in #149991, then review the linked stabilization and documentation guidance. Done requires resolving the ABI design questions, documenting valid signatures and callability, and completing the RFC, documentation, style, and stabilization checklist items.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.