brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.7 KiB · 6717ae8 Raw
115 lines · c
1// Tests the driver when targeting the NVPTX architecture directly without a2// host toolchain to perform CUDA mappings.3 4//5// Test the generated phases when targeting NVPTX.6//7// RUN: %clang -target nvptx64-nvidia-cuda -ccc-print-phases %s 2>&1 \8// RUN:   | FileCheck -check-prefix=PHASES %s9 10//      PHASES: 0: input, "[[INPUT:.+]]", c11// PHASES-NEXT: 1: preprocessor, {0}, cpp-output12// PHASES-NEXT: 2: compiler, {1}, ir13// PHASES-NEXT: 3: backend, {2}, assembler14// PHASES-NEXT: 4: assembler, {3}, object15// PHASES-NEXT: 5: linker, {4}, image16 17//18// Test the generated bindings when targeting NVPTX.19//20// RUN: %clang -target nvptx64-nvidia-cuda -ccc-print-bindings %s 2>&1 \21// RUN:   | FileCheck -check-prefix=BINDINGS %s22 23//      BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[PTX:.+]].s"24// BINDINGS-NEXT: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[PTX]].s"], output: "[[CUBIN:.+]].o"25// BINDINGS-NEXT: "nvptx64-nvidia-cuda" - "NVPTX::Linker", inputs: ["[[CUBIN]].o"], output: "a.out"26 27//28// Test the generated arguments to the CUDA binary utils when targeting NVPTX. 29// Ensure that the '.o' files are converted to '.cubin' if produced internally.30//31// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -### %s 2>&1 \32// RUN:   | FileCheck -check-prefix=ARGS %s33 34//      ARGS: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_61" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"35// ARGS-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_61" "--output-file" "[[CUBIN:.+]].o" "[[PTX]].s" "-c"36// ARGS-NEXT: clang-nvlink-wrapper{{.*}}"-o" "a.out" "-arch" "sm_61"{{.*}}"[[CUBIN]].o"37 38//39// Test the generated arguments to the CUDA binary utils when targeting NVPTX. 40// Ensure that we emit '.o' files if compiled with '-c'41//42// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -c -### %s 2>&1 \43// RUN:   | FileCheck -check-prefix=OBJECT %s44// RUN: %clang -target nvptx64-nvidia-cuda -save-temps -march=sm_61 -c -### %s 2>&1 \45// RUN:   | FileCheck -check-prefix=OBJECT %s46 47//      OBJECT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_61" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"48// OBJECT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_61" "--output-file" "[[OBJ:.+]].o" "[[PTX]].s" "-c"49 50//51// Test the generated arguments to the CUDA binary utils when targeting NVPTX. 52// Ensure that we copy input '.o' files to '.cubin' files when linking.53//54// RUN: touch %t.o55// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -### %t.o 2>&1 \56// RUN:   | FileCheck -check-prefix=LINK %s57 58// LINK: clang-nvlink-wrapper{{.*}}"-o" "a.out" "-arch" "sm_61"{{.*}}[[CUBIN:.+]].o59 60//61// Test passing arguments directly to nvlink.62//63// RUN: %clang -target nvptx64-nvidia-cuda -Wl,-v -Wl,a,b -march=sm_52 -### %s 2>&1 \64// RUN:   | FileCheck -check-prefix=LINKER-ARGS %s65 66// LINKER-ARGS: clang-nvlink-wrapper{{.*}}"-v"{{.*}}"a" "b"67 68// Tests for handling a missing architecture.69//70// RUN: not %clang -target nvptx64-nvidia-cuda %s -### 2>&1 \71// RUN:   | FileCheck -check-prefix=MISSING %s72// RUN: not %clang -target nvptx64-nvidia-cuda -march=generic %s -### 2>&1 \73// RUN:   | FileCheck -check-prefix=MISSING %s74 75// MISSING: error: must pass in an explicit nvptx64 gpu architecture to 'ptxas'76// MISSING: error: must pass in an explicit nvptx64 gpu architecture to 'nvlink'77 78// Do not error when performing LTO.79//80// RUN: %clang -target nvptx64-nvidia-cuda -flto %s -### 2>&1 \81// RUN:   | FileCheck -check-prefix=MISSING-LTO %s82 83// MISSING-LTO-NOT: error: must pass in an explicit nvptx64 gpu architecture to 'nvlink'84 85// RUN: %clang -target nvptx64-nvidia-cuda -flto -c %s -### 2>&1 \86// RUN:   | FileCheck -check-prefix=GENERIC %s87// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_52 -march=generic -flto -c %s -### 2>&1 \88// RUN:   | FileCheck -check-prefix=GENERIC %s89 90// GENERIC-NOT: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-target-cpu"91 92//93// Test forwarding the necessary +ptx feature.94//95// RUN: %clang -target nvptx64-nvidia-cuda --cuda-feature=+ptx63 -march=sm_52 -### %s 2>&1 \96// RUN:   | FileCheck -check-prefix=FEATURE %s97 98// FEATURE: clang-nvlink-wrapper{{.*}}"--plugin-opt=-mattr=+ptx63"99 100//101// Test including the libc startup files and libc102//103// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_61 -stdlib -startfiles \104// RUN:   -nogpulib -nogpuinc -### %s 2>&1 | FileCheck -check-prefix=STARTUP %s105 106// STARTUP: clang-nvlink-wrapper{{.*}}"-lc" "-lm" "{{.*}}crt1.o"107 108//109// Test cuda path handling110//111// RUN: %clang -target nvptx64-nvidia-cuda -march=sm_52 --cuda-path=%S/Inputs/CUDA/usr/local/cuda \112// RUN:   -nogpulib -nogpuinc -### %s 2>&1 | FileCheck -check-prefix=PATH %s113 114// PATH: clang-nvlink-wrapper{{.*}}"--cuda-path={{.*}}/Inputs/CUDA/usr/local/cuda"115