Skip to content

Commit c650067

Browse files
authored
[NVPTX] Add a clang builtin for the warpsize intrinsic (#110316)
Summary: There's an intrinsic for the warp size, we want to expose this to make the interface proposed in #110179 more generic.
1 parent 8ed18ed commit c650067

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/include/clang/Basic/BuiltinsNVPTX.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ TARGET_BUILTIN(__nvvm_is_explicit_cluster, "b", "nc", AND(SM_90, PTX78))
139139
BUILTIN(__nvvm_read_ptx_sreg_laneid, "i", "nc")
140140
BUILTIN(__nvvm_read_ptx_sreg_warpid, "i", "nc")
141141
BUILTIN(__nvvm_read_ptx_sreg_nwarpid, "i", "nc")
142+
BUILTIN(__nvvm_read_ptx_sreg_warpsize, "i", "nc")
142143

143144
BUILTIN(__nvvm_read_ptx_sreg_smid, "i", "nc")
144145
BUILTIN(__nvvm_read_ptx_sreg_nsmid, "i", "nc")

clang/test/CodeGen/builtins-nvptx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,17 @@ __device__ int read_ids() {
114114
// CHECK: call i32 @llvm.nvvm.read.ptx.sreg.smid()
115115
// CHECK: call i32 @llvm.nvvm.read.ptx.sreg.nsmid()
116116
// CHECK: call i32 @llvm.nvvm.read.ptx.sreg.gridid()
117+
// CHECK: call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
117118

118119
int a = __nvvm_read_ptx_sreg_laneid();
119120
int b = __nvvm_read_ptx_sreg_warpid();
120121
int c = __nvvm_read_ptx_sreg_nwarpid();
121122
int d = __nvvm_read_ptx_sreg_smid();
122123
int e = __nvvm_read_ptx_sreg_nsmid();
123124
int f = __nvvm_read_ptx_sreg_gridid();
125+
int g = __nvvm_read_ptx_sreg_warpsize();
124126

125-
return a + b + c + d + e + f;
127+
return a + b + c + d + e + f + g;
126128

127129
}
128130

0 commit comments

Comments
 (0)