Skip to content

Commit 2c98fd8

Browse files
authored
[Driver][SYCL] Fix parsing of device values in backend target opts (#15876)
The use of -Xsycl-target-backend=target "opts" was not properly being captured when attempting to find device values to set default values to be used during AOT compilations for GEN.
1 parent 1c1a964 commit 2c98fd8

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,16 @@ void SYCLToolChain::AddImpliedTargetArgs(const llvm::Triple &Triple,
17801780
ArgStringList TargArgs;
17811781
Args.AddAllArgValues(TargArgs, options::OPT_Xs, options::OPT_Xs_separate);
17821782
Args.AddAllArgValues(TargArgs, options::OPT_Xsycl_backend);
1783+
// For -Xsycl-target-backend=<triple> the triple value is used to push
1784+
// specific options to the matching device compilation using that triple.
1785+
// Scrutinize this to make sure we are only checking the values needed
1786+
// for the current device compilation.
1787+
for (auto *A : Args) {
1788+
if (!A->getOption().matches(options::OPT_Xsycl_backend_EQ))
1789+
continue;
1790+
if (getDriver().MakeSYCLDeviceTriple(A->getValue()) == Triple)
1791+
TargArgs.push_back(A->getValue(1));
1792+
}
17831793
// Check for any -device settings.
17841794
std::string DevArg;
17851795
if (IsJIT || Device == "pvc" || hasPVCDevice(TargArgs, DevArg)) {

clang/test/Driver/sycl-ftarget-register-alloc-mode-old-model.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
// RUN: -fsycl-targets=spir64_gen -Xs "-device pvc" %s 2>&1 \
2121
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc
2222

23+
// RUN: %clang -### -fsycl --no-offload-new-driver \
24+
// RUN: -fsycl-targets=spir64_gen -Xsycl-target-backend "-device pvc" %s 2>&1 \
25+
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc
26+
27+
// RUN: %clang -### -fsycl --no-offload-new-driver \
28+
// RUN: -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device pvc" %s 2>&1 \
29+
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc
30+
2331
// RUN: %clang -### -fsycl --no-offload-new-driver \
2432
// RUN: -fsycl-targets=spir64_gen -Xs "-device 0x0BD5" %s 2>&1 \
2533
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc

clang/test/Driver/sycl-ftarget-register-alloc-mode.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
// RUN: -fsycl-targets=spir64_gen -Xs "-device pvc" %s 2>&1 \
2121
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc
2222

23+
// RUN: %clang -### -fsycl --offload-new-driver \
24+
// RUN: -fsycl-targets=spir64_gen -Xsycl-target-backend "-device pvc" %s 2>&1 \
25+
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc
26+
27+
// RUN: %clang -### -fsycl --offload-new-driver \
28+
// RUN: -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device pvc" %s 2>&1 \
29+
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc
30+
2331
// RUN: %clang -### -fsycl --offload-new-driver \
2432
// RUN: -fsycl-targets=spir64_gen -Xs "-device 0x0BD5" %s 2>&1 \
2533
// RUN: | FileCheck %if system-windows %{ -check-prefix=DEFAULT_AOT %} %else %{ -check-prefix=AUTO_AOT %} %s -DDEVICE=pvc

clang/test/Driver/sycl-offload-new-driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
// RUN: %clangxx -fsycl -### -fsycl-targets=spir64_gen --offload-new-driver \
188188
// RUN: -Xsycl-target-backend=spir64_gen "-device pvc,bdw" %s 2>&1 \
189189
// RUN: | FileCheck -check-prefix COMMA_FILE %s
190-
// COMMA_FILE: clang-offload-packager{{.*}} "--image=file={{.*}}pvc@bdw{{.*}},triple=spir64_gen-unknown-unknown,arch=pvc,bdw,kind=sycl"
190+
// COMMA_FILE: clang-offload-packager{{.*}} "--image=file={{.*}}pvc@bdw{{.*}},triple=spir64_gen-unknown-unknown,arch=pvc,bdw,kind=sycl,compile-opts=-device_options pvc -ze-intel-enable-auto-large-GRF-mode"
191191

192192
/// Verify that --cuda-path is passed to clang-linker-wrapper for SYCL offload
193193
// RUN: %clangxx -fsycl -### -fsycl-targets=nvptx64-nvidia-cuda \

0 commit comments

Comments
 (0)