Skip to content

Commit 705e8fe

Browse files
authored
[Driver][SYCL] Allow for intel_gpu_pvc to pull in the native bfloat lib (#16240)
When using -fsycl-targets=spir64_gen -Xsycl-target-backend "-device pvc" the driver will pull in the native bfloat16 device library. This was not occurring when using -fsycl-targets=intel_gpu_pvc
1 parent 4881d6d commit 705e8fe

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ static bool selectBfloatLibs(const llvm::Triple &Triple, const Compilation &C,
324324
}
325325
}
326326

327+
UseNative = false;
328+
329+
// Check for intel_gpu_pvc as the target
330+
if (Arg *SYCLTarget = Args.getLastArg(options::OPT_fsycl_targets_EQ)) {
331+
if (SYCLTarget->getValues().size() == 1) {
332+
StringRef SYCLTargetStr = SYCLTarget->getValue();
333+
if (SYCLTargetStr == "intel_gpu_pvc")
334+
UseNative = true;
335+
}
336+
}
337+
327338
auto checkBF = [](StringRef Device) {
328339
return Device.starts_with("pvc") || Device.starts_with("ats");
329340
};
@@ -334,8 +345,7 @@ static bool selectBfloatLibs(const llvm::Triple &Triple, const Compilation &C,
334345
Params += Arg;
335346
}
336347
size_t DevicesPos = Params.find("-device ");
337-
UseNative = false;
338-
if (DevicesPos != std::string::npos) {
348+
if (!UseNative && DevicesPos != std::string::npos) {
339349
UseNative = true;
340350
std::istringstream Devices(Params.substr(DevicesPos + 8));
341351
for (std::string S; std::getline(Devices, S, ',');)

clang/test/Driver/sycl-device-lib-bfloat16.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend \
1919
// RUN: "-device pvc" %s --sysroot=%S/Inputs/SYCL -### 2>&1 \
2020
// RUN: | FileCheck %s -check-prefix=BFLOAT16-NATIVE
21+
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc %s \
22+
// RUN: --sysroot=%S/Inputs/SYCL -### 2>&1 \
23+
// RUN: | FileCheck %s -check-prefix=BFLOAT16-NATIVE
2124

2225
// Test that unless all targets support bfloat16, AOT compilation uses the
2326
// fallback library.

0 commit comments

Comments
 (0)