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

Add amdgpu target #134740

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add amdgpu target #134740

wants to merge 1 commit into from

Conversation

Flakebi
Copy link
Contributor

@Flakebi Flakebi commented Dec 25, 2024

Add amdgpu target to rustc and enable the LLVM target.

Fix compiling core with the amdgpu:
The amdgpu backend makes heavy use of different address spaces. This
leads to situations, where a pointer in one addrspace needs to be casted
to a pointer in a different addrspace. bitcast is invalid for this
case, addrspacecast needs to be used.

Fix compilation failures that created bitcasts for such cases by
creating pointer casts (which creates an addrspacecast under the hood)
instead.

MCP: rust-lang/compiler-team#823
Tracking issue: #135024
Kinda related to the original amdgpu tracking issue #51575 (though that one has been closed for a while).

@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 25, 2024
@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2024

These commits modify compiler targets.
(See the Target Tier Policy.)

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

Some changes occurred in src/doc/rustc/src/platform-support

cc @Noratrieb

This PR modifies config.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@jieyouxu
Copy link
Member

r? jieyouxu

@rustbot rustbot assigned jieyouxu and unassigned GuillaumeGomez Dec 25, 2024
@workingjubilee
Copy link
Member

cc @eddyb Hello, tagging you for domain expertise if you want to chime in.

@jieyouxu
Copy link
Member

jieyouxu commented Dec 25, 2024

Thanks for the PR, @Flakebi. I'm going to request that you open a MCP at https://github.com/rust-lang/compiler-team/issues/ to gauge team consensus for adding this target, primarily to give compiler team members some opportunity to ask clarifying questions and register possible concerns, since:

  • Adding this target requires modifying codegen_llvm in a non-trivial way (emitting at times
    addrspacecast instead of bitcast). In particular, as you stated, this target has a
    non-conventional addrspace usage model that I believe we don't quite observe in other existing
    targets:

    The amdgpu backend makes heavy use of different address spaces. This leads to situations,
    where a pointer in one addrspace needs to be casted to a pointer in a different addrspace.
    bitcast is invalid for this case, addrspacecast needs to be used.

  • This requires modifying the LLVM build to also include the AMDGPU backend.

  • This target seems to be intended for many different CPUs of varying hardware generation, but the
    present target definition defaults to gfx900.

Note that usually adding more "conventional" Tier 3 targets do not need to go through the MCP process, but this target looks not so conventional.

@jieyouxu jieyouxu added needs-mcp This change is large enough that it needs a major change proposal before starting work. A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Dec 25, 2024
@jieyouxu
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 25, 2024
@Flakebi
Copy link
Contributor Author

Flakebi commented Dec 26, 2024

Thank you for the quick review!

I opened an MCP here: rust-lang/compiler-team#823

@traviscross
Copy link
Contributor

cc @ZuseZ4

@jieyouxu jieyouxu added S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. needs-mcp This change is large enough that it needs a major change proposal before starting work. labels Dec 26, 2024
@bors
Copy link
Contributor

bors commented Dec 27, 2024

☔ The latest upstream changes (presumably #134822) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 27, 2024
@jieyouxu jieyouxu removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 31, 2024
@Flakebi Flakebi mentioned this pull request Jan 2, 2025
12 tasks
@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Jan 2, 2025
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 2, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 2, 2025
@Flakebi
Copy link
Contributor Author

Flakebi commented Jan 2, 2025

I removed changes apart from adding the target and enabling the LLVM backend from this PR. They will go into their own PRs.
I extended the platform-support documentation a bit.

There is now a tracking issue: #135024

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 5, 2025

☔ The latest upstream changes (presumably #135074) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 5, 2025
@Flakebi
Copy link
Contributor Author

Flakebi commented Jan 14, 2025

Rebased to fix conflicts and fix tests, no changes to the target.

Add target and compile the amdgpu llvm backend.
@Flakebi
Copy link
Contributor Author

Flakebi commented Jan 22, 2025

Extend target documentation.
I found out that HIP can be used to load/run amdgpu binaries as well (in addition to HSA), and it works on Linux and Windows!
Diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants