[libc-commits] [libc] [libc] Rework the RPC interface to accept runtime wave sizes (PR #80914)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed Feb 7 10:52:58 PST 2024


================
@@ -264,33 +277,35 @@ template <bool Invert, typename Packet> struct Process {
 /// Invokes a function accross every active buffer across the total lane size.
 template <uint32_t lane_size>
 static LIBC_INLINE void invoke_rpc(cpp::function<void(Buffer *)> fn,
-                                   Packet<lane_size> &packet) {
+                                   Buffer *slot, uint64_t mask) {
   if constexpr (is_process_gpu()) {
-    fn(&packet.payload.slot[gpu::get_lane_id()]);
+    fn(&slot[gpu::get_lane_id()]);
   } else {
-    for (uint32_t i = 0; i < lane_size; i += gpu::get_lane_size())
-      if (packet.header.mask & 1ul << i)
-        fn(&packet.payload.slot[i]);
+    auto sz = lane_size == VARIABLE_LANE_SIZE ? gpu::get_lane_size() : lane_size;
+    for (uint32_t i = 0; i < sz; i += gpu::get_lane_size())
+      if (mask & 1ul << i)
----------------
jhuber6 wrote:

`<<` has precedence `7` while `&` has 11` so it should be `mask & (1 << i)`. However, the fact that I had to look up the operator precedence is a good indicator that this should be in parenthesis anyway.

https://github.com/llvm/llvm-project/pull/80914


More information about the libc-commits mailing list