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
16 tasks
@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Jan 2, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 1, 2025
…bilee

Add amdgpu target

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: rust-lang#135024
Kinda related to the original amdgpu tracking issue rust-lang#51575 (though that one has been closed for a while).
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
Rollup of 11 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL)
 - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
 - rust-lang#136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - rust-lang#136283 (Update encode_utf16 to mention it is native endian)
 - rust-lang#136309 (set rustc dylib on manually constructed rustc command)
 - rust-lang#136328 (Rework "long type names" printing logic)
 - rust-lang#136339 (CompileTest: Add Directives to Ignore `arm-unknown-*` Targets)
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
Rollup of 11 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL)
 - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
 - rust-lang#136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - rust-lang#136283 (Update encode_utf16 to mention it is native endian)
 - rust-lang#136309 (set rustc dylib on manually constructed rustc command)
 - rust-lang#136328 (Rework "long type names" printing logic)
 - rust-lang#136339 (CompileTest: Add Directives to Ignore `arm-unknown-*` Targets)
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 1, 2025
…bilee

Add amdgpu target

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: rust-lang#135024
Kinda related to the original amdgpu tracking issue rust-lang#51575 (though that one has been closed for a while).
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL)
 - rust-lang#136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - rust-lang#136283 (Update encode_utf16 to mention it is native endian)
 - rust-lang#136309 (set rustc dylib on manually constructed rustc command)
 - rust-lang#136328 (Rework "long type names" printing logic)
 - rust-lang#136339 (CompileTest: Add Directives to Ignore `arm-unknown-*` Targets)
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: dist-powerpc64-linux
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 1, 2025
…bilee

Add amdgpu target

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: rust-lang#135024
Kinda related to the original amdgpu tracking issue rust-lang#51575 (though that one has been closed for a while).
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#136283 (Update encode_utf16 to mention it is native endian)
 - rust-lang#136309 (set rustc dylib on manually constructed rustc command)
 - rust-lang#136339 (CompileTest: Add Directives to Ignore `arm-unknown-*` Targets)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: dist-powerpc64-linux
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
Rollup of 11 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL)
 - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
 - rust-lang#136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - rust-lang#136283 (Update encode_utf16 to mention it is native endian)
 - rust-lang#136309 (set rustc dylib on manually constructed rustc command)
 - rust-lang#136328 (Rework "long type names" printing logic)
 - rust-lang#136339 (CompileTest: Add Directives to Ignore `arm-unknown-*` Targets)
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: dist-powerpc64-linux
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
Rollup of 11 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL)
 - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
 - rust-lang#136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - rust-lang#136283 (Update encode_utf16 to mention it is native endian)
 - rust-lang#136309 (set rustc dylib on manually constructed rustc command)
 - rust-lang#136328 (Rework "long type names" printing logic)
 - rust-lang#136339 (CompileTest: Add Directives to Ignore `arm-unknown-*` Targets)
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: dist-powerpc64-linux
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 1, 2025
…bilee

Add amdgpu target

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: rust-lang#135024
Kinda related to the original amdgpu tracking issue rust-lang#51575 (though that one has been closed for a while).
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 2, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#136133 (Fix sentence in process::abort)
 - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
 - rust-lang#136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - rust-lang#136328 (Rework "long type names" printing logic)
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 2, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#136133 (Fix sentence in process::abort)
 - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
 - rust-lang#136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - rust-lang#136328 (Rework "long type names" printing logic)
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 2, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - rust-lang#134740 (Add amdgpu target)
 - rust-lang#136133 (Fix sentence in process::abort)
 - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
 - rust-lang#136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - rust-lang#136328 (Rework "long type names" printing logic)
 - rust-lang#136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

@bors rollup=never

@workingjubilee
Copy link
Member

This is blocking other related PRs from proceeding, so

@bors p=1

@workingjubilee
Copy link
Member

workingjubilee commented Feb 2, 2025

Reason for the rollup=never:

@klensy in #136399 (comment):

#134740 adds llvm target, probably increasing libllvm size, should be rollup=never?

@matthiaskrgr in #136399 (comment):

maybe we need exponentially more memory during lto or something with the new target...

if've iffyd #136309 and never'd #134740 let's see if that help..

notable though that none of the other rollup=never prs have landed in the meantime, maybe gh is just having a bad weekend :/

I think that's unlikely, but LLVM does love to randomly have a runaway compile time event, so "unlikely" is certainly not "extremely unlikely" and it's probably just as well.

@workingjubilee
Copy link
Member

Also, if this is suspected of being the reason for failures of rollups, it should just be put through a try-job anyways, since we have enough high-risk jobs in the queue already, we don't need to send something through with only middling confidence it will work:

@bors r-
@bors try

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 2, 2025
@bors
Copy link
Contributor

bors commented Feb 2, 2025

⌛ Trying commit 56795fb with merge 6faa3e6...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 2, 2025
Add amdgpu target

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: rust-lang#135024
Kinda related to the original amdgpu tracking issue rust-lang#51575 (though that one has been closed for a while).

try-job: dist-powerpc-linux
try-job: dist-powerpc64-linux
try-job: dist-powerpc64le-linux
try-job: dist-various-1
try-job: dist-various-2
try-job: aarch64-gnu
@bors
Copy link
Contributor

bors commented Feb 2, 2025

☀️ Try build successful - checks-actions
Build commit: 6faa3e6 (6faa3e6fd2949d5cb421d19522f597501fc751a7)

@saethlin
Copy link
Member

saethlin commented Feb 2, 2025

@bors r=workingjubilee

@bors
Copy link
Contributor

bors commented Feb 2, 2025

📌 Commit 56795fb has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 2, 2025
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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.