|
| 1 | +; Tests the clang-sycl-linker tool. |
| 2 | +; |
| 3 | +; REQUIRES: spirv-registered-target |
| 4 | +; |
| 5 | +; RUN: rm -rf %t && split-file %s %t |
| 6 | +; RUN: llvm-as %t/input1.ll -o %t/input1.bc |
| 7 | +; RUN: llvm-as %t/input2.ll -o %t/input2.bc |
| 8 | +; |
| 9 | +; Test the dry run of a simple case to link two input files. |
| 10 | +; RUN: clang-sycl-linker --dry-run -v -triple=spirv64 %t/input1.bc %t/input2.bc -o %t/spirv.out 2>&1 \ |
| 11 | +; RUN: | FileCheck %s --check-prefix=SIMPLE-FO |
| 12 | +; SIMPLE-FO: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc |
| 13 | +; SIMPLE-FO-NEXT: sycl-module-split: input: [[LLVMLINKOUT]].bc, output: [[LLVMLINKOUT]].bc, mode: none |
| 14 | +; SIMPLE-FO-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: {{.*}}_0.spv |
| 15 | +; |
| 16 | +; Test that IMG_SPIRV image kind is set for non-AOT compilation. |
| 17 | +; RUN: llvm-objdump --offloading %t/spirv.out | FileCheck %s --check-prefix=IMAGE-KIND-SPIRV |
| 18 | +; IMAGE-KIND-SPIRV: kind spir-v |
| 19 | +; |
| 20 | +; Test the dry run of a simple case with device library files specified. |
| 21 | +; RUN: mkdir -p %t/libs |
| 22 | +; RUN: touch %t/libs/lib1.bc |
| 23 | +; RUN: touch %t/libs/lib2.bc |
| 24 | +; RUN: clang-sycl-linker --dry-run -v -triple=spirv64 %t/input1.bc %t/input2.bc --library-path=%t/libs --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1 \ |
| 25 | +; RUN: | FileCheck %s --check-prefix=DEVLIBS |
| 26 | +; DEVLIBS: sycl-device-link: inputs: {{.*}}.bc libfiles: {{.*}}lib1.bc, {{.*}}lib2.bc output: [[LLVMLINKOUT:.*]].bc |
| 27 | +; DEVLIBS-NEXT: sycl-module-split: input: [[LLVMLINKOUT]].bc, output: [[LLVMLINKOUT]].bc, mode: none |
| 28 | +; DEVLIBS-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: a_0.spv |
| 29 | +; |
| 30 | +; Test a simple case with a random file (not bitcode) as input. |
| 31 | +; RUN: touch %t/dummy.o |
| 32 | +; RUN: not clang-sycl-linker -triple=spirv64 %t/dummy.o -o a.spv 2>&1 \ |
| 33 | +; RUN: | FileCheck %s --check-prefix=FILETYPEERROR |
| 34 | +; FILETYPEERROR: Unsupported file type |
| 35 | +; |
| 36 | +; Test to see if device library related errors are emitted. |
| 37 | +; RUN: not clang-sycl-linker --dry-run -triple=spirv64 %t/input1.bc %t/input2.bc --library-path=%t/libs --device-libs= -o a.spv 2>&1 \ |
| 38 | +; RUN: | FileCheck %s --check-prefix=DEVLIBSERR1 |
| 39 | +; DEVLIBSERR1: Number of device library files cannot be zero |
| 40 | +; RUN: not clang-sycl-linker --dry-run -triple=spirv64 %t/input1.bc %t/input2.bc --library-path=%t/libs --device-libs=lib1.bc,lib2.bc,lib3.bc -o a.spv 2>&1 \ |
| 41 | +; RUN: | FileCheck %s --check-prefix=DEVLIBSERR2 |
| 42 | +; DEVLIBSERR2: '{{.*}}lib3.bc' SYCL device library file is not found |
| 43 | +; |
| 44 | +; Test AOT compilation for an Intel GPU. |
| 45 | +; RUN: clang-sycl-linker --dry-run -v -triple=spirv64 -arch=bmg_g21 %t/input1.bc %t/input2.bc -o %t/aot-gpu.out 2>&1 \ |
| 46 | +; RUN: --ocloc-options="-a -b" \ |
| 47 | +; RUN: | FileCheck %s --check-prefix=AOT-INTEL-GPU |
| 48 | +; AOT-INTEL-GPU: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc |
| 49 | +; AOT-INTEL-GPU-NEXT: sycl-module-split: input: [[LLVMLINKOUT]].bc, output: [[LLVMLINKOUT]].bc, mode: none |
| 50 | +; AOT-INTEL-GPU-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: [[SPIRVTRANSLATIONOUT:.*]]_0.spv |
| 51 | +; AOT-INTEL-GPU-NEXT: "{{.*}}ocloc{{.*}}" {{.*}}-device bmg_g21 -a -b {{.*}}-output [[SPIRVTRANSLATIONOUT]]_0.out -file [[SPIRVTRANSLATIONOUT]]_0.spv |
| 52 | +; |
| 53 | +; Test that IMG_Object image kind is set for AOT compilation (Intel GPU). |
| 54 | +; RUN: llvm-objdump --offloading %t/aot-gpu.out | FileCheck %s --check-prefix=IMAGE-KIND-OBJECT |
| 55 | +; IMAGE-KIND-OBJECT: kind elf |
| 56 | +; |
| 57 | +; Test AOT compilation for an Intel CPU. |
| 58 | +; RUN: clang-sycl-linker --dry-run -v -triple=spirv64 -arch=graniterapids %t/input1.bc %t/input2.bc -o %t/aot-cpu.out 2>&1 \ |
| 59 | +; RUN: --opencl-aot-options="-a -b" \ |
| 60 | +; RUN: | FileCheck %s --check-prefix=AOT-INTEL-CPU |
| 61 | +; AOT-INTEL-CPU: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc |
| 62 | +; AOT-INTEL-CPU-NEXT: sycl-module-split: input: [[LLVMLINKOUT]].bc, output: [[LLVMLINKOUT]].bc, mode: none |
| 63 | +; AOT-INTEL-CPU-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: [[SPIRVTRANSLATIONOUT:.*]]_0.spv |
| 64 | +; AOT-INTEL-CPU-NEXT: "{{.*}}opencl-aot{{.*}}" {{.*}}--device=cpu -a -b {{.*}}-o [[SPIRVTRANSLATIONOUT]]_0.out [[SPIRVTRANSLATIONOUT]]_0.spv |
| 65 | +; |
| 66 | +; Test that IMG_Object image kind is set for AOT compilation (Intel CPU). |
| 67 | +; RUN: llvm-objdump --offloading %t/aot-cpu.out | FileCheck %s --check-prefix=IMAGE-KIND-OBJECT |
| 68 | +; |
| 69 | +; Check that the output file must be specified. |
| 70 | +; RUN: not clang-sycl-linker --dry-run %t/input1.bc %t/input2.bc 2>&1 \ |
| 71 | +; RUN: | FileCheck %s --check-prefix=NOOUTPUT |
| 72 | +; NOOUTPUT: Output file must be specified |
| 73 | +; |
| 74 | +; Check that the target triple must be specified. |
| 75 | +; RUN: not clang-sycl-linker --dry-run %t/input1.bc %t/input2.bc -o a.out 2>&1 \ |
| 76 | +; RUN: | FileCheck %s --check-prefix=NOTARGET |
| 77 | +; NOTARGET: Target triple must be specified |
| 78 | + |
| 79 | +;--- input1.ll |
| 80 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" |
| 81 | +target triple = "spirv64" |
| 82 | + |
| 83 | +define spir_kernel void @kernel_a() #0 { |
| 84 | + ret void |
| 85 | +} |
| 86 | + |
| 87 | +attributes #0 = { "sycl-module-id"="TU1.cpp" } |
| 88 | + |
| 89 | +;--- input2.ll |
| 90 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" |
| 91 | +target triple = "spirv64" |
| 92 | + |
| 93 | +define spir_kernel void @kernel_b() #0 { |
| 94 | + ret void |
| 95 | +} |
| 96 | + |
| 97 | +attributes #0 = { "sycl-module-id"="TU2.cpp" } |
0 commit comments