Skip to content

Commit 60e97e7

Browse files
authored
[Driver][SYCL] Improve AOT option passing with intel_gpu targets (#8419)
When using -fsycl-targets=intel_gpu* -Xsycl-target-backend=intel_gpu* "opts" be sure to pass "opts" to the ocloc call. These specially handled target values imply spir64_gen but were not processed properly to be able to scrutinize various target possibilities.
1 parent 045f5ab commit 60e97e7

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -901,17 +901,14 @@ void SYCLToolChain::TranslateTargetOpt(const llvm::opt::ArgList &Args,
901901
OptNoTriple = A->getOption().matches(Opt);
902902
if (A->getOption().matches(Opt_EQ)) {
903903
// Passing device args: -X<Opt>=<triple> -opt=val.
904-
if (getDriver().MakeSYCLDeviceTriple(A->getValue()) != getTriple())
904+
StringRef GenDevice = SYCL::gen::resolveGenDevice(A->getValue());
905+
if (getDriver().MakeSYCLDeviceTriple(A->getValue()) != getTriple() &&
906+
GenDevice.empty())
905907
// Provided triple does not match current tool chain.
906908
continue;
907-
if (getTriple().isSPIR() &&
908-
getTriple().getSubArch() == llvm::Triple::SPIRSubArch_gen) {
909-
if (Device.empty() && StringRef(A->getValue()).startswith("intel_gpu"))
910-
continue;
911-
if (!Device.empty() &&
912-
getDriver().MakeSYCLDeviceTriple(A->getValue()) == getTriple())
913-
continue;
914-
}
909+
if (Device != GenDevice && getTriple().isSPIR() &&
910+
getTriple().getSubArch() == llvm::Triple::SPIRSubArch_gen)
911+
continue;
915912
} else if (!OptNoTriple)
916913
// Don't worry about any of the other args, we only want to pass what is
917914
// passed in -X<Opt>

clang/test/Driver/sycl-oneapi-gpu.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,16 @@
382382
// CHECK_PHASES_MIX: 26: file-table-tform, {22, 25}, tempfiletable, (device-sycl)
383383
// CHECK_PHASES_MIX: 27: clang-offload-wrapper, {26}, object, (device-sycl)
384384
// CHECK_PHASES_MIX: 28: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (spir64_gen-unknown-unknown:skl)" {20}, "device-sycl (spir64_gen-unknown-unknown)" {27}, image
385+
386+
/// Check that ocloc backend option settings only occur for the expected
387+
/// toolchains when mixing spir64_gen and intel_gpu
388+
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg1,spir64_gen,intel_gpu_skl \
389+
// RUN: -Xsycl-target-backend=spir64_gen "-device skl -DSKL" \
390+
// RUN: -Xsycl-target-backend=intel_gpu_dg1 "-DDG1" \
391+
// RUN: -Xsycl-target-backend=intel_gpu_skl "-DSKL2" \
392+
// RUN: -fno-sycl-device-lib=all -fno-sycl-instrument-device-code \
393+
// RUN: -target x86_64-unknown-linux-gnu -### %s 2>&1 | \
394+
// RUN: FileCheck %s --check-prefix=CHECK_TOOLS_BEOPTS
395+
// CHECK_TOOLS_BEOPTS: ocloc{{.*}} "-device" "dg1" "-DDG1"
396+
// CHECK_TOOLS_BEOPTS: ocloc{{.*}} "-device" "skl" "-DSKL"
397+
// CHECK_TOOLS_BEOPTS: ocloc{{.*}} "-device" "skl" "-DSKL2"

0 commit comments

Comments
 (0)