]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #94703 - kjetilkjeka:nvptx-kernel-args-abi2, r=nagisa
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Tue, 26 Apr 2022 11:22:27 +0000 (13:22 +0200)
committerGitHub <noreply@github.com>
Tue, 26 Apr 2022 11:22:27 +0000 (13:22 +0200)
commitfe49981ea0069f6b89e4511d5de92b7027d9b688
tree506d49735cd47ce97bc37e7fbe885cc85c77aa0d
parenteaf8beb3f32b089b426a435794214ee0eaed8fec
parent5bf5acc324f56fad271a97a93b7976d7d3aa67fb
Rollup merge of #94703 - kjetilkjeka:nvptx-kernel-args-abi2, r=nagisa

Fix codegen bug in "ptx-kernel" abi related to arg passing

I found a codegen bug in the nvptx abi related to that args are passed as ptrs ([see comment](https://github.com/rust-lang/rust/issues/38788#issuecomment-1048999928)), this is not as specified in the [ptx-interoperability doc](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/) or how C/C++ does it. It will also almost always fail in practice since device/host uses different memory spaces for most hardware.

This PR fixes the bug and add tests for passing structs to ptx kernels.

I observed that all nvptx assembly tests had been marked as [ignore a long time ago](https://github.com/rust-lang/rust/pull/59752#issuecomment-501713428). I'm not sure if the new one should be marked as ignore, it passed on my computer but it might fail if ptx-linker is missing on the server? I guess this is outside scope for this PR and should be looked at in a different issue/PR.

I only fixed the nvptx64-nvidia-cuda target and not the potential code paths for the non-existing 32bit target. Even though 32bit nvptx is not a supported target there are still some code under the hood supporting codegen for 32 bit ptx. I was advised to create an MCP to find out if this code should be removed or updated.

Perhaps ``@RDambrosio016`` would have interest in taking a quick look at this.
compiler/rustc_middle/src/ty/layout.rs
compiler/rustc_target/src/abi/call/mod.rs
compiler/rustc_target/src/abi/mod.rs