Repository navigation
Conversation
|
Thank you for also solving the fixme along the way. I'm at the llvm dev till wednesday, but I'll try to test it a bit in between. @kjetilkjeka you had some ideas on how to configure cpu vs gpu builds, right? fyi @xkevio |
|
For my cargo experiment with offload support this is a step in the right direction, with a little regression. It fits well within the model of building a single "cdylib" (ptx/elf) for the device compilation per binary (as opposed to one per crate). The unfortunate regression is of course that a crate with a single I checked out your PR and added a mapping in I haven't got far enough to test |
This comment has been minimized.
This comment has been minimized.
|
Thanks. I agree that independently of the final design we almost never want to compile the GPU code as a normal binary, even if libc-for-gpu might allow us to do such cursed/funny things. So for now mapping the GPU cratetype seems like the right call, @sgasho can you try to add that? I'd expect that if we remap it early enough it should be unproblematic |
0d7ede9 to
4e185cd
Compare
|
Thanks both. I added the Executable → Cdylib mapping in |
|
Thanks, another hundred lines saved. I tested it on an AMD igpu, where it also works. |
This comment has been minimized.
This comment has been minimized.
|
@bors delegate r=me when rebased |
|
Invalid command: Key-value argument |
|
@bors delegate lgtm, after rebase |
|
Unknown argument "lgtm,". Did you mean to use |
|
I thought bors now allows comments following the command? But I guess that's just for r+. lgtm, after rebase @bors delegate |
4e185cd to
4c05263
Compare
This comment has been minimized.
This comment has been minimized.
4c05263 to
c6749d8
Compare
|
@bors r=ZuseZ4 |
offload: pass the linked device image to the host pass Closes rust-lang#164057 Follow-up to: rust-lang#164455 The host pass now takes the linked device output (`<crate>.ptx` for NVPTX, `<crate>.elf` for AMDGPU) instead of the device bitcode. The device crate must now be built as a cdylib. rustc only passes --export-symbol to llvm-bitcode-linker for cdylibs, so a bin would lose its kernels to internalization. I had to add [lib] in Cargo.toml ```toml [lib] name = "sample_offload" path = "src/main.rs" crate-type = ["cdylib"] ``` Without it, the runtime fails at startup ``` PluginInterface error: Failure to init kernel: "requested object was not found in the binary image" error in cuModuleGetFunction('_RNvC14sample_offload6kernel'): named symbol not found omptarget error: Failed to load kernel _RNvC14sample_offload6kernel ``` I’m not sure whether bin device crates should export their kernels too, so I left the linker untouched for now. The second commit fixes another runtime error without `--emit=llvm-bc`/`llvm-ir`. (my understanding is that we should not have to set these after this PR, because no device.bc anymore) The “already wrapped” check in handle_offload relied on a value name, which LLVM drops unless --emit=llvm-bc/llvm-ir is given, so the kernel got wrapped twice. I verified on UofT nvidia gpunode (amdgpunodes was not available for my account). r? ZuseZ4
offload: pass the linked device image to the host pass Closes rust-lang#164057 Follow-up to: rust-lang#164455 The host pass now takes the linked device output (`<crate>.ptx` for NVPTX, `<crate>.elf` for AMDGPU) instead of the device bitcode. The device crate must now be built as a cdylib. rustc only passes --export-symbol to llvm-bitcode-linker for cdylibs, so a bin would lose its kernels to internalization. I had to add [lib] in Cargo.toml ```toml [lib] name = "sample_offload" path = "src/main.rs" crate-type = ["cdylib"] ``` Without it, the runtime fails at startup ``` PluginInterface error: Failure to init kernel: "requested object was not found in the binary image" error in cuModuleGetFunction('_RNvC14sample_offload6kernel'): named symbol not found omptarget error: Failed to load kernel _RNvC14sample_offload6kernel ``` I’m not sure whether bin device crates should export their kernels too, so I left the linker untouched for now. The second commit fixes another runtime error without `--emit=llvm-bc`/`llvm-ir`. (my understanding is that we should not have to set these after this PR, because no device.bc anymore) The “already wrapped” check in handle_offload relied on a value name, which LLVM drops unless --emit=llvm-bc/llvm-ir is given, so the kernel got wrapped twice. I verified on UofT nvidia gpunode (amdgpunodes was not available for my account). r? ZuseZ4
…uwer Rollup of 15 pull requests Successful merges: - #165378 (rustfmt subtree update (v1.12.0)) - #149245 (Make inline attributes apply to the generated `poll` in async fn) - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - #165109 (Avoid building a region map when erasing bound regions) - #163393 (std: Use getexecpath() for current_exe() on OpenBSD) - #164896 (offload: pass the linked device image to the host pass) - #165358 (Reenable some cg_gcc tests that were disabled) - #165371 (Don't use `llvm_type` as the type of `static`s.) - #162232 (Replace `builtin #` with `k#`) - #162608 (Avoid oscillating line wrapping due to symbol indices) - #165029 (Use `MalformedLintAttributeInput` in more places) - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - #165230 (Fix rigidity assertion ICE) - #165354 (Remove `AbiAlign`) - #165374 (Refactorings in preparation for the move trait)
offload: pass the linked device image to the host pass Closes rust-lang#164057 Follow-up to: rust-lang#164455 The host pass now takes the linked device output (`<crate>.ptx` for NVPTX, `<crate>.elf` for AMDGPU) instead of the device bitcode. The device crate must now be built as a cdylib. rustc only passes --export-symbol to llvm-bitcode-linker for cdylibs, so a bin would lose its kernels to internalization. I had to add [lib] in Cargo.toml ```toml [lib] name = "sample_offload" path = "src/main.rs" crate-type = ["cdylib"] ``` Without it, the runtime fails at startup ``` PluginInterface error: Failure to init kernel: "requested object was not found in the binary image" error in cuModuleGetFunction('_RNvC14sample_offload6kernel'): named symbol not found omptarget error: Failed to load kernel _RNvC14sample_offload6kernel ``` I’m not sure whether bin device crates should export their kernels too, so I left the linker untouched for now. The second commit fixes another runtime error without `--emit=llvm-bc`/`llvm-ir`. (my understanding is that we should not have to set these after this PR, because no device.bc anymore) The “already wrapped” check in handle_offload relied on a value name, which LLVM drops unless --emit=llvm-bc/llvm-ir is given, so the kernel got wrapped twice. I verified on UofT nvidia gpunode (amdgpunodes was not available for my account). r? ZuseZ4
…uwer Rollup of 14 pull requests Successful merges: - #165378 (rustfmt subtree update (v1.12.0)) - #149245 (Make inline attributes apply to the generated `poll` in async fn) - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - #165109 (Avoid building a region map when erasing bound regions) - #163393 (std: Use getexecpath() for current_exe() on OpenBSD) - #164896 (offload: pass the linked device image to the host pass) - #165358 (Reenable some cg_gcc tests that were disabled) - #165371 (Don't use `llvm_type` as the type of `static`s.) - #162232 (Replace `builtin #` with `k#`) - #162608 (Avoid oscillating line wrapping due to symbol indices) - #165029 (Use `MalformedLintAttributeInput` in more places) - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - #165230 (Fix rigidity assertion ICE) - #165374 (Refactorings in preparation for the move trait)
offload: pass the linked device image to the host pass Closes rust-lang#164057 Follow-up to: rust-lang#164455 The host pass now takes the linked device output (`<crate>.ptx` for NVPTX, `<crate>.elf` for AMDGPU) instead of the device bitcode. The device crate must now be built as a cdylib. rustc only passes --export-symbol to llvm-bitcode-linker for cdylibs, so a bin would lose its kernels to internalization. I had to add [lib] in Cargo.toml ```toml [lib] name = "sample_offload" path = "src/main.rs" crate-type = ["cdylib"] ``` Without it, the runtime fails at startup ``` PluginInterface error: Failure to init kernel: "requested object was not found in the binary image" error in cuModuleGetFunction('_RNvC14sample_offload6kernel'): named symbol not found omptarget error: Failed to load kernel _RNvC14sample_offload6kernel ``` I’m not sure whether bin device crates should export their kernels too, so I left the linker untouched for now. The second commit fixes another runtime error without `--emit=llvm-bc`/`llvm-ir`. (my understanding is that we should not have to set these after this PR, because no device.bc anymore) The “already wrapped” check in handle_offload relied on a value name, which LLVM drops unless --emit=llvm-bc/llvm-ir is given, so the kernel got wrapped twice. I verified on UofT nvidia gpunode (amdgpunodes was not available for my account). r? ZuseZ4
…uwer Rollup of 14 pull requests Successful merges: - #149245 (Make inline attributes apply to the generated `poll` in async fn) - #164304 ([perf] Reuse CanonicalVarKinds if no new variables were added) - #165109 (Avoid building a region map when erasing bound regions) - #163393 (std: Use getexecpath() for current_exe() on OpenBSD) - #164896 (offload: pass the linked device image to the host pass) - #165358 (Reenable some cg_gcc tests that were disabled) - #165371 (Don't use `llvm_type` as the type of `static`s.) - #162232 (Replace `builtin #` with `k#`) - #162608 (Avoid oscillating line wrapping due to symbol indices) - #164241 (make the safety documentation consistent in Ptr module) - #165029 (Use `MalformedLintAttributeInput` in more places) - #165203 (AIX: Implement TLS destructor guard in std and update dynamic-loading-cdylib test) - #165230 (Fix rigidity assertion ICE) - #165374 (Refactorings in preparation for the move trait)
|
💔 I suspect this PR failed tests as part of a rollup After fixing the problem, consider running a try job for the failed job before re-approving. Link to failure: #165400 (comment) |
|
This pull request was unapproved. This PR was contained in a rollup (#165400), which was unapproved. |
This comment has been minimized.
This comment has been minimized.
offload: pass the linked device image to the host pass try-job: test-various
|
💔 Test for cac7381 failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
|
just added @bors try jobs=test-various |
offload: pass the linked device image to the host pass try-job: test-various
This comment has been minimized.
This comment has been minimized.
|
@bors r=ZuseZ4 |
View all comments
Closes #164057
Follow-up to: #164455
The host pass now takes the linked device output (
<crate>.ptxfor NVPTX,<crate>.elffor AMDGPU) instead of the device bitcode.The device crate must now be built as a cdylib. rustc only passes --export-symbol to llvm-bitcode-linker for cdylibs, so a bin would lose its kernels to internalization.
I had to add [lib] in Cargo.toml
Without it, the runtime fails at startup
I’m not sure whether bin device crates should export their kernels too, so I left the linker untouched for now.
The second commit fixes another runtime error without
--emit=llvm-bc/llvm-ir. (my understanding is that we should not have to set these after this PR, because no device.bc anymore)The “already wrapped” check in handle_offload relied on a value name, which LLVM drops unless --emit=llvm-bc/llvm-ir is given, so the kernel got wrapped twice.
I verified on UofT nvidia gpunode (amdgpunodes was not available for my account).
r? ZuseZ4