[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 13:57:19 PDT 2023


jhuber6 updated this revision to Diff 545270.
jhuber6 added a comment.

Switch to builtin version


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156566/new/

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,6 +12,7 @@
 #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"
 
 namespace __llvm_libc {
@@ -27,8 +28,10 @@
 #elif defined(LIBC_TARGET_ARCH_IS_AMDGPU)
   __builtin_amdgcn_s_sleep(2);
 #else
-  // Simply do nothing if sleeping isn't supported on this platform.
+  if constexpr (LIBC_HAS_BUILTIN(__builtin_ia32_pause))
+    __builtin_ia32_pause();
 #endif
+  // Simply do nothing if sleeping isn't supported on this platform.
 }
 
 /// Get the first active thread inside the lane.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156566.545270.patch
Type: text/x-patch
Size: 850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230728/7a8db89b/attachment.bin>


More information about the libc-commits mailing list