| 1 |
/// |
| 2 |
/// Perform several driver tests for OpenMP offloading |
| 3 |
/// |
| 4 |
|
| 5 |
/// ########################################################################### |
| 6 |
|
| 7 |
/// Check -Xopenmp-target uses one of the archs provided when several archs are used. |
| 8 |
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -nogpulib -nogpuinc \ |
| 9 |
// RUN: -Xopenmp-target -march=sm_52 -Xopenmp-target -march=sm_60 %s 2>&1 \ |
| 10 |
// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s |
| 11 |
|
| 12 |
// CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60" |
| 13 |
|
| 14 |
/// ########################################################################### |
| 15 |
|
| 16 |
/// Check -Xopenmp-target -march=sm_52 works as expected when two triples are present. |
| 17 |
// RUN: %clang -### -fopenmp=libomp \ |
| 18 |
// RUN: -fopenmp-targets=powerpc64le-ibm-linux-gnu,nvptx64-nvidia-cuda \ |
| 19 |
// RUN: -nogpulib -nogpuinc -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 %s 2>&1 \ |
| 20 |
// RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-COMPILATION %s |
| 21 |
|
| 22 |
// CHK-FOPENMP-TARGET-COMPILATION: ptxas{{.*}}" "--gpu-name" "sm_52" |
| 23 |
|
| 24 |
/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP. |
| 25 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 \ |
| 26 |
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s |
| 27 |
|
| 28 |
// CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c" |
| 29 |
|
| 30 |
/// ########################################################################### |
| 31 |
|
| 32 |
/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it. |
| 33 |
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target \ |
| 34 |
// RUN: -nogpulib -nogpuinc --offload-arch=sm_52 -save-temps %s 2>&1 \ |
| 35 |
// RUN: | FileCheck -check-prefix=CHK-PTXAS-NORELO %s |
| 36 |
|
| 37 |
// CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c" |
| 38 |
|
| 39 |
/// ########################################################################### |
| 40 |
|
| 41 |
/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP |
| 42 |
/// Check that the flag is passed when -fopenmp-relocatable-target is used. |
| 43 |
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target \ |
| 44 |
// RUN: -nogpulib -nogpuinc --offload-arch=sm_52 -save-temps %s 2>&1 \ |
| 45 |
// RUN: | FileCheck -check-prefix=CHK-PTXAS-RELO %s |
| 46 |
|
| 47 |
// CHK-PTXAS-RELO: ptxas{{.*}}" "-c" |
| 48 |
|
| 49 |
/// ########################################################################### |
| 50 |
|
| 51 |
/// Check that error is not thrown by toolchain when no cuda lib flag is used. |
| 52 |
/// Check that the flag is passed when -fopenmp-relocatable-target is used. |
| 53 |
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \ |
| 54 |
// RUN: -nogpulib -nogpuinc -fopenmp-relocatable-target -save-temps %s 2>&1 \ |
| 55 |
// RUN: | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s |
| 56 |
|
| 57 |
// CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_60 |
| 58 |
|
| 59 |
/// ########################################################################### |
| 60 |
|
| 61 |
/// Check that error is not thrown by toolchain when no cuda lib device is found when using -S. |
| 62 |
/// Check that the flag is passed when -fopenmp-relocatable-target is used. |
| 63 |
// RUN: %clang -### -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \ |
| 64 |
// RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \ |
| 65 |
// RUN: | FileCheck -check-prefix=CHK-NOLIBDEVICE %s |
| 66 |
|
| 67 |
// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60 |
| 68 |
|
| 69 |
/// ########################################################################### |
| 70 |
|
| 71 |
/// Check that the runtime bitcode library is part of the compile line. |
| 72 |
/// Create a bogus bitcode library and specify it with libomptarget-nvptx-bc-path |
| 73 |
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 74 |
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \ |
| 75 |
// RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 76 |
// RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \ |
| 77 |
// RUN: | FileCheck -check-prefix=CHK-BCLIB %s |
| 78 |
|
| 79 |
/// Specify the directory containing the bitcode lib, check clang picks the right one |
| 80 |
// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 81 |
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget \ |
| 82 |
// RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 83 |
// RUN: -fopenmp-relocatable-target -save-temps \ |
| 84 |
// RUN: %s 2>&1 | FileCheck -check-prefix=CHK-BCLIB-DIR %s |
| 85 |
|
| 86 |
/// Create a bogus bitcode library and find it with LIBRARY_PATH |
| 87 |
// RUN: env LIBRARY_PATH=%S/Inputs/libomptarget/subdir %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 88 |
// RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 89 |
// RUN: -fopenmp-relocatable-target -save-temps \ |
| 90 |
// RUN: %s 2>&1 | FileCheck -check-prefix=CHK-ENV-BCLIB %s |
| 91 |
|
| 92 |
// CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-test.bc |
| 93 |
// CHK-BCLIB-DIR: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget{{/|\\\\}}libomptarget-nvptx.bc |
| 94 |
// CHK-ENV-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}subdir{{/|\\\\}}libomptarget-nvptx.bc |
| 95 |
// CHK-BCLIB-NOT: {{error:|warning:}} |
| 96 |
|
| 97 |
/// ########################################################################### |
| 98 |
|
| 99 |
/// Check that the error is thrown when the libomptarget bitcode library does not exist. |
| 100 |
// RUN: not %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 101 |
// RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 102 |
// RUN: --libomptarget-nvptx-bc-path=not-exist.bc \ |
| 103 |
// RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \ |
| 104 |
// RUN: | FileCheck -check-prefix=CHK-BCLIB-ERROR %s |
| 105 |
|
| 106 |
// CHK-BCLIB-ERROR: bitcode library 'not-exist.bc' does not exist |
| 107 |
|
| 108 |
/// ########################################################################### |
| 109 |
|
| 110 |
/// Check that the error is thrown when CUDA 9.1 or lower version is used. |
| 111 |
// RUN: not %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 112 |
// RUN: -Xopenmp-target -march=sm_52 --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda \ |
| 113 |
// RUN: -fopenmp-relocatable-target -save-temps %s 2>&1 \ |
| 114 |
// RUN: | FileCheck -check-prefix=CHK-CUDA-VERSION-ERROR %s |
| 115 |
|
| 116 |
// CHK-CUDA-VERSION-ERROR: NVPTX target requires CUDA 9.2 or above; CUDA 9.0 detected |
| 117 |
|
| 118 |
/// Check that debug info is emitted in dwarf-2 |
| 119 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O1 --no-cuda-noopt-device-debug 2>&1 \ |
| 120 |
// RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s |
| 121 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \ |
| 122 |
// RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s |
| 123 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \ |
| 124 |
// RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s |
| 125 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \ |
| 126 |
// RUN: | FileCheck -check-prefix=NO_DEBUG %s |
| 127 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \ |
| 128 |
// RUN: | FileCheck -check-prefix=NO_DEBUG %s |
| 129 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-directives-only 2>&1 \ |
| 130 |
// RUN: | FileCheck -check-prefix=DEBUG_DIRECTIVES %s |
| 131 |
|
| 132 |
// DEBUG_DIRECTIVES-NOT: warning: debug |
| 133 |
// NO_DEBUG-NOT: warning: debug |
| 134 |
// NO_DEBUG: "-fopenmp-is-target-device" |
| 135 |
// NO_DEBUG-NOT: "-debug-info-kind= |
| 136 |
// NO_DEBUG: ptxas |
| 137 |
// DEBUG_DIRECTIVES: "-triple" "nvptx64-nvidia-cuda" |
| 138 |
// DEBUG_DIRECTIVES-SAME: "-debug-info-kind=line-directives-only" |
| 139 |
// DEBUG_DIRECTIVES-SAME: "-fopenmp-is-target-device" |
| 140 |
// DEBUG_DIRECTIVES: ptxas |
| 141 |
// DEBUG_DIRECTIVES: "-lineinfo" |
| 142 |
|
| 143 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \ |
| 144 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 145 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \ |
| 146 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 147 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \ |
| 148 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 149 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --cuda-noopt-device-debug 2>&1 \ |
| 150 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 151 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g2 2>&1 \ |
| 152 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 153 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb2 -O0 --cuda-noopt-device-debug 2>&1 \ |
| 154 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 155 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g3 -O3 --cuda-noopt-device-debug 2>&1 \ |
| 156 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 157 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \ |
| 158 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 159 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \ |
| 160 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 161 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \ |
| 162 |
// RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 163 |
|
| 164 |
// HAS_DEBUG-NOT: warning: debug |
| 165 |
// HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda" |
| 166 |
// HAS_DEBUG-SAME: "-debug-info-kind={{constructor|line-tables-only}}" |
| 167 |
// HAS_DEBUG-SAME: "-dwarf-version=2" |
| 168 |
// HAS_DEBUG-SAME: "-fopenmp-is-target-device" |
| 169 |
// HAS_DEBUG: ptxas |
| 170 |
// HAS_DEBUG-SAME: "-g" |
| 171 |
// HAS_DEBUG-SAME: "--dont-merge-basicblocks" |
| 172 |
// HAS_DEBUG-SAME: "--return-at-end" |
| 173 |
|
| 174 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-mode 2>&1 \ |
| 175 |
// RUN: | FileCheck -check-prefix=CUDA_MODE %s |
| 176 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-mode -fopenmp-cuda-mode 2>&1 \ |
| 177 |
// RUN: | FileCheck -check-prefix=CUDA_MODE %s |
| 178 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-mode 2>&1 \ |
| 179 |
// RUN: | FileCheck -check-prefix=CUDA_MODE %s |
| 180 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-mode -fopenmp-cuda-mode 2>&1 \ |
| 181 |
// RUN: | FileCheck -check-prefix=CUDA_MODE %s |
| 182 |
// CUDA_MODE: "-cc1"{{.*}}"-triple" "{{nvptx64-nvidia-cuda|amdgcn-amd-amdhsa}}" |
| 183 |
// CUDA_MODE-SAME: "-fopenmp-cuda-mode" |
| 184 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fno-openmp-cuda-mode 2>&1 \ |
| 185 |
// RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s |
| 186 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-mode -fno-openmp-cuda-mode 2>&1 \ |
| 187 |
// RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s |
| 188 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fno-openmp-cuda-mode 2>&1 \ |
| 189 |
// RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s |
| 190 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target -march=gfx906 %s -fopenmp-cuda-mode -fno-openmp-cuda-mode 2>&1 \ |
| 191 |
// RUN: | FileCheck -check-prefix=NO_CUDA_MODE %s |
| 192 |
// NO_CUDA_MODE-NOT: "-{{fno-|f}}openmp-cuda-mode" |
| 193 |
|
| 194 |
// RUN: %clang -### -nogpulib -nogpuinc -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -fopenmp-cuda-teams-reduction-recs-num=2048 2>&1 \ |
| 195 |
// RUN: | FileCheck -check-prefix=CUDA_RED_RECS %s |
| 196 |
// CUDA_RED_RECS: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda" |
| 197 |
// CUDA_RED_RECS-SAME: "-fopenmp-cuda-teams-reduction-recs-num=2048" |
| 198 |
|
| 199 |
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 200 |
// RUN: --offload-arch=sm_52 --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \ |
| 201 |
// RUN: | FileCheck -check-prefix=OPENMP_NVPTX_WRAPPERS %s |
| 202 |
// OPENMP_NVPTX_WRAPPERS: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda" |
| 203 |
// OPENMP_NVPTX_WRAPPERS-SAME: "-internal-isystem" "{{.*}}openmp_wrappers" |
| 204 |
|
| 205 |
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -nogpulib -nogpuinc \ |
| 206 |
// RUN: --offload-arch=sm_52 -save-temps -ccc-print-bindings %s -o openmp-offload-gpu 2>&1 \ |
| 207 |
// RUN: | FileCheck -check-prefix=SAVE_TEMPS_NAMES %s |
| 208 |
|
| 209 |
// SAVE_TEMPS_NAMES-NOT: "GNU::Linker"{{.*}}["[[SAVE_TEMPS_INPUT1:.*\.o]]", "[[SAVE_TEMPS_INPUT1]]"] |
| 210 |
|
| 211 |
// RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 -march=sm_52 \ |
| 212 |
// RUN: -nogpulib -nogpuinc -save-temps %s -o openmp-offload-gpu 2>&1 \ |
| 213 |
// RUN: | FileCheck -check-prefix=TRIPLE %s |
| 214 |
|
| 215 |
// TRIPLE: "-triple" "nvptx64-nvidia-cuda" |
| 216 |
// TRIPLE: "-target-cpu" "sm_52" |
| 217 |
|
| 218 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 219 |
// RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 220 |
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \ |
| 221 |
// RUN: | FileCheck %s |
| 222 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 223 |
// RUN: --offload-arch=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 224 |
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \ |
| 225 |
// RUN: | FileCheck %s |
| 226 |
|
| 227 |
// verify the tools invocations |
| 228 |
// CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-llvm-bc"{{.*}}"-x" "c" |
| 229 |
// CHECK: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}}"-target-cpu" "sm_52" |
| 230 |
// CHECK: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-emit-obj" |
| 231 |
// CHECK: clang-linker-wrapper{{.*}} "-o" "a.out" |
| 232 |
|
| 233 |
// RUN: %clang -ccc-print-phases --target=x86_64-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 %s 2>&1 \ |
| 234 |
// RUN: | FileCheck --check-prefix=CHECK-PHASES %s |
| 235 |
// CHECK-PHASES: 0: input, "[[INPUT:.+]]", c, (host-openmp) |
| 236 |
// CHECK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp) |
| 237 |
// CHECK-PHASES: 2: compiler, {1}, ir, (host-openmp) |
| 238 |
// CHECK-PHASES: 3: input, "[[INPUT]]", c, (device-openmp, sm_52) |
| 239 |
// CHECK-PHASES: 4: preprocessor, {3}, cpp-output, (device-openmp, sm_52) |
| 240 |
// CHECK-PHASES: 5: compiler, {4}, ir, (device-openmp, sm_52) |
| 241 |
// CHECK-PHASES: 6: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (nvptx64-nvidia-cuda:sm_52)" {5}, ir |
| 242 |
// CHECK-PHASES: 7: backend, {6}, assembler, (device-openmp, sm_52) |
| 243 |
// CHECK-PHASES: 8: assembler, {7}, object, (device-openmp, sm_52) |
| 244 |
// CHECK-PHASES: 9: offload, "device-openmp (nvptx64-nvidia-cuda:sm_52)" {8}, object |
| 245 |
// CHECK-PHASES: 10: llvm-offload-binary, {9}, image |
| 246 |
// CHECK-PHASES: 11: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, "device-openmp (x86_64-unknown-linux-gnu)" {10}, ir |
| 247 |
// CHECK-PHASES: 12: backend, {11}, assembler, (host-openmp) |
| 248 |
// CHECK-PHASES: 13: assembler, {12}, object, (host-openmp) |
| 249 |
// CHECK-PHASES: 14: clang-linker-wrapper, {13}, image, (host-openmp) |
| 250 |
|
| 251 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-BINDINGS |
| 252 |
// CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HOST_BC:.+]]" |
| 253 |
// CHECK-BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_BC:.+]]" |
| 254 |
// CHECK-BINDINGS: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_BC]]"], output: "[[DEVICE_OBJ:.+]]" |
| 255 |
// CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[DEVICE_OBJ]]"], output: "[[BINARY:.+.out]]" |
| 256 |
// CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.+]]" |
| 257 |
// CHECK-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out" |
| 258 |
|
| 259 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib -save-temps %s 2>&1 | FileCheck %s --check-prefix=CHECK-TEMP-BINDINGS |
| 260 |
// CHECK-TEMP-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[DEVICE_OBJ:.+]]"], output: "[[BINARY:.+.out]]" |
| 261 |
|
| 262 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52 --offload-arch=sm_70 -nogpuinc -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS |
| 263 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52,sm_70 -nogpuinc -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS |
| 264 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52,sm_60,sm_70,sm_80 --no-offload-arch=sm_60,sm_80 -nogpuinc -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS |
| 265 |
// CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"], output: "[[HOST_BC:.*]]" |
| 266 |
// CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_BC_SM_52:.*]]" |
| 267 |
// CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_BC_SM_52]]"], output: "[[DEVICE_OBJ_SM_52:.*]]" |
| 268 |
// CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_BC_SM_70:.*]]" |
| 269 |
// CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_BC_SM_70]]"], output: "[[DEVICE_OBJ_SM_70:.*]]" |
| 270 |
// CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[DEVICE_OBJ_SM_52]]", "[[DEVICE_OBJ_SM_70]]"], output: "[[BINARY:.*]]" |
| 271 |
// CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.*]]" |
| 272 |
// CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out" |
| 273 |
|
| 274 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp \ |
| 275 |
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda,amdgcn-amd-amdhsa -Xopenmp-target=nvptx64-nvidia-cuda --offload-arch=sm_70 \ |
| 276 |
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda,amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa --offload-arch=gfx908 \ |
| 277 |
// RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NVIDIA-AMDGPU |
| 278 |
|
| 279 |
// CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[HOST_BC:.+]]" |
| 280 |
// CHECK-NVIDIA-AMDGPU: "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[AMD_BC:.+]]" |
| 281 |
// CHECK-NVIDIA-AMDGPU: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[NVIDIA_PTX:.+]]" |
| 282 |
// CHECK-NVIDIA-AMDGPU: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[NVIDIA_PTX]]"], output: "[[NVIDIA_CUBIN:.+]]" |
| 283 |
// CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "Offload::Packager", inputs: ["[[AMD_BC]]", "[[NVIDIA_CUBIN]]"], output: "[[BINARY:.*]]" |
| 284 |
// CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.+]]" |
| 285 |
// CHECK-NVIDIA-AMDGPU: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out" |
| 286 |
|
| 287 |
// RUN: %clang -x ir -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp --offload-arch=sm_52 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-IR |
| 288 |
|
| 289 |
// CHECK-IR: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT_IR:.+]]"], output: "[[OBJECT:.+]]" |
| 290 |
// CHECK-IR: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[OBJECT]]"], output: "a.out" |
| 291 |
|
| 292 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp=libomp --offload-device-only \ |
| 293 |
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \ |
| 294 |
// RUN: | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR |
| 295 |
// CHECK-EMIT-LLVM-IR: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"{{.*}}"-emit-llvm" |
| 296 |
|
| 297 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp=libomp \ |
| 298 |
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 -nogpulib %s 2>&1 \ |
| 299 |
// RUN: | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR-BC |
| 300 |
// CHECK-EMIT-LLVM-IR-BC: "-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"{{.*}}"-emit-llvm-bc" |
| 301 |
|
| 302 |
// RUN: %clang -### -fopenmp=libomp --offload-arch=sm_89 \ |
| 303 |
// RUN: --no-cuda-version-check \ |
| 304 |
// RUN: -nogpulib %s -o openmp-offload-gpu 2>&1 \ |
| 305 |
// RUN: | FileCheck -check-prefix=DRIVER_EMBEDDING %s |
| 306 |
|
| 307 |
// DRIVER_EMBEDDING: -fembed-offload-object={{.*}}.out |
| 308 |
|
| 309 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 310 |
// RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 --offload-host-only -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-HOST-ONLY |
| 311 |
// CHECK-HOST-ONLY: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"], output: "[[OUTPUT:.*]]" |
| 312 |
// CHECK-HOST-ONLY: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[OUTPUT]]"], output: "a.out" |
| 313 |
|
| 314 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 315 |
// RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 --offload-device-only -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE-ONLY |
| 316 |
// CHECK-DEVICE-ONLY: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[INPUT:.*]]"], output: "[[HOST_BC:.*]]" |
| 317 |
// CHECK-DEVICE-ONLY: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", "[[HOST_BC]]"], output: "[[DEVICE_ASM:.*]]" |
| 318 |
// CHECK-DEVICE-ONLY: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_ASM]]"], output: "{{.*}}-openmp-nvptx64-nvidia-cuda-sm_52.o" |
| 319 |
|
| 320 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 321 |
// RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 --offload-device-only -E -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEVICE-ONLY-PP |
| 322 |
// CHECK-DEVICE-ONLY-PP: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.*]]"], output: "-" |
| 323 |
|
| 324 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 325 |
// RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBRARY %s |
| 326 |
|
| 327 |
// CHECK-LTO-LIBRARY: --device-linker={{.*}}=-lomp{{.*}}-lomptarget{{.*}} |
| 328 |
|
| 329 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 330 |
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \ |
| 331 |
// RUN: | FileCheck --check-prefix=CHECK-NO-LTO-LIBRARY %s |
| 332 |
|
| 333 |
// CHECK-NO-LTO-LIBRARY: --device-linker={{.*}}=-lomp{{.*}}-lomptarget{{.*}} |
| 334 |
|
| 335 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \ |
| 336 |
// RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-NO-LIBRARY %s |
| 337 |
|
| 338 |
// CHECK-NO-LIBRARY-NOT: --device-linker={{.*}}=-lomp{{.*}}-lomptarget{{.*}} |
| 339 |
|
| 340 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \ |
| 341 |
// RUN: -Xoffload-linker a -Xoffload-linker-nvptx64-nvidia-cuda b -Xoffload-linker-nvptx64 c \ |
| 342 |
// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-XLINKER %s |
| 343 |
|
| 344 |
// CHECK-XLINKER: -device-linker=a{{.*}}-device-linker=nvptx64-nvidia-cuda=b{{.*}}-device-linker=nvptx64-nvidia-cuda=c{{.*}}-- |
| 345 |
|
| 346 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \ |
| 347 |
// RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-FEATURES %s |
| 348 |
|
| 349 |
// CHECK-LTO-FEATURES: llvm-offload-binary{{.*}}--image={{.*}}feature=+ptx{{[0-9]+}} |
| 350 |
|
| 351 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=sm_52 -nogpulib \ |
| 352 |
// RUN: -Xopenmp-target=nvptx64-nvidia-cuda --cuda-feature=+ptx64 -foffload-lto %s 2>&1 \ |
| 353 |
// RUN: | FileCheck --check-prefix=CHECK-SET-FEATURES %s |
| 354 |
|
| 355 |
// CHECK-SET-FEATURES: llvm-offload-binary{{.*}}--image={{.*}}feature=+ptx64 |
| 356 |
|
| 357 |
// |
| 358 |
// Check that `-Xarch_host` works for OpenMP offloading. |
| 359 |
// |
| 360 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \ |
| 361 |
// RUN: --offload-arch=sm_52 -nogpulib -nogpuinc -Xarch_host -O3 %s 2>&1 \ |
| 362 |
// RUN: | FileCheck --check-prefix=XARCH-HOST %s |
| 363 |
// XARCH-HOST: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-O3" |
| 364 |
// XARCH-HOST-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-O3" |
| 365 |
|
| 366 |
// |
| 367 |
// Check that `-Xarch_device` works for OpenMP offloading. |
| 368 |
// |
| 369 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \ |
| 370 |
// RUN: --offload-arch=sm_52 -nogpulib -nogpuinc -Xarch_device -O3 %s 2>&1 \ |
| 371 |
// RUN: | FileCheck --check-prefix=XARCH-DEVICE %s |
| 372 |
// XARCH-DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-O3" |
| 373 |
// XARCH-DEVICE-NOT: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-O3" |
| 374 |
|
| 375 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \ |
| 376 |
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \ |
| 377 |
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ |
| 378 |
// RUN: --offload-arch=sm_52 -nogpulibc -nogpuinc %s 2>&1 \ |
| 379 |
// RUN: | FileCheck --check-prefix=LIBC-GPU %s |
| 380 |
// LIBC-GPU-NOT: clang-linker-wrapper{{.*}}"--device-linker" |
| 381 |
|
| 382 |
// |
| 383 |
// Check that ThinLTO works for OpenMP offloading. |
| 384 |
// |
| 385 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \ |
| 386 |
// RUN: --offload-arch=gfx906 -foffload-lto=thin -nogpulib -nogpuinc %s 2>&1 \ |
| 387 |
// RUN: | FileCheck --check-prefix=THINLTO-GFX906 %s |
| 388 |
// THINLTO-GFX906: --device-compiler=amdgcn-amd-amdhsa=-flto=thin |
| 389 |
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-force-import-all |
| 390 |
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-avail-extern-to-local |
| 391 |
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-avail-extern-gv-in-addrspace-to-local=3 |
| 392 |
// THINLTO-GFX906-SAME: --device-linker=amdgcn-amd-amdhsa=-plugin-opt=-amdgpu-internalize-symbols |
| 393 |
// |
| 394 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \ |
| 395 |
// RUN: --offload-arch=sm_52 -foffload-lto=thin -nogpulib -nogpuinc %s 2>&1 \ |
| 396 |
// RUN: | FileCheck --check-prefix=THINLTO-SM52 %s |
| 397 |
// THINLTO-SM52: --device-compiler=nvptx64-nvidia-cuda=-flto=thin |
| 398 |
|
| 399 |
// |
| 400 |
// Check the requested architecture is passed if provided. |
| 401 |
// |
| 402 |
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \ |
| 403 |
// RUN: --offload-arch=gfx906 -foffload-lto=thin -nogpulib -nogpuinc %s 2>&1 \ |
| 404 |
// RUN: | FileCheck --check-prefix=SHOULD-EXTRACT %s |
| 405 |
// |
| 406 |
// SHOULD-EXTRACT: clang-linker-wrapper{{.*}}"--should-extract=gfx906" |