1 // RUN: echo "GPU binary would be here" > %t
2
3 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
4 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
5 // RUN: | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=CHECK
6
7 #include "Inputs/cuda.h"
8
ckernel()9 extern "C" __global__ void ckernel() {}
10
11 namespace ns {
nskernel()12 __global__ void nskernel() {}
13 } // namespace ns
14
15 template<class T>
kernelfunc()16 __global__ void kernelfunc() {}
17
18 __global__ void kernel_decl();
19
20 // Device side kernel names
21
22 // CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
23 // CHECK: @[[NSKERN:[0-9]*]] = {{.*}} c"_ZN2ns8nskernelEv\00"
24 // CHECK: @[[TKERN:[0-9]*]] = {{.*}} c"_Z10kernelfuncIiEvv\00"
25
26 // Non-template kernel stub functions
27
28 // CHECK: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
29 // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
30 // CHECK: define{{.*}}@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]]
31 // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[NSSTUB]]
32
33 // CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
34 // CHECK: call void @[[CSTUB]]()
35 // CHECK: call void @[[NSSTUB]]()
36 // CHECK: call void @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]]()
37 // CHECK: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
hostfunc(void)38 void hostfunc(void) {
39 ckernel<<<1, 1>>>();
40 ns::nskernel<<<1, 1>>>();
41 kernelfunc<int><<<1, 1>>>();
42 kernel_decl<<<1, 1>>>();
43 }
44
45 // Template kernel stub functions
46
47 // CHECK: define{{.*}}@[[TSTUB]]
48 // CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[TSTUB]]
49
50 // CHECK: declare{{.*}}@[[DSTUB]]
51
52 // CHECK-LABEL: define{{.*}}@__hip_register_globals
53 // CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[CSTUB]]{{.*}}@[[CKERN]]
54 // CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[NSSTUB]]{{.*}}@[[NSKERN]]
55 // CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[TSTUB]]{{.*}}@[[TKERN]]
56