Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 1 | /// |
| 2 | /// Perform several driver tests for OpenMP offloading |
| 3 | /// |
| 4 | |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 5 | // REQUIRES: clang-driver |
| 6 | // REQUIRES: x86-registered-target |
| 7 | // REQUIRES: powerpc-registered-target |
| 8 | // REQUIRES: nvptx-registered-target |
| 9 | |
| 10 | /// ########################################################################### |
| 11 | |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 12 | /// Check -Xopenmp-target uses one of the archs provided when several archs are used. |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 13 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 14 | // RUN: -Xopenmp-target -march=sm_35 -Xopenmp-target -march=sm_60 %s 2>&1 \ |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 15 | // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s |
| 16 | |
| 17 | // CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60" |
| 18 | // CHK-FOPENMP-TARGET-ARCHS: nvlink{{.*}}" "-arch" "sm_60" |
| 19 | |
| 20 | /// ########################################################################### |
| 21 | |
| 22 | /// Check -Xopenmp-target -march=sm_35 works as expected when two triples are present. |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 23 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp \ |
| 24 | // RUN: -fopenmp-targets=powerpc64le-ibm-linux-gnu,nvptx64-nvidia-cuda \ |
| 25 | // RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_35 %s 2>&1 \ |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 26 | // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-COMPILATION %s |
| 27 | |
| 28 | // CHK-FOPENMP-TARGET-COMPILATION: ptxas{{.*}}" "--gpu-name" "sm_35" |
| 29 | // CHK-FOPENMP-TARGET-COMPILATION: nvlink{{.*}}" "-arch" "sm_35" |
| 30 | |
| 31 | /// ########################################################################### |
| 32 | |
| 33 | /// Check cubin file generation and usage by nvlink |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 34 | // RUN: %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp \ |
| 35 | // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \ |
| 36 | // RUN: | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s |
| 37 | /// Check cubin file generation and usage by nvlink when toolchain has BindArchAction |
| 38 | // RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp \ |
| 39 | // RUN: -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \ |
| 40 | // RUN: | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 41 | |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 42 | // CHK-CUBIN-NVLINK: clang{{.*}}" "-o" "[[PTX:.*\.s]]" |
| 43 | // CHK-CUBIN-NVLINK-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]" |
| 44 | // CHK-CUBIN-NVLINK-NEXT: nvlink{{.*}}" {{.*}}"[[CUBIN]]" |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 45 | |
| 46 | /// ########################################################################### |
| 47 | |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 48 | /// Check unbundlink of assembly file, cubin file generation and usage by nvlink |
| 49 | // RUN: touch %t.s |
Jonas Hahnfeld | 4609b25 | 2017-11-21 15:06:28 +0000 | [diff] [blame] | 50 | // RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 51 | // RUN: -no-canonical-prefixes -save-temps %t.s 2>&1 \ |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 52 | // RUN: | FileCheck -check-prefix=CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK %s |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 53 | |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 54 | /// Use DAG to ensure that assembly file has been unbundled. |
| 55 | // CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX:.*\.s]]" |
| 56 | // CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=s" {{.*}}"-outputs={{.*}}[[PTX]] |
| 57 | // CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG-SAME: "-unbundle" |
| 58 | // CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK: nvlink{{.*}}" {{.*}}"[[CUBIN]]" |
| 59 | |
| 60 | /// ########################################################################### |
| 61 | |
| 62 | /// Check cubin file generation and bundling |
Jonas Hahnfeld | 4609b25 | 2017-11-21 15:06:28 +0000 | [diff] [blame] | 63 | // RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 64 | // RUN: -no-canonical-prefixes -save-temps %s -c 2>&1 \ |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 65 | // RUN: | FileCheck -check-prefix=CHK-PTXAS-CUBIN-BUNDLING %s |
| 66 | |
| 67 | // CHK-PTXAS-CUBIN-BUNDLING: clang{{.*}}" "-o" "[[PTX:.*\.s]]" |
| 68 | // CHK-PTXAS-CUBIN-BUNDLING-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]" |
| 69 | // CHK-PTXAS-CUBIN-BUNDLING: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-inputs={{.*}}[[CUBIN]] |
| 70 | |
| 71 | /// ########################################################################### |
| 72 | |
| 73 | /// Check cubin file unbundling and usage by nvlink |
| 74 | // RUN: touch %t.o |
Jonas Hahnfeld | 4609b25 | 2017-11-21 15:06:28 +0000 | [diff] [blame] | 75 | // RUN: %clang -### -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 76 | // RUN: -no-canonical-prefixes -save-temps %t.o 2>&1 \ |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 77 | // RUN: | FileCheck -check-prefix=CHK-CUBIN-UNBUNDLING-NVLINK %s |
| 78 | |
| 79 | /// Use DAG to ensure that cubin file has been unbundled. |
| 80 | // CHK-CUBIN-UNBUNDLING-NVLINK-DAG: nvlink{{.*}}" {{.*}}"[[CUBIN:.*\.cubin]]" |
| 81 | // CHK-CUBIN-UNBUNDLING-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-outputs={{.*}}[[CUBIN]] |
| 82 | // CHK-CUBIN-UNBUNDLING-NVLINK-DAG-SAME: "-unbundle" |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 83 | |
| 84 | /// ########################################################################### |
| 85 | |
| 86 | /// Check cubin file generation and usage by nvlink |
| 87 | // RUN: touch %t1.o |
| 88 | // RUN: touch %t2.o |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 89 | // RUN: %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp \ |
| 90 | // RUN: -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \ |
| 91 | // RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s |
| 92 | /// Check cubin file generation and usage by nvlink when toolchain has BindArchAction |
| 93 | // RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp \ |
| 94 | // RUN: -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \ |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 95 | // RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s |
| 96 | |
Gheorghe-Teodor Bercea | 5636f4b | 2017-09-25 21:25:38 +0000 | [diff] [blame] | 97 | // CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin" |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 98 | |
| 99 | /// ########################################################################### |
| 100 | |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 101 | /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP. |
| 102 | // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -no-canonical-prefixes %s 2>&1 \ |
| 103 | // RUN: | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s |
| 104 | |
| 105 | // CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c" |
| 106 | |
| 107 | /// ########################################################################### |
| 108 | |
| 109 | /// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it. |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 110 | // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target \ |
| 111 | // RUN: -save-temps -no-canonical-prefixes %s 2>&1 \ |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 112 | // RUN: | FileCheck -check-prefix=CHK-PTXAS-NORELO %s |
| 113 | |
| 114 | // CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c" |
| 115 | |
| 116 | /// ########################################################################### |
| 117 | |
| 118 | /// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP |
| 119 | /// Check that the flag is passed when -fopenmp-relocatable-target is used. |
Jonas Hahnfeld | 7c78cc5 | 2017-11-21 14:44:45 +0000 | [diff] [blame] | 120 | // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target \ |
| 121 | // RUN: -save-temps -no-canonical-prefixes %s 2>&1 \ |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 122 | // RUN: | FileCheck -check-prefix=CHK-PTXAS-RELO %s |
| 123 | |
| 124 | // CHK-PTXAS-RELO: ptxas{{.*}}" "-c" |
Gheorghe-Teodor Bercea | 20789a5 | 2017-09-25 21:56:32 +0000 | [diff] [blame] | 125 | |
| 126 | /// ########################################################################### |
| 127 | |
| 128 | /// Check that error is not thrown by toolchain when no cuda lib flag is used. |
| 129 | /// Check that the flag is passed when -fopenmp-relocatable-target is used. |
| 130 | // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \ |
| 131 | // RUN: -nocudalib -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \ |
| 132 | // RUN: | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s |
| 133 | |
| 134 | // CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_60 |
Gheorghe-Teodor Bercea | 5a3608c | 2017-09-26 15:36:20 +0000 | [diff] [blame] | 135 | |
| 136 | /// ########################################################################### |
| 137 | |
| 138 | /// Check that error is not thrown by toolchain when no cuda lib device is found when using -S. |
| 139 | /// Check that the flag is passed when -fopenmp-relocatable-target is used. |
| 140 | // RUN: %clang -### -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \ |
| 141 | // RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \ |
| 142 | // RUN: | FileCheck -check-prefix=CHK-NOLIBDEVICE %s |
| 143 | |
| 144 | // CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60 |
Gheorghe-Teodor Bercea | 0d5aa84 | 2018-03-13 23:19:52 +0000 | [diff] [blame] | 145 | |
| 146 | /// ########################################################################### |
| 147 | |
| 148 | /// Check that the runtime bitcode library is part of the compile line. Create a bogus |
| 149 | /// bitcode library and add it to the LIBRARY_PATH. |
| 150 | // RUN: env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 151 | // RUN: -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \ |
| 152 | // RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \ |
| 153 | // RUN: | FileCheck -check-prefix=CHK-BCLIB %s |
| 154 | |
| 155 | // CHK-BCLIB: clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-cuda-bitcode{{.*}}libomptarget-nvptx-sm_20.bc |
| 156 | // CHK-BCLIB-NOT: {{error:|warning:}} |
| 157 | |
| 158 | /// ########################################################################### |
| 159 | |
| 160 | /// Check that the warning is thrown when the libomptarget bitcode library is not found. |
| 161 | /// Libomptarget requires sm_35 or newer so an sm_20 bitcode library should never exist. |
| 162 | // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \ |
| 163 | // RUN: -Xopenmp-target -march=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \ |
| 164 | // RUN: -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \ |
| 165 | // RUN: | FileCheck -check-prefix=CHK-BCLIB-WARN %s |
| 166 | |
| 167 | // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices. |
Alexey Bataev | e36c67b | 2018-04-18 16:31:09 +0000 | [diff] [blame^] | 168 | |
| 169 | /// Check that debug info is emitted in dwarf-2 |
| 170 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \ |
| 171 | // RUN: | FileCheck -check-prefix=NO_DEBUG %s |
| 172 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \ |
| 173 | // RUN: | FileCheck -check-prefix=NO_DEBUG %s |
| 174 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \ |
| 175 | // RUN: | FileCheck -check-prefix=NO_DEBUG %s |
| 176 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \ |
| 177 | // RUN: | FileCheck -check-prefix=NO_DEBUG %s |
| 178 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \ |
| 179 | // RUN: | FileCheck -check-prefix=NO_DEBUG %s |
| 180 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \ |
| 181 | // RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s |
| 182 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \ |
| 183 | // RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s |
| 184 | |
| 185 | // NO_DEBUG: ptxas |
| 186 | // LINE_TABLE: "-lineinfo" |
| 187 | // NO_DEBUG-NOT: "-g" |
| 188 | // NO_DEBUG: nvlink |
| 189 | // NO_DEBUG-NOT: "-g" |
| 190 | |
| 191 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \ |
| 192 | // RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 193 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \ |
| 194 | // RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 195 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --cuda-noopt-device-debug 2>&1 \ |
| 196 | // RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 197 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g2 2>&1 \ |
| 198 | // RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 199 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb2 -O0 --cuda-noopt-device-debug 2>&1 \ |
| 200 | // RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 201 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g3 -O3 --cuda-noopt-device-debug 2>&1 \ |
| 202 | // RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 203 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \ |
| 204 | // RUN: | FileCheck -check-prefix=HAS_DEBUG %s |
| 205 | |
| 206 | // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda" |
| 207 | // HAS_DEBUG-SAME: "-dwarf-version=2" |
| 208 | // HAS_DEBUG-SAME: "-fopenmp-is-device" |
| 209 | // HAS_DEBUG: ptxas |
| 210 | // HAS_DEBUG-SAME: "-g" |
| 211 | // HAS_DEBUG-SAME: "--dont-merge-basicblocks" |
| 212 | // HAS_DEBUG-SAME: "--return-at-end" |
| 213 | // HAS_DEBUG: nvlink |
| 214 | // HAS_DEBUG-SAME: "-g" |
| 215 | |