Skip to content
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
14 changes: 12 additions & 2 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,17 @@ static bool selectBfloatLibs(const llvm::Triple &Triple, const Compilation &C,
}
}

UseNative = false;

// Check for intel_gpu_pvc as the target
if (Arg *SYCLTarget = Args.getLastArg(options::OPT_fsycl_targets_EQ)) {
if (SYCLTarget->getValues().size() == 1) {
StringRef SYCLTargetStr = SYCLTarget->getValue();
if (SYCLTargetStr == "intel_gpu_pvc")
UseNative = true;
}
}

auto checkBF = [](StringRef Device) {
return Device.starts_with("pvc") || Device.starts_with("ats");
};
Expand All @@ -334,8 +345,7 @@ static bool selectBfloatLibs(const llvm::Triple &Triple, const Compilation &C,
Params += Arg;
}
size_t DevicesPos = Params.find("-device ");
UseNative = false;
if (DevicesPos != std::string::npos) {
if (!UseNative && DevicesPos != std::string::npos) {
UseNative = true;
std::istringstream Devices(Params.substr(DevicesPos + 8));
for (std::string S; std::getline(Devices, S, ',');)
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Driver/sycl-device-lib-bfloat16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend \
// RUN: "-device pvc" %s --sysroot=%S/Inputs/SYCL -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-NATIVE
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc %s \
// RUN: --sysroot=%S/Inputs/SYCL -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-NATIVE

// Test that unless all targets support bfloat16, AOT compilation uses the
// fallback library.
Expand Down
Loading