Repository navigation
offload: remove device.bin and pass device bitcode directly - #164455
Conversation
2c08c13 to
80d95cc
Compare
|
Iterating over all functions to get a target-cpu doesn't seem great, but should work for now and become unnecessary with the follow-up PR, so lgtm. Thanks! @bors r+ rollup |
This comment has been minimized.
This comment has been minimized.
offload: remove device.bin and pass device bitcode directly related: #164057 Since #162309 removed the `clang-linker-wrapper` step, nothing reads `device.bin` anymore, and its triple/arch are already in the bitcode. So, as the first step, I removed steps generating and extracting device.bin, instead we're going to use the device bitcode. As a next step, the host pass could take the linked device output(`.ptx` for NVPTX, `.elf` for AMDGPU) instead, which would remove the second codegen. I'd like to do that in a separate PR. I'll update rustc-dev-guide in a follow-up PR in their repo. I verified that this change works by running offload sample code on UofT gpunode. r? ZuseZ4
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test for 42d559d failed: CI. Failed job:
|
|
spurious @bors r+ rollup |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 02fb0a1 (parent) -> 33295d7 (this PR) Test differencesShow 2 test diffs2 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 33295d734447c7a2c22c44190f11bce6164a035a --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (33295d7): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (secondary -3.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 5.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 489.75s -> 488.147s (-0.33%) |
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
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
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
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
Rollup merge of #164896 - sgasho:offload-cleanup-2, r=ZuseZ4 offload: pass the linked device image to the host pass Closes #164057 Follow-up to: #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
related: #164057
Since #162309 removed the
clang-linker-wrapperstep, nothing readsdevice.binanymore, and its triple/arch are already in the bitcode.
So, as the first step, I removed steps generating and extracting device.bin, instead we're going to use the device bitcode.
As a next step, the host pass could take the linked device output(
.ptxfor NVPTX,.elffor AMDGPU) instead, whichwould remove the second codegen. I'd like to do that in a separate PR.
I'll update rustc-dev-guide in a follow-up PR in their repo.
I verified that this change works by running offload sample code on UofT gpunode.
r? ZuseZ4