blob: 6dd10188e9fbcc74360621c3cd5c351282abc0a8 [file] [log] [blame]
Justin Holewinski285dc652011-04-20 19:34:15 +00001// RUN: %clang_cc1 -triple ptx32-unknown-unknown -emit-llvm -o %t %s
2// RUN: %clang_cc1 -triple ptx64-unknown-unknown -emit-llvm -o %t %s
3
4
5int read_tid() {
6
7 int x = __builtin_ptx_read_tid_x();
8 int y = __builtin_ptx_read_tid_y();
9 int z = __builtin_ptx_read_tid_z();
10 int w = __builtin_ptx_read_tid_w();
11
12 return x + y + z + w;
13
14}
15
16int read_ntid() {
17
18 int x = __builtin_ptx_read_ntid_x();
19 int y = __builtin_ptx_read_ntid_y();
20 int z = __builtin_ptx_read_ntid_z();
21 int w = __builtin_ptx_read_ntid_w();
22
23 return x + y + z + w;
24
25}
26
27int read_ctaid() {
28
29 int x = __builtin_ptx_read_ctaid_x();
30 int y = __builtin_ptx_read_ctaid_y();
31 int z = __builtin_ptx_read_ctaid_z();
32 int w = __builtin_ptx_read_ctaid_w();
33
34 return x + y + z + w;
35
36}
37
38int read_nctaid() {
39
40 int x = __builtin_ptx_read_nctaid_x();
41 int y = __builtin_ptx_read_nctaid_y();
42 int z = __builtin_ptx_read_nctaid_z();
43 int w = __builtin_ptx_read_nctaid_w();
44
45 return x + y + z + w;
46
47}
48
49int read_ids() {
50
51 int a = __builtin_ptx_read_laneid();
52 int b = __builtin_ptx_read_warpid();
53 int c = __builtin_ptx_read_nwarpid();
54 int d = __builtin_ptx_read_smid();
55 int e = __builtin_ptx_read_nsmid();
56 int f = __builtin_ptx_read_gridid();
57
58 return a + b + c + d + e + f;
59
60}
61
62int read_lanemasks() {
63
64 int a = __builtin_ptx_read_lanemask_eq();
65 int b = __builtin_ptx_read_lanemask_le();
66 int c = __builtin_ptx_read_lanemask_lt();
67 int d = __builtin_ptx_read_lanemask_ge();
68 int e = __builtin_ptx_read_lanemask_gt();
69
70 return a + b + c + d + e;
71
72}
73
74
75long read_clocks() {
76
77 int a = __builtin_ptx_read_clock();
78 long b = __builtin_ptx_read_clock64();
79
80 return (long)a + b;
81
82}
83
84int read_pms() {
85
86 int a = __builtin_ptx_read_pm0();
87 int b = __builtin_ptx_read_pm1();
88 int c = __builtin_ptx_read_pm2();
89 int d = __builtin_ptx_read_pm3();
90
91 return a + b + c + d;
92
93}
94
95void sync() {
96
97 __builtin_ptx_bar_sync(0);
98
99}