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 targeting AMDGPU devices #51575

Closed
2 of 5 tasks
DiamondLovesYou opened this issue Jun 15, 2018 · 8 comments
Closed
2 of 5 tasks

Tracking issue for targeting AMDGPU devices #51575

DiamondLovesYou opened this issue Jun 15, 2018 · 8 comments
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.

Comments

@DiamondLovesYou
Copy link
Contributor

DiamondLovesYou commented Jun 15, 2018

This issue tracks progress/roadmap for what needs to be done to codegen for targets like AMDGPUs. Personally, I am working on AMDGPU codegen as it would be used for HSA. Specifically, I am aiming for the amdgcn-amd-amdhsa-amdgiz LLVM target. Note that I’m still learning, so this issue will likely change as guided by experience.

Here are the pieces that will be needed to make this work to a MVP level (ie not providing access to most GPU specific stuff):

The address space changes are pretty general. However, in order to not require sweeping changes to how Rust is codegen-ed for LLVM, any target must support a flat address space. Flat meaning an addr space which is a superset of all others.

amdgpu-kernel requires its return type be void. There are two ways I see to do this:

  • compile-time checks (somewhere in rustc), ie disallow any return type except ! and ().
  • rewriting returns to use an sret-like style: promote the return to be an indirect first argument of the function.

As I recall, Rust inserts wrapper functions for functions with extern “abi” which call the real rust abi function. My current impl went with the magical rewriting, but I think forcing the user to acknowledge this with an error is better long term.

Privately, I've made it to errors stemming from # 4 on general Rust code (ie std/core code). See this repo/crate. Regarding virtual function calls, in principle, it’s possible to support, if using HSA, completely GPU side. amdgpu-kernels have access to two different hsa_queue_ts (one for the host and the device), setup by the GPU’s hardware command processor. When a virtual call is encountered, the trick is to have the GPU write to its own hsa_queue_t then wait on the completion signal. Foreign functions can also be supported in this way, by writing to the host hsa_queue_t instead.

Post-MVP

TBD(TODO) Discuss?

Informational links

@LifeIsStrange
Copy link

As the work on NVPTX overlap, there could be some common/shared effort.
#38789

@DiamondLovesYou
Copy link
Contributor Author

I saw that thread! 😄 I have not taken time to read through it, yet, however. Will get to it Soon(TM).

I have an example of my progress, using a Rust fork, from before the i/u128 stabilization ecosystem breakage. This example is from this "trivial" program, and in addition to the AMDGPU specific IR, uses a single source Thingy(TM) (I'm in the process of preparing PRs) to compile functions for a different target than the host.

mir-hsa-ndarray-example.ll. Warning, it's pretty big!

@LifeIsStrange
Copy link

As a side note I guess this project could get some development help from AMD or at least some funding from AMD or the AMD subreddit community because rust would be a net improvement for the gpu computing world !
@johnbridgman
@jedwards-AMD

@mati865
Copy link
Contributor

mati865 commented Sep 19, 2018

Add the amdgpu-kernel ABI (PR #52032).

This one is merged.

@eddyb
Copy link
Member

eddyb commented Sep 25, 2018

As I recall, Rust inserts wrapper functions for functions with extern “abi” which call the real rust abi function

FWIW this was fixed years ago, nowadays we have the tools to talk about call ABIs.

@jonas-schievink jonas-schievink added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Jan 27, 2019
@Titaniumtown
Copy link

Is this ever going to happen? seems the issue has been inactive for some time now.

@DiamondLovesYou
Copy link
Contributor Author

In upstream Rust, not likely: I have absolutely no interest in upstreaming anything anymore. I'm (relatively) actively developing my Rust fork which supports AMDGPU however: https://github.com/geobacter-rs.

@Titaniumtown
Copy link

Very interesting! I'm cloning and compiling that right now to check it out. Thanks for the info!

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 30, 2024
…oli-obk

Remove the `abi_amdgpu_kernel` feature

The tracking issue (rust-lang#51575) has been closed for 3 years, with no activity for 5.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 30, 2024
…oli-obk

Remove the `abi_amdgpu_kernel` feature

The tracking issue (rust-lang#51575) has been closed for 3 years, with no activity for 5.
Nadrieril added a commit to Nadrieril/rust that referenced this issue Jan 31, 2024
…oli-obk

Remove the `abi_amdgpu_kernel` feature

The tracking issue (rust-lang#51575) has been closed for 3 years, with no activity for 5.
Nadrieril added a commit to Nadrieril/rust that referenced this issue Jan 31, 2024
…oli-obk

Remove the `abi_amdgpu_kernel` feature

The tracking issue (rust-lang#51575) has been closed for 3 years, with no activity for 5.
Nadrieril added a commit to Nadrieril/rust that referenced this issue Jan 31, 2024
…oli-obk

Remove the `abi_amdgpu_kernel` feature

The tracking issue (rust-lang#51575) has been closed for 3 years, with no activity for 5.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 31, 2024
Rollup merge of rust-lang#120495 - clubby789:remove-amdgpu-kernel, r=oli-obk

Remove the `abi_amdgpu_kernel` feature

The tracking issue (rust-lang#51575) has been closed for 3 years, with no activity for 5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.
Projects
None yet
Development

No branches or pull requests

6 participants