[SYCL][NewOffloadModel] Enable -no-sycl-rdc in Clang Driver for NewOffloadModel. - #21973
[SYCL][NewOffloadModel] Enable -no-sycl-rdc in Clang Driver for NewOffloadModel.#21973maksimsab wants to merge 2 commits into
Conversation
ed80080 to
062564b
Compare
c76c3cf to
d34f71d
Compare
d34f71d to
ff0bd11
Compare
|
Note: when SYCL offloading processing moves from clang-linker-wrapper to clang-sycl-linker we would be able to move the handling of -no-rdc-sycl from linking step to compilation step. |
| clang++ --no-offload-old-driver -fsycl -fsycl-targets=T1,T2 input1.cpp -fno-sycl-rdc -c -o object1.o # -fno-sycl-rdc is specified | ||
| clang++ --no-offload-old-driver -fsycl -fsycl-targets=T1,T2 input2.cpp -fno-sycl-rdc -c -o object2.o # -fno-sycl-rdc is specified | ||
| clang++ --no-offload-old-driver -fsycl -fsycl-targets=T1,T2 object1.o object2.o -o a.out # -fno-sycl-rdc is NOT specified |
There was a problem hiding this comment.
| clang++ --no-offload-old-driver -fsycl -fsycl-targets=T1,T2 input1.cpp -fno-sycl-rdc -c -o object1.o # -fno-sycl-rdc is specified | |
| clang++ --no-offload-old-driver -fsycl -fsycl-targets=T1,T2 input2.cpp -fno-sycl-rdc -c -o object2.o # -fno-sycl-rdc is specified | |
| clang++ --no-offload-old-driver -fsycl -fsycl-targets=T1,T2 object1.o object2.o -o a.out # -fno-sycl-rdc is NOT specified | |
| clang++ --no-offload-new-driver -fsycl -fsycl-targets=T1,T2 input1.cpp -fno-sycl-rdc -c -o object1.o # -fno-sycl-rdc is specified | |
| clang++ --no-offload-new-driver -fsycl -fsycl-targets=T1,T2 input2.cpp -fno-sycl-rdc -c -o object2.o # -fno-sycl-rdc is specified | |
| clang++ --no-offload-new-driver -fsycl -fsycl-targets=T1,T2 object1.o object2.o -o a.out # -fno-sycl-rdc is NOT specified |
| // CHK-AOT-NO-RDC: clang-linker-wrapper{{.*}} "--no-sycl-rdc" | ||
|
|
||
| // Test compilation step. | ||
| // RUN: not %clang -### --offload-new-driver -Werror --target=x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_gen -fno-sycl-rdc %t.cpp -c -o %t.o 2>&1 \ |
There was a problem hiding this comment.
This is the base usage with the old offloading model, where the expectation is for -fno-sycl-rdc -c creates a fully linked device binary and bundles it with the host object. How are we planning on supporting this?
There was a problem hiding this comment.
I put this together for the upstream state of code: https://github.com/YuriPlyakhin/llvm-project/blob/6553d362c5e84114a30eff3a79cad70432fff3ef/sycl-no-rdc-plan.md
maybe downstream we can do similar flow, with a modification to call clang-linker-wrapper instead of clang-sycl-linker.
There was a problem hiding this comment.
The current patch handles -fno-sycl-rdc at the link step, but the old offload model supported it at the compile step (-fno-sycl-rdc -c), where each object file's device code was fully finalized and self-contained before final link.
Supporting this in the new offload model requires invoking clang-linker-wrapper --sycl-device-link --no-sycl-rdc per translation unit at compile time (analogous to how upstream uses clang-sycl-linker per-TU), plus a new CC1 option to pass the finalized image to the host compile for embedding and registration. That is a non-trivial driver + CodeGen change that is best tracked separately to keep this patch focused and reviewable. I'll open a follow-up patch for that. WDYT @YuriPlyakhin @mdtoguchi @sarnex
There was a problem hiding this comment.
supporting -c -fno-sycl-rdc in a follow up seems fine to me
| clang++ --offload-new-driver -fsycl -fsycl-targets=T1,T2 input1.cpp -c -o object1.o # -fno-sycl-rdc is NOT specified | ||
| clang++ --offload-new-driver -fsycl -fsycl-targets=T1,T2 input2.cpp -c -o object2.o # -fno-sycl-rdc is NOT specified | ||
| clang++ --offload-new-driver -fsycl -fsycl-targets=T1,T2 -fno-sycl-rdc object1.o object2.o -o a.out # -fno-sycl-rdc is specified |
There was a problem hiding this comment.
that creates divergence with no-sycl-rdc behavior of old offloading model and with no-gpu-rdc behavior of other programming models. I think we need to redesign the behavior to align with other programming models and old offloading model.
while we have offloading processing in |
…Offload Model (#22832) ## Summary This patch adds `-fno-sycl-rdc` support to the new SYCL offload model in the Clang driver. It is based on the work by @maksimsab in #21973, with review fixes applied. ### What this patch does By default (`-fsycl-rdc`), all device code across translation units is linked together into one module at link time before post-link processing. With `-fno-sycl-rdc`, each object file's device code is processed independently — skipping the `llvm-link` step — which can significantly reduce peak memory and compile time. **Changes:** - `clang/lib/Driver/ToolChains/Clang.cpp`: In `LinkerWrapper::ConstructJob`, propagate `--no-sycl-rdc` to `clang-linker-wrapper` when `-fno-sycl-rdc` is passed at link time. - `sycl/doc/design/OffloadDesign.md`: Document NoRDC mode for the new offload model. - `sycl/doc/design/NonRelocatableDeviceCode.md`: Add a note clarifying that document covers the old offload model only. - `sycl/test-e2e/AOT/early_aot.cpp`: Un-XFAIL the test for the new offload model; adjust RUN lines to pass `-fno-sycl-rdc` at the correct step per model. - `clang/test/Driver/sycl-no-rdc-new-driver.cpp`: New driver test verifying `--no-sycl-rdc` is propagated to `clang-linker-wrapper` correctly. ### Key behavioral difference from the old offload model | Model | Where to pass `-fno-sycl-rdc` | |---|---| | Old (`--no-offload-new-driver`) | At each **compile** step (`-c`) | | New (`--offload-new-driver`) | At the **link** step | This inversion exists because in the new model all SYCL offload processing (post-link, AOT, wrapping) lives in `clang-linker-wrapper` at link time. ### Follow-up work Supporting `-fno-sycl-rdc -c` in the new model (matching the old model's compile-step ergonomics) will be addressed in a follow-up patch. The plan is to invoke `clang-linker-wrapper --sycl-device-link --no-sycl-rdc` per translation unit at compile time, embedding the finalized device image directly into the host object. Supporting -fno-sycl-rdc -c in the new model (matching old model compile-step ergonomics) is addressed in #22833. Fixes: CMPLRLLVM-51875 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Sabianin, Maksim <maksim.sabianin@intel.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
|
should this one be closed in favor of #22832? |
Propagate --no-sycl-rdc from Clang Driver to clang-linker-wrapper when New Offload Model is enabled.