Skip to content

Commit cfee27a

Browse files
committed
[SYCL][Driver] Improve SYCL libspirv linking test coverage (NFC)
In the next commits I'd like to refactor and fix SYCL libspirv linking. This adds a few tests to cover the current behavior. Some of it is buggy, and not consistent between NVPTX and AMDGPU, it will be improved in the next commits.
1 parent 8b445d6 commit cfee27a

8 files changed

+47
-11
lines changed

clang/test/Driver/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc

Whitespace-only changes.

clang/test/Driver/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc

Whitespace-only changes.

clang/test/Driver/Inputs/SYCL/share/clc/remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc

Whitespace-only changes.

clang/test/Driver/cuda-nvptx-target.cpp

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %clang -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-msvc %s 2>&1 \
2+
// RUN: | FileCheck %s --check-prefixes=CHECK-WINDOWS
3+
// CHECK-WINDOWS: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc"
4+
//
5+
// RUN: %clang -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-linux-gnu %s 2>&1 \
6+
// RUN: | FileCheck %s --check-prefixes=CHECK-LINUX
7+
// CHECK-LINUX: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc"
8+
//
9+
// AMDGCN wrongly uses 32-bit longs on Windows
10+
// RUN: %clang -### -resource-dir %S/Inputs/SYCL/lib/clang/resource_dir -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib -target x86_64-unknown-windows-msvc %s 2>&1 \
11+
// RUN: | FileCheck %s --check-prefixes=CHECK-AMDGCN-WINDOWS
12+
// CHECK-AMDGCN-WINDOWS: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "{{.*[\\/]}}remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc"
13+
//
14+
// RUN: %clang -### -fsycl -fsycl-device-only -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
15+
// RUN: | FileCheck %s --check-prefixes=CHECK-DEVICE-ONLY
16+
// CHECK-DEVICE-ONLY: "-cc1"{{.*}} "-fsycl-is-device"
17+
// CHECK-DEVICE-ONLY-NOT: "-mlink-builtin-bitcode" "{{.*}}.libspirv-{{.*}}.bc"
18+
//
19+
// Only link libspirv in SYCL language mode, but `-fno-sycl-libspirv` does not result in a warning
20+
// RUN: %clang -### -x cu -fno-sycl-libspirv -nocudainc -nocudalib %s 2>&1 | FileCheck %s --check-prefixes=CHECK-CUDA
21+
// CHECK-CUDA-NOT: warning: argument unused during compilation: '-fno-sycl-libspirv' [-Wunused-command-line-argument]
22+
// CHECK-CUDA: "-cc1"{{.*}} "-fcuda-is-device"
23+
// CHECK-CUDA-NOT: "-mlink-builtin-bitcode" "{{.*}}.libspirv-{{.*}}.bc"
24+
//
25+
// The path to the remangled libspirv bitcode file is determined by the resource directory.
26+
// RUN: %clang -### -ccc-install-dir %S/Inputs/SYCL/bin -resource-dir %S/Inputs/SYCL/lib/clang/resource_dir -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
27+
// RUN: | FileCheck %s -DINSTALL_DIR=%S/Inputs/SYCL/bin -DRESOURCE_DIR=%S/Inputs/SYCL/lib/clang/resource_dir --check-prefixes=CHECK-DIR
28+
// CHECK-DIR: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[RESOURCE_DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc"
29+
//
30+
// The `-###` option disables file existence checks
31+
// RUN: %clang -### -resource-dir %S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
32+
// RUN: | FileCheck %s -DDIR=%S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir --check-prefixes=CHECK-HHH-NOT-FOUND
33+
// CHECK-HHH-NOT-FOUND: "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-mlink-builtin-bitcode" "[[DIR]]{{.*[\\/]}}remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc"
34+
//
35+
// But not for AMDGCN :^)
36+
// RUN: not %clang -### -resource-dir %S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 -nogpulib %s 2>&1 \
37+
// RUN: | FileCheck %s -DDIR=%S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir --check-prefixes=CHECK-AMDGCN-HHH-NOT-FOUND
38+
// CHECK-AMDGCN-HHH-NOT-FOUND: error: cannot find 'remangled-{{.*}}.libspirv-amdgcn-amd-amdhsa.bc'; provide path to libspirv library via '-fsycl-libspirv-path', or pass '-fno-sycl-libspirv' to build without linking with libspirv
39+
//
40+
// `-fdriver-only` has no such special handling, so it will not find the file
41+
// RUN: not %clang -fdriver-only -resource-dir %S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib %s 2>&1 \
42+
// RUN: | FileCheck %s -DDIR=%S/Inputs/SYCL/does_not_exist/lib/clang/resource_dir --check-prefixes=CHECK-DO-NOT-FOUND
43+
// CHECK-DO-NOT-FOUND: error: cannot find 'remangled-{{.*}}.libspirv-nvptx64-nvidia-cuda.bc'; provide path to libspirv library via '-fsycl-libspirv-path', or pass '-fno-sycl-libspirv' to build without linking with libspirv

