diff --git a/libc/src/__support/RPC/rpc.h b/libc/src/__support/RPC/rpc.h --- a/libc/src/__support/RPC/rpc.h +++ b/libc/src/__support/RPC/rpc.h @@ -74,7 +74,7 @@ /// - The client will always start with a 'send' operation. /// - The server will always start with a 'recv' operation. /// - Every 'send' or 'recv' call is mirrored by the other process. -template struct Process { +template struct Process { LIBC_INLINE Process() = default; LIBC_INLINE Process(const Process &) = delete; LIBC_INLINE Process &operator=(const Process &) = delete; @@ -85,7 +85,7 @@ uint64_t port_count; cpp::Atomic *inbox; cpp::Atomic *outbox; - Packet *packet; + Packet *packet; cpp::Atomic lock[DEFAULT_PORT_COUNT] = {0}; @@ -96,8 +96,8 @@ advance(buffer, inbox_offset(port_count))); this->outbox = reinterpret_cast *>( advance(buffer, outbox_offset(port_count))); - this->packet = reinterpret_cast *>( - advance(buffer, buffer_offset(port_count))); + this->packet = + reinterpret_cast(advance(buffer, buffer_offset(port_count))); } /// Returns the beginning of the unified buffer. Intended for initializing the @@ -222,8 +222,9 @@ } /// Invokes a function accross every active buffer across the total lane size. - LIBC_INLINE void invoke_rpc(cpp::function fn, - Packet &packet) { + template + LIBC_INLINE static void invoke_rpc(cpp::function fn, + P &packet) { if constexpr (is_process_gpu()) { fn(&packet.payload.slot[gpu::get_lane_id()]); } else { @@ -234,8 +235,9 @@ } /// Alternate version that also provides the index of the current lane. - LIBC_INLINE void invoke_rpc(cpp::function fn, - Packet &packet) { + template + LIBC_INLINE static void invoke_rpc(cpp::function fn, + P &packet) { if constexpr (is_process_gpu()) { fn(&packet.payload.slot[gpu::get_lane_id()], gpu::get_lane_id()); } else { @@ -252,7 +254,7 @@ /// Number of bytes to allocate for the buffer containing the packets. LIBC_INLINE static constexpr uint64_t buffer_bytes(uint64_t port_count) { - return port_count * sizeof(Packet); + return port_count * sizeof(Packet); } /// Offset of the inbox in memory. This is the same as the outbox if inverted. @@ -267,7 +269,7 @@ /// Offset of the buffer containing the packets after the inbox and outbox. LIBC_INLINE static constexpr uint64_t buffer_offset(uint64_t port_count) { - return align_up(2 * mailbox_bytes(port_count), alignof(Packet)); + return align_up(2 * mailbox_bytes(port_count), alignof(Packet)); } }; @@ -339,7 +341,7 @@ } private: - Process process; + Process> process; }; /// The RPC server used to respond to the client. @@ -362,11 +364,11 @@ } LIBC_INLINE static uint64_t allocation_size(uint64_t port_count) { - return Process::allocation_size(port_count); + return Process>::allocation_size(port_count); } private: - Process process; + Process> process; }; /// Applies \p fill to the shared buffer and initiates a send operation.