Skip to content

Commit 09ceb47

Browse files
[libc][rpc] Land helpers from D148943
1 parent bfb7c99 commit 09ceb47

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libc/src/__support/RPC/rpc_util.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ LIBC_INLINE void sleep_briefly() {
2626
#endif
2727
}
2828

29+
/// Get the first active thread inside the lane.
30+
LIBC_INLINE uint64_t get_first_lane_id(uint64_t lane_mask) {
31+
return __builtin_ffsl(lane_mask) - 1;
32+
}
33+
34+
/// Conditional that is only true for a single thread in a lane.
35+
LIBC_INLINE bool is_first_lane(uint64_t lane_mask) {
36+
return gpu::get_lane_id() == get_first_lane_id(lane_mask);
37+
}
38+
2939
} // namespace rpc
3040
} // namespace __llvm_libc
3141

0 commit comments

Comments
 (0)