Skip to content
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

Tracking Issue for the gpu-kernel ABI #135467

Open
1 of 14 tasks
Flakebi opened this issue Jan 14, 2025 · 0 comments
Open
1 of 14 tasks

Tracking Issue for the gpu-kernel ABI #135467

Flakebi opened this issue Jan 14, 2025 · 0 comments
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC O-amdgpu AMDGPU targets O-NVPTX Target: the NVPTX LLVM backend for running rust on GPUs, https://llvm.org/docs/NVPTXUsage.html T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Flakebi
Copy link
Contributor

Flakebi commented Jan 14, 2025

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 Add gpu-kernel calling convention #135047
  • Prevent safely calling extern "gpu-kernel" functions when compiling for GPU targets
  • Document valid function signatures
    • Must have no return value () or !
  • Bar invalid function signatures
@Flakebi Flakebi added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Jan 14, 2025
@workingjubilee workingjubilee added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. O-NVPTX Target: the NVPTX LLVM backend for running rust on GPUs, https://llvm.org/docs/NVPTXUsage.html A-ABI Area: Concerning the application binary interface (ABI) O-amdgpu AMDGPU targets A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Jan 14, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 14, 2025
…gjubilee

Add gpu-kernel calling convention

The amdgpu-kernel calling convention was reverted in commit f6b21e9 (rust-lang#120495 and rust-lang/rust-analyzer#16463) due to inactivity in the amdgpu target.

Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.

Tracking issue: rust-lang#135467
amdgpu target tracking issue: rust-lang#135024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 14, 2025
…gjubilee

Add gpu-kernel calling convention

The amdgpu-kernel calling convention was reverted in commit f6b21e9 (rust-lang#120495 and rust-lang/rust-analyzer#16463) due to inactivity in the amdgpu target.

Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.

Tracking issue: rust-lang#135467
amdgpu target tracking issue: rust-lang#135024
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 17, 2025
…ubilee

Add gpu-kernel calling convention

The amdgpu-kernel calling convention was reverted in commit f6b21e9 (rust-lang#120495 and rust-lang/rust-analyzer#16463) due to inactivity in the amdgpu target.

Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.

Tracking issue: rust-lang#135467
amdgpu target tracking issue: rust-lang#135024
bjorn3 pushed a commit to bjorn3/rust that referenced this issue Jan 20, 2025
…ubilee

Add gpu-kernel calling convention

The amdgpu-kernel calling convention was reverted in commit f6b21e9 (rust-lang#120495 and rust-lang/rust-analyzer#16463) due to inactivity in the amdgpu target.

Introduce a `gpu-kernel` calling convention that translates to `ptx_kernel` or `amdgpu_kernel`, depending on the target that rust compiles for.

Tracking issue: rust-lang#135467
amdgpu target tracking issue: rust-lang#135024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC O-amdgpu AMDGPU targets O-NVPTX Target: the NVPTX LLVM backend for running rust on GPUs, https://llvm.org/docs/NVPTXUsage.html T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants