2
2
3
3
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
4
4
// RUN: -fcuda-include-gpubinary %t -o - -x hip\
5
- // RUN: | FileCheck -check-prefixes=CHECK,GNU %s
5
+ // RUN: | FileCheck -check-prefixes=CHECK,GNU,GNU-HIP,HIP %s
6
6
7
7
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
8
8
// RUN: -fcuda-include-gpubinary %t -o - -x hip\
11
11
// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
12
12
// RUN: -aux-triple amdgcn-amd-amdhsa -fcuda-include-gpubinary \
13
13
// RUN: %t -o - -x hip\
14
- // RUN: | FileCheck -check-prefixes=CHECK,MSVC %s
14
+ // RUN: | FileCheck -check-prefixes=CHECK,MSVC,MSVC-HIP,HIP %s
15
+
16
+ // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
17
+ // RUN: -aux-triple nvptx64 -fcuda-include-gpubinary \
18
+ // RUN: %t -target-sdk-version=9.2 -o - \
19
+ // RUN: | FileCheck -check-prefixes=CHECK,MSVC,CUDA %s
15
20
16
21
// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
17
22
// RUN: -aux-triple amdgcn-amd-amdhsa -fcuda-include-gpubinary \
22
27
23
28
// Check kernel handles are emitted for non-MSVC target but not for MSVC target.
24
29
25
- // GNU: @[[HCKERN:ckernel]] = constant ptr @[[CSTUB:__device_stub__ckernel]], align 8
26
- // GNU: @[[HNSKERN:_ZN2ns8nskernelEv]] = constant ptr @[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]], align 8
27
- // GNU: @[[HTKERN:_Z10kernelfuncIiEvv]] = linkonce_odr constant ptr @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]], comdat, align 8
28
- // GNU: @[[HDKERN:_Z11kernel_declv]] = external constant ptr, align 8
29
- // GNU: @[[HTDKERN:_Z20template_kernel_declIiEvT_]] = external constant ptr, align 8
30
-
31
- // MSVC: @[[HCKERN:ckernel]] = dso_local constant ptr @[[CSTUB:__device_stub__ckernel]], align 8
32
- // MSVC: @[[HNSKERN:"\?nskernel@ns@@YAXXZ.*"]] = dso_local constant ptr @[[NSSTUB:"\?__device_stub__nskernel@ns@@YAXXZ"]], align 8
33
- // MSVC: @[[HTKERN:"\?\?\$kernelfunc@H@@YAXXZ.*"]] = linkonce_odr dso_local constant ptr @[[TSTUB:"\?\?\$__device_stub__kernelfunc@H@@YAXXZ.*"]], comdat, align 8
34
- // MSVC: @[[HDKERN:"\?kernel_decl@@YAXXZ.*"]] = external dso_local constant ptr, align 8
35
- // MSVC: @[[HTDKERN:"\?\?\$template_kernel_decl@H@@YAXH.*"]] = external dso_local constant ptr, align 8
30
+ // GNU-HIP : @[[HCKERN:ckernel]] = constant ptr @[[CSTUB:__device_stub__ckernel]], align 8
31
+ // GNU-HIP : @[[HNSKERN:_ZN2ns8nskernelEv]] = constant ptr @[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]], align 8
32
+ // GNU-HIP : @[[HTKERN:_Z10kernelfuncIiEvv]] = linkonce_odr constant ptr @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]], comdat, align 8
33
+ // GNU-HIP : @[[HDKERN:_Z11kernel_declv]] = external constant ptr, align 8
34
+ // GNU-HIP : @[[HTDKERN:_Z20template_kernel_declIiEvT_]] = external constant ptr, align 8
35
+
36
+ // MSVC-HIP : @[[HCKERN:ckernel]] = dso_local constant ptr @[[CSTUB:__device_stub__ckernel]], align 8
37
+ // MSVC-HIP : @[[HNSKERN:"\?nskernel@ns@@YAXXZ.*"]] = dso_local constant ptr @[[NSSTUB:"\?__device_stub__nskernel@ns@@YAXXZ"]], align 8
38
+ // MSVC-HIP : @[[HTKERN:"\?\?\$kernelfunc@H@@YAXXZ.*"]] = linkonce_odr dso_local constant ptr @[[TSTUB:"\?\?\$__device_stub__kernelfunc@H@@YAXXZ.*"]], comdat, align 8
39
+ // MSVC-HIP : @[[HDKERN:"\?kernel_decl@@YAXXZ.*"]] = external dso_local constant ptr, align 8
40
+ // MSVC-HIP : @[[HTDKERN:"\?\?\$template_kernel_decl@H@@YAXH.*"]] = external dso_local constant ptr, align 8
36
41
extern " C" __global__ void ckernel () {}
37
42
43
+ // CUDA: @[[HTKERN:"\?\?\$__device_stub__kernelfunc@H@@YAXXZ\.id"]] = linkonce_odr dso_local global i8 0, comdat
44
+
38
45
namespace ns {
39
46
__global__ void nskernel () {}
40
47
} // namespace ns
@@ -60,18 +67,23 @@ extern "C" void launch(void *kern);
60
67
61
68
// Non-template kernel stub functions
62
69
63
- // CHECK: define{{.*}}@[[CSTUB]]
64
- // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HCKERN]]
70
+ // HIP: define{{.*}}@[[CSTUB]]
71
+ // CUDA: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
72
+ // HIP: call{{.*}}@hipLaunchByPtr{{.*}}@[[HCKERN]]
73
+ // CUDA: call{{.*}}@cudaLaunch{{.*}}@[[CSTUB]]
65
74
66
- // CHECK: define{{.*}}@[[NSSTUB]]
67
- // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HNSKERN]]
75
+ // HIP: define{{.*}}@[[NSSTUB]]
76
+ // CUDA: define{{.*}}@[[NSSTUB:"\?__device_stub__nskernel@ns@@YAXXZ"]]
77
+ // HIP: call{{.*}}@hipLaunchByPtr{{.*}}@[[HNSKERN]]
78
+ // CUDA: call{{.*}}@cudaLaunch{{.*}}@[[NSSTUB]]
68
79
69
80
// Check kernel stub is called for triple chevron.
70
81
71
82
// CHECK-LABEL: define{{.*}}@fun1()
72
83
// CHECK: call void @[[CSTUB]]()
73
84
// CHECK: call void @[[NSSTUB]]()
74
- // CHECK: call void @[[TSTUB]]()
85
+ // HIP: call void @[[TSTUB]]()
86
+ // CUDA: call void @[[TSTUB:"\?\?\$__device_stub__kernelfunc@H@@YAXXZ.*"]]()
75
87
// GNU: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
76
88
// GNU: call void @[[TDSTUB:_Z35__device_stub__template_kernel_declIiEvT_]](
77
89
// MSVC: call void @[[DSTUB:"\?__device_stub__kernel_decl@@YAXXZ"]]()
@@ -88,7 +100,10 @@ extern "C" void fun1(void) {
88
100
// Template kernel stub functions
89
101
90
102
// CHECK: define{{.*}}@[[TSTUB]]
91
- // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HTKERN]]
103
+ // HIP: call{{.*}}@hipLaunchByPtr{{.*}}@[[HTKERN]]
104
+ // CUDA: call{{.*}}@cudaLaunch{{.*}}@[[TSTUB]]
105
+ // CUDA: store i8 1, ptr @[[HTKERN]], align 1
106
+ // CHECK: ret void
92
107
93
108
// Check declaration of stub function for external kernel.
94
109
@@ -98,11 +113,11 @@ extern "C" void fun1(void) {
98
113
// Check kernel handle is used for passing the kernel as a function pointer.
99
114
100
115
// CHECK-LABEL: define{{.*}}@fun2()
101
- // CHECK : call void @launch({{.*}}[[HCKERN]]
102
- // CHECK : call void @launch({{.*}}[[HNSKERN]]
103
- // CHECK : call void @launch({{.*}}[[HTKERN]]
104
- // CHECK : call void @launch({{.*}}[[HDKERN]]
105
- // CHECK : call void @launch({{.*}}[[HTDKERN]]
116
+ // HIP : call void @launch({{.*}}[[HCKERN]]
117
+ // HIP : call void @launch({{.*}}[[HNSKERN]]
118
+ // HIP : call void @launch({{.*}}[[HTKERN]]
119
+ // HIP : call void @launch({{.*}}[[HDKERN]]
120
+ // HIP : call void @launch({{.*}}[[HTDKERN]]
106
121
extern " C" void fun2 () {
107
122
launch ((void *)ckernel);
108
123
launch ((void *)ns::nskernel);
@@ -114,10 +129,10 @@ extern "C" void fun2() {
114
129
// Check kernel handle is used for assigning a kernel to a function pointer.
115
130
116
131
// CHECK-LABEL: define{{.*}}@fun3()
117
- // CHECK : store ptr @[[HCKERN]], ptr @kernel_ptr, align 8
118
- // CHECK : store ptr @[[HCKERN]], ptr @kernel_ptr, align 8
119
- // CHECK : store ptr @[[HCKERN]], ptr @void_ptr, align 8
120
- // CHECK : store ptr @[[HCKERN]], ptr @void_ptr, align 8
132
+ // HIP : store ptr @[[HCKERN]], ptr @kernel_ptr, align 8
133
+ // HIP : store ptr @[[HCKERN]], ptr @kernel_ptr, align 8
134
+ // HIP : store ptr @[[HCKERN]], ptr @void_ptr, align 8
135
+ // HIP : store ptr @[[HCKERN]], ptr @void_ptr, align 8
121
136
extern " C" void fun3 () {
122
137
kernel_ptr = ckernel;
123
138
kernel_ptr = &ckernel;
@@ -129,11 +144,11 @@ extern "C" void fun3() {
129
144
// used with triple chevron.
130
145
131
146
// CHECK-LABEL: define{{.*}}@fun4()
132
- // CHECK : store ptr @[[HCKERN]], ptr @kernel_ptr
133
- // CHECK : call noundef i32 @{{.*hipConfigureCall}}
134
- // CHECK : %[[HANDLE:.*]] = load ptr, ptr @kernel_ptr, align 8
135
- // CHECK : %[[STUB:.*]] = load ptr, ptr %[[HANDLE]], align 8
136
- // CHECK : call void %[[STUB]]()
147
+ // HIP : store ptr @[[HCKERN]], ptr @kernel_ptr
148
+ // HIP : call noundef i32 @{{.*hipConfigureCall}}
149
+ // HIP : %[[HANDLE:.*]] = load ptr, ptr @kernel_ptr, align 8
150
+ // HIP : %[[STUB:.*]] = load ptr, ptr %[[HANDLE]], align 8
151
+ // HIP : call void %[[STUB]]()
137
152
extern " C" void fun4 () {
138
153
kernel_ptr = ckernel;
139
154
kernel_ptr<<<1 ,1 >>> ();
@@ -142,20 +157,20 @@ extern "C" void fun4() {
142
157
// Check kernel handle is passed to a function.
143
158
144
159
// CHECK-LABEL: define{{.*}}@fun5()
145
- // CHECK : store ptr @[[HCKERN]], ptr @kernel_ptr
146
- // CHECK : %[[HANDLE:.*]] = load ptr, ptr @kernel_ptr, align 8
147
- // CHECK : call void @launch(ptr noundef %[[HANDLE]])
160
+ // HIP : store ptr @[[HCKERN]], ptr @kernel_ptr
161
+ // HIP : %[[HANDLE:.*]] = load ptr, ptr @kernel_ptr, align 8
162
+ // HIP : call void @launch(ptr noundef %[[HANDLE]])
148
163
extern " C" void fun5 () {
149
164
kernel_ptr = ckernel;
150
165
launch ((void *)kernel_ptr);
151
166
}
152
167
153
168
// Check kernel handle is registered.
154
169
155
- // CHECK -LABEL: define{{.*}}@__hip_register_globals
156
- // CHECK : call{{.*}}@__hipRegisterFunction{{.*}}@[[HCKERN]]{{.*}}@[[CKERN]]
157
- // CHECK : call{{.*}}@__hipRegisterFunction{{.*}}@[[HNSKERN]]{{.*}}@[[NSKERN]]
158
- // CHECK : call{{.*}}@__hipRegisterFunction{{.*}}@[[HTKERN]]{{.*}}@[[TKERN]]
170
+ // HIP -LABEL: define{{.*}}@__hip_register_globals
171
+ // HIP : call{{.*}}@__hipRegisterFunction{{.*}}@[[HCKERN]]{{.*}}@[[CKERN]]
172
+ // HIP : call{{.*}}@__hipRegisterFunction{{.*}}@[[HNSKERN]]{{.*}}@[[NSKERN]]
173
+ // HIP : call{{.*}}@__hipRegisterFunction{{.*}}@[[HTKERN]]{{.*}}@[[TKERN]]
159
174
// NEG-NOT: call{{.*}}@__hipRegisterFunction{{.*}}__device_stub
160
175
// NEG-NOT: call{{.*}}@__hipRegisterFunction{{.*}}kernel_decl
161
176
// NEG-NOT: call{{.*}}@__hipRegisterFunction{{.*}}template_kernel_decl
0 commit comments