Skip to content

[Driver][SYCL] Improve AOT option passing with intel_gpu targets #8419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,17 +901,14 @@ void SYCLToolChain::TranslateTargetOpt(const llvm::opt::ArgList &Args,
OptNoTriple = A->getOption().matches(Opt);
if (A->getOption().matches(Opt_EQ)) {
// Passing device args: -X<Opt>=<triple> -opt=val.
if (getDriver().MakeSYCLDeviceTriple(A->getValue()) != getTriple())
StringRef GenDevice = SYCL::gen::resolveGenDevice(A->getValue());
if (getDriver().MakeSYCLDeviceTriple(A->getValue()) != getTriple() &&
GenDevice.empty())
// Provided triple does not match current tool chain.
continue;
if (getTriple().isSPIR() &&
getTriple().getSubArch() == llvm::Triple::SPIRSubArch_gen) {
if (Device.empty() && StringRef(A->getValue()).startswith("intel_gpu"))
continue;
if (!Device.empty() &&
getDriver().MakeSYCLDeviceTriple(A->getValue()) == getTriple())
continue;
}
if (Device != GenDevice && getTriple().isSPIR() &&
getTriple().getSubArch() == llvm::Triple::SPIRSubArch_gen)
continue;
} else if (!OptNoTriple)
// Don't worry about any of the other args, we only want to pass what is
// passed in -X<Opt>
Expand Down
13 changes: 13 additions & 0 deletions clang/test/Driver/sycl-oneapi-gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,16 @@
// CHECK_PHASES_MIX: 26: file-table-tform, {22, 25}, tempfiletable, (device-sycl)
// CHECK_PHASES_MIX: 27: clang-offload-wrapper, {26}, object, (device-sycl)
// 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

/// Check that ocloc backend option settings only occur for the expected
/// toolchains when mixing spir64_gen and intel_gpu
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg1,spir64_gen,intel_gpu_skl \
// RUN: -Xsycl-target-backend=spir64_gen "-device skl -DSKL" \
// RUN: -Xsycl-target-backend=intel_gpu_dg1 "-DDG1" \
// RUN: -Xsycl-target-backend=intel_gpu_skl "-DSKL2" \
// RUN: -fno-sycl-device-lib=all -fno-sycl-instrument-device-code \
// RUN: -target x86_64-unknown-linux-gnu -### %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=CHECK_TOOLS_BEOPTS
// CHECK_TOOLS_BEOPTS: ocloc{{.*}} "-device" "dg1" "-DDG1"
// CHECK_TOOLS_BEOPTS: ocloc{{.*}} "-device" "skl" "-DSKL"
// CHECK_TOOLS_BEOPTS: ocloc{{.*}} "-device" "skl" "-DSKL2"