Home | History | Annotate | Download | only in Driver
      1 // Tests CUDA compilation pipeline construction in Driver.
      2 // REQUIRES: clang-driver
      3 // REQUIRES: x86-registered-target
      4 // REQUIRES: nvptx-registered-target
      5 
      6 // Simple compilation case:
      7 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
      8 // Compile device-side to PTX assembly and make sure we use it on the host side.
      9 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
     10 // Then compile host side and incorporate device code.
     11 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
     12 // Make sure we don't link anything.
     13 // RUN:   -check-prefix CUDA-NL %s
     14 
     15 // Typical compilation + link case:
     16 // RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \
     17 // Compile device-side to PTX assembly and make sure we use it on the host side
     18 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
     19 // Then compile host side and incorporate device code.
     20 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
     21 // Then link things.
     22 // RUN:   -check-prefix CUDA-L %s
     23 
     24 // Verify that --cuda-host-only disables device-side compilation and linking
     25 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \
     26 // Make sure we didn't run device-side compilation.
     27 // RUN:   | FileCheck -check-prefix CUDA-ND \
     28 // Then compile host side and make sure we don't attempt to incorporate GPU code.
     29 // RUN:    -check-prefix CUDA-H -check-prefix CUDA-H-NI \
     30 // Linking is allowed to happen, even if we're missing GPU code.
     31 // RUN:    -check-prefix CUDA-L %s
     32 
     33 // Same test as above, but with preceeding --cuda-device-only to make
     34 // sure only last option has effect.
     35 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only --cuda-host-only %s 2>&1 \
     36 // Make sure we didn't run device-side compilation.
     37 // RUN:   | FileCheck -check-prefix CUDA-ND \
     38 // Then compile host side and make sure we don't attempt to incorporate GPU code.
     39 // RUN:    -check-prefix CUDA-H -check-prefix CUDA-H-NI \
     40 // Linking is allowed to happen, even if we're missing GPU code.
     41 // RUN:    -check-prefix CUDA-L %s
     42 
     43 // Verify that --cuda-device-only disables host-side compilation and linking
     44 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
     45 // Compile device-side to PTX assembly
     46 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
     47 // Make sure there are no host cmpilation or linking.
     48 // RUN:   -check-prefix CUDA-NH -check-prefix CUDA-NL %s
     49 
     50 // Same test as above, but with preceeding --cuda-host-only to make
     51 // sure only last option has effect.
     52 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only --cuda-device-only %s 2>&1 \
     53 // Compile device-side to PTX assembly
     54 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
     55 // Make sure there are no host cmpilation or linking.
     56 // RUN:   -check-prefix CUDA-NH -check-prefix CUDA-NL %s
     57 
     58 // Verify that with -S we compile host and device sides to assembly
     59 // and incorporate device code on the host side.
     60 // RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \
     61 // Compile device-side to PTX assembly
     62 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
     63 // Then compile host side and incorporate GPU code.
     64 // RUN:  -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
     65 // Make sure we don't link anything.
     66 // RUN:  -check-prefix CUDA-NL %s
     67 
     68 // Verify that --cuda-gpu-arch option passes correct GPU
     69 // archtecture info to device compilation.
     70 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
     71 // Compile device-side to PTX assembly.
     72 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS \
     73 // RUN:   -check-prefix CUDA-D1-SM35 \
     74 // Then compile host side and incorporate GPU code.
     75 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-H-I1 \
     76 // Make sure we don't link anything.
     77 // RUN:   -check-prefix CUDA-NL %s
     78 
     79 // Verify that there is device-side compilation per --cuda-gpu-arch args
     80 // and that all results are included on the host side.
     81 // RUN: %clang -### -target x86_64-linux-gnu \
     82 // RUN:        --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
     83 // Compile both device-sides to PTX assembly
     84 // RUN:   | FileCheck \
     85 // RUN: -check-prefix CUDA-D1 -check-prefix CUDA-D1NS -check-prefix CUDA-D1-SM35 \
     86 // RUN: -check-prefix CUDA-D2 -check-prefix CUDA-D2-SM30 \
     87 // Then compile host side and incorporate both device-side outputs
     88 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-HNS \
     89 // RUN:   -check-prefix CUDA-H-I1 -check-prefix CUDA-H-I2 \
     90 // Make sure we don't link anything.
     91 // RUN:   -check-prefix CUDA-NL %s
     92 
     93 // Verify that device-side results are passed to correct tool when
     94 // -save-temps is used
     95 // RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \
     96 // Compile device-side to PTX assembly and make sure we use it on the host side.
     97 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1S \
     98 // Then compile host side and incorporate device code.
     99 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-HS -check-prefix CUDA-HS-I1 \
    100 // Make sure we don't link anything.
    101 // RUN:   -check-prefix CUDA-NL %s
    102 
    103 // Verify that device-side results are passed to correct tool when
    104 // -fno-integrated-as is used
    105 // RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -c %s 2>&1 \
    106 // Compile device-side to PTX assembly and make sure we use it on the host side.
    107 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS \
    108 // Then compile host side and incorporate device code.
    109 // RUN:   -check-prefix CUDA-H -check-prefix CUDA-HNS -check-prefix CUDA-HS-I1 \
    110 // RUN:   -check-prefix CUDA-H-AS \
    111 // Make sure we don't link anything.
    112 // RUN:   -check-prefix CUDA-NL %s
    113 
    114 // --cuda-host-only should never trigger unused arg warning.
    115 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
    116 // RUN:    FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
    117 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
    118 // RUN:    FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
    119 
    120 // --cuda-device-only should not produce warning compiling CUDA files
    121 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -c %s 2>&1 | \
    122 // RUN:    FileCheck -check-prefix CUDA-NO-UNUSED-CDO %s
    123 
    124 // --cuda-device-only should warn during non-CUDA compilation.
    125 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
    126 // RUN:    FileCheck -check-prefix CUDA-UNUSED-CDO %s
    127 
    128 // Match device-side preprocessor, and compiler phases with -save-temps
    129 // CUDA-D1S: "-cc1" "-triple" "nvptx64-nvidia-cuda"
    130 // CUDA-D1S-SAME: "-aux-triple" "x86_64--linux-gnu"
    131 // CUDA-D1S-SAME: "-fcuda-is-device"
    132 // CUDA-D1S-SAME: "-x" "cuda"
    133 
    134 // CUDA-D1S: "-cc1" "-triple" "nvptx64-nvidia-cuda"
    135 // CUDA-D1S-SAME: "-aux-triple" "x86_64--linux-gnu"
    136 // CUDA-D1S-SAME: "-fcuda-is-device"
    137 // CUDA-D1S-SAME: "-x" "cuda-cpp-output"
    138 
    139 // Match the job that produces PTX assembly
    140 // CUDA-D1: "-cc1" "-triple" "nvptx64-nvidia-cuda"
    141 // CUDA-D1NS-SAME: "-aux-triple" "x86_64--linux-gnu"
    142 // CUDA-D1-SAME: "-fcuda-is-device"
    143 // CUDA-D1-SM35-SAME: "-target-cpu" "sm_35"
    144 // CUDA-D1-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
    145 // CUDA-D1NS-SAME: "-x" "cuda"
    146 // CUDA-D1S-SAME: "-x" "ir"
    147 
    148 // Match another device-side compilation
    149 // CUDA-D2: "-cc1" "-triple" "nvptx64-nvidia-cuda"
    150 // CUDA-D2-SAME: "-aux-triple" "x86_64--linux-gnu"
    151 // CUDA-D2-SAME: "-fcuda-is-device"
    152 // CUDA-D2-SM30-SAME: "-target-cpu" "sm_30"
    153 // CUDA-D2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
    154 // CUDA-D2-SAME: "-x" "cuda"
    155 
    156 // Match no device-side compilation
    157 // CUDA-ND-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
    158 // CUDA-ND-SAME-NOT: "-fcuda-is-device"
    159 
    160 // Match host-side preprocessor job with -save-temps
    161 // CUDA-HS: "-cc1" "-triple" "x86_64--linux-gnu"
    162 // CUDA-HS-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
    163 // CUDA-HS-SAME-NOT: "-fcuda-is-device"
    164 // CUDA-HS-SAME: "-x" "cuda"
    165 
    166 // Match host-side compilation
    167 // CUDA-H: "-cc1" "-triple" "x86_64--linux-gnu"
    168 // CUDA-H-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
    169 // CUDA-H-SAME-NOT: "-fcuda-is-device"
    170 // CUDA-H-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
    171 // CUDA-HNS-SAME: "-x" "cuda"
    172 // CUDA-HS-SAME: "-x" "cuda-cpp-output"
    173 // CUDA-H-I1-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY1]]"
    174 // CUDA-H-I2-SAME: "-fcuda-include-gpubinary" "[[GPUBINARY2]]"
    175 
    176 // Match external assembler that uses compilation output
    177 // CUDA-H-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
    178 
    179 // Match no GPU code inclusion.
    180 // CUDA-H-NI-NOT: "-fcuda-include-gpubinary"
    181 
    182 // Match no CUDA compilation
    183 // CUDA-NH-NOT: "-cc1" "-triple"
    184 // CUDA-NH-SAME-NOT: "-x" "cuda"
    185 
    186 // Match linker
    187 // CUDA-L: "{{.*}}{{ld|link}}{{(.exe)?}}"
    188 // CUDA-L-SAME: "[[HOSTOUTPUT]]"
    189 
    190 // Match no linker
    191 // CUDA-NL-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
    192 
    193 // CUDA-NO-UNUSED-CHO-NOT: warning: argument unused during compilation: '--cuda-host-only'
    194 // CUDA-UNUSED-CDO: warning: argument unused during compilation: '--cuda-device-only'
    195 // CUDA-NO-UNUSED-CDO-NOT: warning: argument unused during compilation: '--cuda-device-only'
    196