clang/test/Driver/sycl-offload-nvptx.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
// RUN: %clangxx -ccc-print-phases --sysroot=%S/Inputs/SYCL -std=c++11 \
3939
// RUN: -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all \
4040
// RUN: -fsycl-instrument-device-code -fsycl-targets=nvptx64-nvidia-cuda %s 2>&1 \
41-
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/nvidiacl \
41+
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc \
4242
// RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \
4343
// RUN: | FileCheck -check-prefix=CHK-PHASES-NO-CC %s
4444
//
@@ -57,7 +57,7 @@
5757
// CHK-PHASES-NO-CC: 10: input, "{{.*}}libsycl-itt-user-wrappers.bc", ir, (device-sycl, sm_50)
5858
// CHK-PHASES-NO-CC: 11: input, "{{.*}}libsycl-itt-compiler-wrappers.bc", ir, (device-sycl, sm_50)
5959
// CHK-PHASES-NO-CC: 12: input, "{{.*}}libsycl-itt-stubs.bc", ir, (device-sycl, sm_50)
60-
// CHK-PHASES-NO-CC: 13: input, "{{.*}}nvidiacl{{.*}}", ir, (device-sycl, sm_50)
60+
// CHK-PHASES-NO-CC: 13: input, "{{.*}}libspirv-nvptx64{{.*}}", ir, (device-sycl, sm_50)
6161
// CHK-PHASES-NO-CC: 14: input, "{{.*}}libdevice{{.*}}", ir, (device-sycl, sm_50)
6262
// CHK-PHASES-NO-CC: 15: linker, {9, 10, 11, 12, 13, 14}, ir, (device-sycl, sm_50)
6363
// CHK-PHASES-NO-CC: 16: sycl-post-link, {15}, ir, (device-sycl, sm_50)
@@ -75,7 +75,7 @@
7575
// RUN: %clangxx -ccc-print-phases --sysroot=%S/Inputs/SYCL -std=c++11 \
7676
// RUN: -target x86_64-unknown-linux-gnu -fsycl -fno-sycl-device-lib=all \
7777
// RUN: -fsycl-instrument-device-code -fsycl-targets=nvptx64-nvidia-cuda \
78-
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/lib/nvidiacl \
78+
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/share/clc/remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc \
7979
// RUN: --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda \
8080
// RUN: -Xsycl-target-backend "--cuda-gpu-arch=sm_35" %s 2>&1 \
8181
// RUN: | FileCheck -check-prefix=CHK-PHASES %s
@@ -95,7 +95,7 @@
9595
// CHK-PHASES: 10: input, "{{.*}}libsycl-itt-user-wrappers.bc", ir, (device-sycl, sm_35)
9696
// CHK-PHASES: 11: input, "{{.*}}libsycl-itt-compiler-wrappers.bc", ir, (device-sycl, sm_35)
9797
// CHK-PHASES: 12: input, "{{.*}}libsycl-itt-stubs.bc", ir, (device-sycl, sm_35)
98-
// CHK-PHASES: 13: input, "{{.*}}nvidiacl{{.*}}", ir, (device-sycl, sm_35)
98+
// CHK-PHASES: 13: input, "{{.*}}libspirv-nvptx64{{.*}}", ir, (device-sycl, sm_35)
9999
// CHK-PHASES: 14: input, "{{.*}}libdevice{{.*}}", ir, (device-sycl, sm_35)
100100
// CHK-PHASES: 15: linker, {9, 10, 11, 12, 13, 14}, ir, (device-sycl, sm_35)
101101
// CHK-PHASES: 16: sycl-post-link, {15}, ir, (device-sycl, sm_35)

0 commit comments

Comments
 (0)