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: @[[HCKERN:__device_stub__ckernel\.id]] = dso_local global i8 0
44
+ // CUDA: @[[HNSKERN:"\?__device_stub__nskernel@ns@@YAXXZ\.id"]] = dso_local global i8 0
45
+ // CUDA: @[[HTKERN:"\?\?\$__device_stub__kernelfunc@H@@YAXXZ\.id"]] = linkonce_odr dso_local global i8 0, comdat
46
+
38
47
namespace ns {
39
48
__global__ void nskernel () {}
40
49
} // namespace ns
@@ -60,18 +69,27 @@ extern "C" void launch(void *kern);
60
69
61
70
// Non-template kernel stub functions
62
71
63
- // CHECK: define{{.*}}@[[CSTUB]]
64
- // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HCKERN]]
72
+ // HIP: define{{.*}}@[[CSTUB]]
73
+ // CUDA: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
74
+ // HIP: call{{.*}}@hipLaunchByPtr{{.*}}@[[HCKERN]]
75
+ // CUDA: call{{.*}}@cudaLaunch{{.*}}@[[CSTUB]]
76
+ // CUDA: store volatile i8 1, ptr @[[HCKERN]], align 1
77
+ // CHECK: ret void
65
78
66
- // CHECK: define{{.*}}@[[NSSTUB]]
67
- // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HNSKERN]]
79
+ // HIP: define{{.*}}@[[NSSTUB]]
80
+ // CUDA: define{{.*}}@[[NSSTUB:"\?__device_stub__nskernel@ns@@YAXXZ"]]
81
+ // HIP: call{{.*}}@hipLaunchByPtr{{.*}}@[[HNSKERN]]
82
+ // CUDA: call{{.*}}@cudaLaunch{{.*}}@[[NSSTUB]]
83
+ // CUDA: store volatile i8 1, ptr @[[HNSKERN]], align 1
84
+ // CHECK: ret void
68
85
69
86
// Check kernel stub is called for triple chevron.
70
87
71
88
// CHECK-LABEL: define{{.*}}@fun1()
72
89
// CHECK: call void @[[CSTUB]]()
73
90
// CHECK: call void @[[NSSTUB]]()
74
- // CHECK: call void @[[TSTUB]]()
91
+ // HIP: call void @[[TSTUB]]()
92
+ // CUDA: call void @[[TSTUB:"\?\?\$__device_stub__kernelfunc@H@@YAXXZ.*"]]()
75
93
// GNU: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
76
94
// GNU: call void @[[TDSTUB:_Z35__device_stub__template_kernel_declIiEvT_]](
77
95
// MSVC: call void @[[DSTUB:"\?__device_stub__kernel_decl@@YAXXZ"]]()
@@ -88,7 +106,10 @@ extern "C" void fun1(void) {
88
106
// Template kernel stub functions
89
107
90
108
// CHECK: define{{.*}}@[[TSTUB]]
91
- // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[HTKERN]]
109
+ // HIP: call{{.*}}@hipLaunchByPtr{{.*}}@[[HTKERN]]
110
+ // CUDA: call{{.*}}@cudaLaunch{{.*}}@[[TSTUB]]
111
+ // CUDA: store volatile i8 1, ptr @[[HTKERN]], align 1
112
+ // CHECK: ret void
92
113
93
114
// Check declaration of stub function for external kernel.
94
115
@@ -98,11 +119,11 @@ extern "C" void fun1(void) {
98
119
// Check kernel handle is used for passing the kernel as a function pointer.
99
120
100
121
// 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]]
122
+ // HIP : call void @launch({{.*}}[[HCKERN]]
123
+ // HIP : call void @launch({{.*}}[[HNSKERN]]
124
+ // HIP : call void @launch({{.*}}[[HTKERN]]
125
+ // HIP : call void @launch({{.*}}[[HDKERN]]
126
+ // HIP : call void @launch({{.*}}[[HTDKERN]]
106
127
extern " C" void fun2 () {
107
128
launch ((void *)ckernel);
108
129
launch ((void *)ns::nskernel);
@@ -114,10 +135,10 @@ extern "C" void fun2() {
114
135
// Check kernel handle is used for assigning a kernel to a function pointer.
115
136
116
137
// 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
138
+ // HIP : store ptr @[[HCKERN]], ptr @kernel_ptr, align 8
139
+ // HIP : store ptr @[[HCKERN]], ptr @kernel_ptr, align 8
140
+ // HIP : store ptr @[[HCKERN]], ptr @void_ptr, align 8
141
+ // HIP : store ptr @[[HCKERN]], ptr @void_ptr, align 8
121
142
extern " C" void fun3 () {
122
143
kernel_ptr = ckernel;
123
144
kernel_ptr = &ckernel;
@@ -129,11 +150,11 @@ extern "C" void fun3() {
129
150
// used with triple chevron.
130
151
131
152
// 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]]()
153
+ // HIP : store ptr @[[HCKERN]], ptr @kernel_ptr
154
+ // HIP : call noundef i32 @{{.*hipConfigureCall}}
155
+ // HIP : %[[HANDLE:.*]] = load ptr, ptr @kernel_ptr, align 8
156
+ // HIP : %[[STUB:.*]] = load ptr, ptr %[[HANDLE]], align 8
157
+ // HIP : call void %[[STUB]]()
137
158
extern " C" void fun4 () {
138
159
kernel_ptr = ckernel;
139
160
kernel_ptr<<<1 ,1 >>> ();
@@ -142,20 +163,20 @@ extern "C" void fun4() {
142
163
// Check kernel handle is passed to a function.
143
164
144
165
// 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]])
166
+ // HIP : store ptr @[[HCKERN]], ptr @kernel_ptr
167
+ // HIP : %[[HANDLE:.*]] = load ptr, ptr @kernel_ptr, align 8
168
+ // HIP : call void @launch(ptr noundef %[[HANDLE]])
148
169
extern " C" void fun5 () {
149
170
kernel_ptr = ckernel;
150
171
launch ((void *)kernel_ptr);
151
172
}
152
173
153
174
// Check kernel handle is registered.
154
175
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]]
176
+ // HIP -LABEL: define{{.*}}@__hip_register_globals
177
+ // HIP : call{{.*}}@__hipRegisterFunction{{.*}}@[[HCKERN]]{{.*}}@[[CKERN]]
178
+ // HIP : call{{.*}}@__hipRegisterFunction{{.*}}@[[HNSKERN]]{{.*}}@[[NSKERN]]
179
+ // HIP : call{{.*}}@__hipRegisterFunction{{.*}}@[[HTKERN]]{{.*}}@[[TKERN]]
159
180
// NEG-NOT: call{{.*}}@__hipRegisterFunction{{.*}}__device_stub
160
181
// NEG-NOT: call{{.*}}@__hipRegisterFunction{{.*}}kernel_decl
161
182
// NEG-NOT: call{{.*}}@__hipRegisterFunction{{.*}}template_kernel_decl
0 commit comments