Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 1 | /// |
| 2 | /// Perform several driver tests for OpenMP offloading |
| 3 | /// |
| 4 | |
| 5 | // Until this test is stabilized on all local configurations. |
| 6 | // UNSUPPORTED: linux |
| 7 | |
| 8 | // REQUIRES: clang-driver |
| 9 | // REQUIRES: x86-registered-target |
| 10 | // REQUIRES: powerpc-registered-target |
| 11 | // REQUIRES: nvptx-registered-target |
| 12 | |
| 13 | /// ########################################################################### |
| 14 | |
Gheorghe-Teodor Bercea | 0499212 | 2017-08-11 21:17:50 +0000 | [diff] [blame] | 15 | /// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr7 is passed when compiling for the device. |
| 16 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \ |
| 17 | // RUN: | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s |
| 18 | |
| 19 | // CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7" |
| 20 | |
| 21 | /// ########################################################################### |
| 22 | |
| 23 | /// Check -Xopenmp-target -march=pwr7 is passed when compiling for the device. |
| 24 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \ |
| 25 | // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s |
| 26 | |
| 27 | // CHK-FOPENMP-TARGET: clang{{.*}} "-target-cpu" "pwr7" |
| 28 | |
| 29 | /// ########################################################################### |
| 30 | |
| 31 | /// Check -Xopenmp-target triggers error when multiple triples are used. |
| 32 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu -Xopenmp-target -mcpu=pwr8 %s 2>&1 \ |
| 33 | // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR %s |
| 34 | |
| 35 | // CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR: clang{{.*}} error: cannot deduce implicit triple value for -Xopenmp-target, specify triple using -Xopenmp-target=<triple> |
| 36 | |
| 37 | /// ########################################################################### |
| 38 | |
| 39 | /// Check -Xopenmp-target triggers error when an option requiring arguments is passed to it. |
| 40 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target -mcpu=pwr8 %s 2>&1 \ |
| 41 | // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s |
| 42 | |
| 43 | // CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are unsupported |
| 44 | |
| 45 | /// ########################################################################### |
| 46 | |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 47 | /// Check -Xopenmp-target uses one of the archs provided when several archs are used. |
| 48 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_35 -Xopenmp-target -march=sm_60 %s 2>&1 \ |
| 49 | // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s |
| 50 | |
| 51 | // CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60" |
| 52 | // CHK-FOPENMP-TARGET-ARCHS: nvlink{{.*}}" "-arch" "sm_60" |
| 53 | |
| 54 | /// ########################################################################### |
| 55 | |
| 56 | /// Check -Xopenmp-target -march=sm_35 works as expected when two triples are present. |
| 57 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_35 %s 2>&1 \ |
| 58 | // RUN: | FileCheck -check-prefix=CHK-FOPENMP-TARGET-COMPILATION %s |
| 59 | |
| 60 | // CHK-FOPENMP-TARGET-COMPILATION: ptxas{{.*}}" "--gpu-name" "sm_35" |
| 61 | // CHK-FOPENMP-TARGET-COMPILATION: nvlink{{.*}}" "-arch" "sm_35" |
| 62 | |
| 63 | /// ########################################################################### |
| 64 | |
| 65 | /// Check cubin file generation and usage by nvlink |
| 66 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \ |
| 67 | // RUN: | FileCheck -check-prefix=CHK-CUBIN %s |
| 68 | |
| 69 | // CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}.s" |
| 70 | // CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" {{.*}}.cubin" {{.*}}.s" |
| 71 | // CHK-CUBIN-NEXT: nvlink" {{.*}}.cubin" |
| 72 | |
| 73 | |
| 74 | /// ########################################################################### |
| 75 | |
| 76 | /// Check cubin file generation and usage by nvlink when toolchain has BindArchAction |
| 77 | // RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \ |
| 78 | // RUN: | FileCheck -check-prefix=CHK-CUBIN-DARWIN %s |
| 79 | |
| 80 | // CHK-CUBIN-DARWIN: clang{{.*}}" "-o" "{{.*}}.s" |
| 81 | // CHK-CUBIN-DARWIN-NEXT: ptxas{{.*}}" "--output-file" {{.*}}.cubin" {{.*}}.s" |
| 82 | // CHK-CUBIN-DARWIN-NEXT: nvlink" {{.*}}.cubin" |
| 83 | |
| 84 | /// ########################################################################### |
| 85 | |
| 86 | /// Check cubin file generation and usage by nvlink |
| 87 | // RUN: touch %t1.o |
| 88 | // RUN: touch %t2.o |
| 89 | // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \ |
| 90 | // RUN: | FileCheck -check-prefix=CHK-TWOCUBIN %s |
| 91 | |
Gheorghe-Teodor Bercea | 5636f4b | 2017-09-25 21:25:38 +0000 | [diff] [blame^] | 92 | // CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin" |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 93 | |
| 94 | /// ########################################################################### |
| 95 | |
| 96 | /// Check cubin file generation and usage by nvlink when toolchain has BindArchAction |
| 97 | // RUN: touch %t1.o |
| 98 | // RUN: touch %t2.o |
| 99 | // RUN: %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \ |
| 100 | // RUN: | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s |
| 101 | |
Gheorghe-Teodor Bercea | 5636f4b | 2017-09-25 21:25:38 +0000 | [diff] [blame^] | 102 | // CHK-TWOCUBIN-DARWIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin" |
Gheorghe-Teodor Bercea | 9c52574 | 2017-08-11 15:46:22 +0000 | [diff] [blame] | 103 | |
| 104 | /// ########################################################################### |
| 105 | |
| 106 | /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP. |
| 107 | // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -no-canonical-prefixes %s 2>&1 \ |
| 108 | // RUN: | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s |
| 109 | |
| 110 | // CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c" |
| 111 | |
| 112 | /// ########################################################################### |
| 113 | |
| 114 | /// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it. |
| 115 | // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \ |
| 116 | // RUN: | FileCheck -check-prefix=CHK-PTXAS-NORELO %s |
| 117 | |
| 118 | // CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c" |
| 119 | |
| 120 | /// ########################################################################### |
| 121 | |
| 122 | /// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP |
| 123 | /// Check that the flag is passed when -fopenmp-relocatable-target is used. |
| 124 | // RUN: %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \ |
| 125 | // RUN: | FileCheck -check-prefix=CHK-PTXAS-RELO %s |
| 126 | |
| 127 | // CHK-PTXAS-RELO: ptxas{{.*}}" "-c" |