2015-07-14 07:27:56 +08:00
|
|
|
// Tests CUDA compilation pipeline construction in Driver.
|
|
|
|
// REQUIRES: clang-driver
|
2015-07-15 02:49:17 +08:00
|
|
|
// REQUIRES: x86-registered-target
|
|
|
|
// REQUIRES: nvptx-registered-target
|
2015-07-14 07:27:56 +08:00
|
|
|
|
2016-01-13 09:24:35 +08:00
|
|
|
// Simple compilation case. Compile device-side to PTX assembly and make sure
|
|
|
|
// we use it on the host side.
|
2015-07-17 01:24:18 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
|
|
|
// RUN: -check-prefix HOST -check-prefix INCLUDES-DEVICE \
|
|
|
|
// RUN: -check-prefix NOLINK %s
|
|
|
|
|
|
|
|
// Typical compilation + link case.
|
2015-07-17 01:24:18 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
|
|
|
// RUN: -check-prefix HOST -check-prefix INCLUDES-DEVICE \
|
|
|
|
// RUN: -check-prefix LINK %s
|
|
|
|
|
|
|
|
// Verify that --cuda-host-only disables device-side compilation, but doesn't
|
|
|
|
// disable host-side compilation/linking.
|
2015-07-17 01:24:18 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
|
|
|
|
// RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
|
|
|
|
|
2016-04-19 10:27:07 +08:00
|
|
|
// Verify that --cuda-device-only disables host-side compilation and linking.
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
|
|
|
// RUN: -check-prefix NOHOST -check-prefix NOLINK %s
|
|
|
|
|
|
|
|
// Check that the last of --cuda-compile-host-device, --cuda-host-only, and
|
|
|
|
// --cuda-device-only wins.
|
|
|
|
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --cuda-host-only %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
|
|
|
|
// RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
|
|
|
|
|
2016-04-19 10:27:07 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
|
|
|
|
// RUN: --cuda-host-only %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
|
|
|
|
// RUN: -check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
|
|
|
|
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only \
|
|
|
|
// RUN: --cuda-device-only %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
|
|
|
// RUN: -check-prefix NOHOST -check-prefix NOLINK %s
|
2015-07-14 07:27:56 +08:00
|
|
|
|
2016-04-19 10:27:07 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
|
|
|
|
// RUN: --cuda-device-only %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
|
|
|
// RUN: -check-prefix NOHOST -check-prefix NOLINK %s
|
2015-09-23 01:23:09 +08:00
|
|
|
|
2016-04-19 10:27:07 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only \
|
|
|
|
// RUN: --cuda-compile-host-device %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
|
|
|
// RUN: -check-prefix HOST -check-prefix INCLUDES-DEVICE \
|
|
|
|
// RUN: -check-prefix LINK %s
|
|
|
|
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --cuda-compile-host-device %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
|
|
|
// RUN: -check-prefix HOST -check-prefix INCLUDES-DEVICE \
|
|
|
|
// RUN: -check-prefix LINK %s
|
|
|
|
|
2016-01-13 09:24:35 +08:00
|
|
|
// Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
|
|
|
|
// device compilation.
|
2016-12-10 06:59:17 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_30 -c %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
2016-12-10 06:59:17 +08:00
|
|
|
// RUN: -check-prefix DEVICE-SM30 -check-prefix HOST \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: -check-prefix INCLUDES-DEVICE -check-prefix NOLINK %s
|
|
|
|
|
|
|
|
// Verify that there is one device-side compilation per --cuda-gpu-arch args
|
2015-07-14 07:27:56 +08:00
|
|
|
// and that all results are included on the host side.
|
2015-08-28 02:10:41 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
2016-12-10 06:59:17 +08:00
|
|
|
// RUN: -check-prefix DEVICE2 -check-prefix DEVICE-SM30 \
|
|
|
|
// RUN: -check-prefix DEVICE2-SM35 -check-prefix HOST \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: -check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
|
2016-01-15 05:41:27 +08:00
|
|
|
// RUN: -check-prefix NOLINK %s
|
2016-01-13 09:24:35 +08:00
|
|
|
|
|
|
|
// Verify that device-side results are passed to the correct tool when
|
|
|
|
// -save-temps is used.
|
2015-08-28 02:10:41 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu -save-temps -c %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-SAVE \
|
|
|
|
// RUN: -check-prefix HOST -check-prefix HOST-SAVE -check-prefix NOLINK %s
|
|
|
|
|
|
|
|
// Verify that device-side results are passed to the correct tool when
|
|
|
|
// -fno-integrated-as is used.
|
2015-08-28 02:10:41 +08:00
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu -fno-integrated-as -c %s 2>&1 \
|
2016-01-13 09:24:35 +08:00
|
|
|
// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
|
|
|
|
// RUN: -check-prefix HOST -check-prefix HOST-NOSAVE \
|
|
|
|
// RUN: -check-prefix HOST-AS -check-prefix NOLINK %s
|
|
|
|
|
2016-12-10 06:59:17 +08:00
|
|
|
// Verify that --[no-]cuda-gpu-arch arguments are handled correctly.
|
|
|
|
// a) --no-cuda-gpu-arch=X negates preceeding --cuda-gpu-arch=X
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
|
|
|
|
// RUN: --no-cuda-gpu-arch=sm_35 \
|
|
|
|
// RUN: -c %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,NOARCH-SM35 %s
|
|
|
|
|
|
|
|
// b) --no-cuda-gpu-arch=X negates more than one preceeding --cuda-gpu-arch=X
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
|
|
|
|
// RUN: --no-cuda-gpu-arch=sm_35 \
|
|
|
|
// RUN: -c %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,NOARCH-SM35 %s
|
|
|
|
|
|
|
|
// c) if --no-cuda-gpu-arch=X negates all preceeding --cuda-gpu-arch=X
|
|
|
|
// we default to sm_20 -- same as if no --cuda-gpu-arch were passed.
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
|
|
|
|
// RUN: --no-cuda-gpu-arch=sm_35 --no-cuda-gpu-arch=sm_30 \
|
|
|
|
// RUN: -c %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefixes ARCH-SM20,NOARCH-SM30,NOARCH-SM35 %s
|
|
|
|
|
|
|
|
// d) --no-cuda-gpu-arch=X is a no-op if there's no preceding --cuda-gpu-arch=X
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30\
|
|
|
|
// RUN: --no-cuda-gpu-arch=sm_50 \
|
|
|
|
// RUN: -c %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,ARCH-SM35 %s
|
|
|
|
|
|
|
|
// e) --no-cuda-gpu-arch=X does not affect following --cuda-gpu-arch=X
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --no-cuda-gpu-arch=sm_35 --no-cuda-gpu-arch=sm_30 \
|
|
|
|
// RUN: --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
|
|
|
|
// RUN: -c %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,ARCH-SM35 %s
|
|
|
|
|
|
|
|
// f) --no-cuda-gpu-arch=all negates all preceding --cuda-gpu-arch=X
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 \
|
|
|
|
// RUN: --no-cuda-gpu-arch=all \
|
|
|
|
// RUN: --cuda-gpu-arch=sm_35 \
|
|
|
|
// RUN: -c %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefixes NOARCH-SM20,NOARCH-SM30,ARCH-SM35 %s
|
|
|
|
|
|
|
|
// g) There's no --cuda-gpu-arch=all
|
|
|
|
// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
|
|
|
|
// RUN: --cuda-gpu-arch=all \
|
|
|
|
// RUN: -c %s 2>&1 \
|
|
|
|
// RUN: | FileCheck -check-prefix ARCHALLERROR %s
|
|
|
|
|
|
|
|
// ARCH-SM20: "-cc1"{{.*}}"-target-cpu" "sm_20"
|
|
|
|
// NOARCH-SM20-NOT: "-cc1"{{.*}}"-target-cpu" "sm_20"
|
|
|
|
// ARCH-SM30: "-cc1"{{.*}}"-target-cpu" "sm_30"
|
|
|
|
// NOARCH-SM30-NOT: "-cc1"{{.*}}"-target-cpu" "sm_30"
|
|
|
|
// ARCH-SM35: "-cc1"{{.*}}"-target-cpu" "sm_35"
|
|
|
|
// NOARCH-SM35-NOT: "-cc1"{{.*}}"-target-cpu" "sm_35"
|
|
|
|
// ARCHALLERROR: error: Unsupported CUDA gpu architecture: all
|
|
|
|
|
2016-01-13 09:24:35 +08:00
|
|
|
// Match device-side preprocessor and compiler phases with -save-temps.
|
|
|
|
// DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
|
|
|
|
// DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
|
|
|
|
// DEVICE-SAVE-SAME: "-fcuda-is-device"
|
|
|
|
// DEVICE-SAVE-SAME: "-x" "cuda"
|
|
|
|
|
|
|
|
// DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
|
|
|
|
// DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
|
|
|
|
// DEVICE-SAVE-SAME: "-fcuda-is-device"
|
|
|
|
// DEVICE-SAVE-SAME: "-x" "cuda-cpp-output"
|
|
|
|
|
|
|
|
// Match the job that produces PTX assembly.
|
|
|
|
// DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
|
|
|
|
// DEVICE-NOSAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
|
|
|
|
// DEVICE-SAME: "-fcuda-is-device"
|
2016-12-10 06:59:17 +08:00
|
|
|
// DEVICE-SM30-SAME: "-target-cpu" "sm_30"
|
2016-01-15 05:41:27 +08:00
|
|
|
// DEVICE-SAME: "-o" "[[PTXFILE:[^"]*]]"
|
2016-01-13 09:24:35 +08:00
|
|
|
// DEVICE-NOSAVE-SAME: "-x" "cuda"
|
|
|
|
// DEVICE-SAVE-SAME: "-x" "ir"
|
|
|
|
|
2016-01-15 05:41:27 +08:00
|
|
|
// Match the call to ptxas (which assembles PTX to SASS).
|
|
|
|
// DEVICE:ptxas
|
2016-12-10 06:59:17 +08:00
|
|
|
// DEVICE-SM30-DAG: "--gpu-name" "sm_30"
|
2016-01-15 05:41:27 +08:00
|
|
|
// DEVICE-DAG: "--output-file" "[[CUBINFILE:[^"]*]]"
|
|
|
|
// DEVICE-DAG: "[[PTXFILE]]"
|
|
|
|
|
2016-01-13 09:24:35 +08:00
|
|
|
// Match another device-side compilation.
|
|
|
|
// DEVICE2: "-cc1" "-triple" "nvptx64-nvidia-cuda"
|
|
|
|
// DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu"
|
|
|
|
// DEVICE2-SAME: "-fcuda-is-device"
|
2016-12-10 06:59:17 +08:00
|
|
|
// DEVICE2-SM35-SAME: "-target-cpu" "sm_35"
|
2016-01-13 09:24:35 +08:00
|
|
|
// DEVICE2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
|
|
|
|
// DEVICE2-SAME: "-x" "cuda"
|
|
|
|
|
|
|
|
// Match no device-side compilation.
|
|
|
|
// NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
|
2016-02-10 10:08:24 +08:00
|
|
|
// NODEVICE-NOT: "-fcuda-is-device"
|
2016-01-13 09:24:35 +08:00
|
|
|
|
2016-01-15 05:41:27 +08:00
|
|
|
// INCLUDES-DEVICE:fatbinary
|
|
|
|
// INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]"
|
|
|
|
// INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]"
|
|
|
|
// INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]"
|
|
|
|
|
2016-01-13 09:24:35 +08:00
|
|
|
// Match host-side preprocessor job with -save-temps.
|
|
|
|
// HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
|
|
|
|
// HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
|
2016-02-10 10:08:24 +08:00
|
|
|
// HOST-SAVE-NOT: "-fcuda-is-device"
|
2016-01-13 09:24:35 +08:00
|
|
|
// HOST-SAVE-SAME: "-x" "cuda"
|
|
|
|
|
|
|
|
// Match host-side compilation.
|
|
|
|
// HOST: "-cc1" "-triple" "x86_64--linux-gnu"
|
|
|
|
// HOST-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
|
2016-02-10 10:08:24 +08:00
|
|
|
// HOST-NOT: "-fcuda-is-device"
|
2016-01-13 09:24:35 +08:00
|
|
|
// HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
|
|
|
|
// HOST-NOSAVE-SAME: "-x" "cuda"
|
|
|
|
// HOST-SAVE-SAME: "-x" "cuda-cpp-output"
|
2016-01-15 05:41:27 +08:00
|
|
|
// INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
|
2016-01-13 09:24:35 +08:00
|
|
|
|
|
|
|
// Match external assembler that uses compilation output.
|
|
|
|
// HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
|
2015-08-28 02:10:41 +08:00
|
|
|
|
2015-07-14 07:27:56 +08:00
|
|
|
// Match no GPU code inclusion.
|
2016-01-13 09:24:35 +08:00
|
|
|
// NOINCLUDES-DEVICE-NOT: "-fcuda-include-gpubinary"
|
2015-07-14 07:27:56 +08:00
|
|
|
|
2016-01-13 09:24:35 +08:00
|
|
|
// Match no host compilation.
|
|
|
|
// NOHOST-NOT: "-cc1" "-triple"
|
2016-02-10 10:08:24 +08:00
|
|
|
// NOHOST-NOT: "-x" "cuda"
|
2015-07-14 07:27:56 +08:00
|
|
|
|
2016-01-13 09:24:35 +08:00
|
|
|
// Match linker.
|
|
|
|
// LINK: "{{.*}}{{ld|link}}{{(.exe)?}}"
|
|
|
|
// LINK-SAME: "[[HOSTOUTPUT]]"
|
2015-07-14 07:27:56 +08:00
|
|
|
|
2016-01-13 09:24:35 +08:00
|
|
|
// Match no linker.
|
|
|
|
// NOLINK-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
|