• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// REQUIRES: clang-driver
2// REQUIRES: x86-registered-target
3// REQUIRES: amdgpu-registered-target
4
5// RUN: %clang -### -target x86_64-linux-gnu \
6// RUN:   -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
7// RUN:   --hip-device-lib=lib1.bc --hip-device-lib=lib2.bc \
8// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib1 \
9// RUN:   --hip-device-lib-path=%S/Inputs/hip_multiple_inputs/lib2 \
10// RUN:   -fuse-ld=lld -fgpu-rdc -nogpuinc \
11// RUN:   -fhip-dump-offload-linker-script \
12// RUN:   %S/Inputs/hip_multiple_inputs/a.cu \
13// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
14// RUN: 2>&1 | FileCheck %s
15
16// check code object alignment in dumped llvm-mc input
17// CHECK: .p2align 12
18
19// emit objects for host side path
20// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
21// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
22// CHECK-SAME: "-emit-obj"
23// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
24// CHECK-SAME: {{.*}} "-o" [[A_OBJ_HOST:".*o"]] "-x" "hip"
25// CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
26
27// CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
28// CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
29// CHECK-SAME: "-emit-obj"
30// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
31// CHECK-SAME: {{.*}} "-o" [[B_OBJ_HOST:".*o"]] "-x" "hip"
32// CHECK-SAME: {{.*}} [[B_SRC:".*b.hip"]]
33
34// generate image for device side path on gfx803
35// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
36// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
37// CHECK-SAME: "-emit-llvm-bc"
38// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
39// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
40// CHECK-SAME: "-fapply-global-visibility-to-externs"
41// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
42// CHECK-SAME: "-target-cpu" "gfx803"
43// CHECK-SAME: {{.*}} "-o" [[A_BC1:".*bc"]] "-x" "hip"
44// CHECK-SAME: {{.*}} [[A_SRC]]
45
46// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
47// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
48// CHECK-SAME: "-emit-llvm-bc"
49// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
50// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
51// CHECK-SAME: "-fapply-global-visibility-to-externs"
52// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
53// CHECK-SAME: "-target-cpu" "gfx803"
54// CHECK-SAME: {{.*}} "-o" [[B_BC1:".*bc"]] "-x" "hip"
55// CHECK-SAME: {{.*}} [[B_SRC]]
56
57// CHECK-NOT: "*.llvm-link"
58// CHECK-NOT: ".*opt"
59// CHECK-NOT: ".*llc"
60// CHECK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
61// CHECK-SAME: "-plugin-opt=mcpu=gfx803"
62// CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
63
64// generate image for device side path on gfx900
65// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
66// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
67// CHECK-SAME: "-emit-llvm-bc"
68// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
69// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
70// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
71// CHECK-SAME: "-target-cpu" "gfx900"
72// CHECK-SAME: {{.*}} "-o" [[A_BC2:".*bc"]] "-x" "hip"
73// CHECK-SAME: {{.*}} [[A_SRC]]
74
75// CHECK: [[CLANG]] "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
76// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
77// CHECK-SAME: "-emit-llvm-bc"
78// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
79// CHECK-SAME: "-fcuda-is-device" "-fgpu-rdc"
80// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
81// CHECK-SAME: "-target-cpu" "gfx900"
82// CHECK-SAME: {{.*}} "-o" [[B_BC2:".*bc"]] "-x" "hip"
83// CHECK-SAME: {{.*}} [[B_SRC]]
84
85// CHECK-NOT: "*.llvm-link"
86// CHECK-NOT: ".*opt"
87// CHECK-NOT: ".*llc"
88// CHECK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
89// CHECK-SAME: "-plugin-opt=mcpu=gfx900"
90// CHECK-SAME: "-o" "[[IMG_DEV2:.*.out]]" [[A_BC2]] [[B_BC2]]
91
92// combine images generated into hip fat binary object
93// CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
94// CHECK-SAME: "-bundle-align=4096"
95// CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900"
96// CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
97
98// CHECK: [[MC:".*llvm-mc.*"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
99
100// output the executable
101// CHECK: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
102