[libc-commits] [PATCH] D156566: [libc] Add PAUSE instruction for the RPC spin loop
Joseph Huber via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Jul 28 12:47:42 PDT 2023
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, sivachandra, lntue, michaelrj.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
jhuber6 requested review of this revision.
The other architectures use a brief sleep to defer work during this spin
loop that checks the RPC mailboxes. This patch adds one for x64 to
improve usage when running the server.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156566
Files:
libc/src/__support/RPC/rpc_util.h
Index: libc/src/__support/RPC/rpc_util.h
===================================================================
--- libc/src/__support/RPC/rpc_util.h
+++ libc/src/__support/RPC/rpc_util.h
@@ -12,8 +12,13 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/GPU/utils.h"
#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"
+#ifdef LIBC_TARGET_ARCH_IS_X86
+#include <emmintrin.h>
+#endif
+
namespace __llvm_libc {
namespace rpc {
@@ -26,6 +31,8 @@
LIBC_INLINE_ASM("nanosleep.u32 64;" ::: "memory");
#elif defined(LIBC_TARGET_ARCH_IS_AMDGPU)
__builtin_amdgcn_s_sleep(2);
+#elif defined(LIBC_TARGET_ARCH_IS_X86)
+ _mm_pause();
#else
// Simply do nothing if sleeping isn't supported on this platform.
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156566.545248.patch
Type: text/x-patch
Size: 834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230728/2a53f0de/attachment.bin>
More information about the libc-commits
mailing list