summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorJon Chesterfield <jonathanchesterfield@gmail.com>2023-05-04 20:53:07 +0100
committerJon Chesterfield <jonathanchesterfield@gmail.com>2023-05-04 20:53:55 +0100
commit09ceb4729f1ca8781718d41b7876b68820baadba (patch)
tree19acce7f46ea16a4dc093aac2961f1123c248d04 /libc
parentbfb7c99f3aeab09236adf1f684f7144f384c6dd7 (diff)
downloadllvm-09ceb4729f1ca8781718d41b7876b68820baadba.tar.gz
[libc][rpc] Land helpers from D148943
Diffstat (limited to 'libc')
-rw-r--r--libc/src/__support/RPC/rpc_util.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/libc/src/__support/RPC/rpc_util.h b/libc/src/__support/RPC/rpc_util.h
index 53a993292fb3..22c5c1d216c8 100644
--- a/libc/src/__support/RPC/rpc_util.h
+++ b/libc/src/__support/RPC/rpc_util.h
@@ -26,6 +26,16 @@ LIBC_INLINE void sleep_briefly() {
#endif
}
+/// Get the first active thread inside the lane.
+LIBC_INLINE uint64_t get_first_lane_id(uint64_t lane_mask) {
+ return __builtin_ffsl(lane_mask) - 1;
+}
+
+/// Conditional that is only true for a single thread in a lane.
+LIBC_INLINE bool is_first_lane(uint64_t lane_mask) {
+ return gpu::get_lane_id() == get_first_lane_id(lane_mask);
+}
+
} // namespace rpc
} // namespace __llvm_libc