Skip to content

Commit

Permalink
[SYCL][Driver] Link Native BF16 devicelib for lnl target (#17154)
Browse files Browse the repository at this point in the history
Lunarlake platform supports native bf16 conversions, should link native
bf16 devicelib.

---------

Signed-off-by: jinge90 <[email protected]>
  • Loading branch information
jinge90 authored Mar 5, 2025
1 parent a43af18 commit a9295c1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
7 changes: 4 additions & 3 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ static bool selectBfloatLibs(const llvm::Triple &Triple, const Compilation &C,

static llvm::SmallSet<StringRef, 8> GPUArchsWithNBF16{
"intel_gpu_pvc", "intel_gpu_acm_g10", "intel_gpu_acm_g11",
"intel_gpu_acm_g12", "intel_gpu_dg2_10", "intel_gpu_dg2_11",
"intel_dg2_g12", "intel_gpu_bmg_g21"};
"intel_gpu_acm_g12", "intel_gpu_dg2_g10", "intel_gpu_dg2_g11",
"intel_dg2_g12", "intel_gpu_bmg_g21", "intel_gpu_lnl_m"};
const llvm::opt::ArgList &Args = C.getArgs();
bool NeedLibs = false;

Expand Down Expand Up @@ -351,7 +351,8 @@ static bool selectBfloatLibs(const llvm::Triple &Triple, const Compilation &C,

auto checkBF = [](StringRef Device) {
return Device.starts_with("pvc") || Device.starts_with("ats") ||
Device.starts_with("dg2") || Device.starts_with("bmg");
Device.starts_with("dg2") || Device.starts_with("bmg") ||
Device.starts_with("lnl");
};

auto checkSpirvJIT = [](StringRef Target) {
Expand Down
42 changes: 37 additions & 5 deletions clang/test/Driver/sycl-device-lib-bfloat16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
// RUN: --sysroot=%S/Inputs/SYCL %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NONE

// Test test AOT-DG1 + JIT compilation uses native libs + no libs
// Test AOT-DG1 + JIT compilation uses native libs + no libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg1,spir64 \
// RUN: --sysroot=%S/Inputs/SYCL %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-NONE
Expand All @@ -113,7 +113,7 @@
// RUN: --sysroot=%S/Inputs/SYCL %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-NONE

// Test test AOT-PVC + JIT compilation + AOT-DG2 uses native libs + no libs + native libs
// Test AOT-PVC + JIT compilation + AOT-DG2 uses native libs + no libs + native libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc,spir64,intel_gpu_acm_g10 \
// RUN: --sysroot=%S/Inputs/SYCL %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NONE-NATIVE
Expand All @@ -127,7 +127,7 @@
// RUN: --sysroot=%S/Inputs/SYCL %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NONE-NATIVE

// Test test AOT-PVC + JIT compilation + AOT-DG1 uses fallback libs + no libs + fallback libs
// Test AOT-PVC + JIT compilation + AOT-DG1 uses fallback libs + no libs + fallback libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc,spir64,intel_gpu_dg1 \
// RUN: --sysroot=%S/Inputs/SYCL %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-NONE-FALLBACK
Expand All @@ -141,22 +141,54 @@
// RUN: --sysroot=%S/Inputs/SYCL %s -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-NONE-FALLBACK

// Test test AOT-PVC + AOT-DG1 specified via different options, uses fallback libs
// Test AOT-PVC + AOT-DG1 specified via different options, uses fallback libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device dg1" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-FALLBACK
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg1,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device pvc" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-FALLBACK

// Test test AOT-PVC + AOT-BMG specified via different options, uses native libs
// Test AOT-PVC + AOT-BMG specified via different options, uses native libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_bmg_g21,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device pvc" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NATIVE
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device bmg-g21-a0" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NATIVE

// Test AOT-DG2 + AOT-DG1 specified via different options, uses fallback libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device dg1" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-FALLBACK
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg1,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device dg2_g12" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-FALLBACK

// Test AOT-PVC + AOT-DG2 specified via different options, uses native libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g11,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device pvc" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NATIVE
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device dg2_g12" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NATIVE

// Test AOT-PVC + AOT-LNL specified via different options, uses native libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_lnl_m,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device pvc" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NATIVE
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_pvc,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device lnl_m" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-NATIVE-NATIVE

// Test AOT-LNL + AOT-DG1 specified via different options, uses fallback libs
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_lnl_m,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device dg1" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-FALLBACK
// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg1,spir64_gen \
// RUN: --sysroot=%S/Inputs/SYCL -Xsycl-target-backend=spir64_gen "-device lnl_m" \
// RUN: %s -### 2>&1 | FileCheck %s -check-prefix=BFLOAT16-FALLBACK-FALLBACK

// BFLOAT16-NOT: llvm-link{{.*}} "{{.*}}libsycl-{{fallback|native}}-bfloat16.bc"

// BFLOAT16-NATIVE: llvm-link{{.*}} "{{.*}}libsycl-native-bfloat16.bc"
Expand Down

0 comments on commit a9295c1

Please sign in to comment.