File: On-non-x86-use-alternative-to-x86-intrinsic-__mm_pause.patch

package info (click to toggle)
rocr-runtime 6.4.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,928 kB
  • sloc: cpp: 126,824; ansic: 41,837; lisp: 1,225; asm: 905; sh: 452; python: 117; makefile: 59
file content (28 lines) | stat: -rw-r--r-- 997 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From: Christian Kastner <ckk@debian.org>
Date: Fri, 18 Oct 2024 20:24:16 +0200
Subject: On non-x86, use alternative to x86 intrinsic __mm_pause

Cargo-culted from various other solutions that I could find.

Not forwarded yet, as this needs double-checking. For example, on my
first pass, I overlooked that this might also be built by MSVC.
---
 runtime/hsa-runtime/core/util/locks.h | 6 ++++++
 1 file changed, 6 insertions(+)

--- a/runtime/hsa-runtime/core/util/locks.h
+++ b/runtime/hsa-runtime/core/util/locks.h
@@ -72,7 +72,13 @@
     while (!lock_.compare_exchange_strong(old, 1)) {
       cnt--;
       if (cnt > maxSpinIterPause) {
+#if defined(__x86_64__) || defined(_M_X64)
         _mm_pause();
+#elif defined(__aarch64__) || defined(_M_ARM64)
+        asm volatile("isb");
+#elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
+        asm volatile("or 27, 27, 27");
+#endif
       } else if (cnt-- > maxSpinIterYield) {
         os::YieldThread();
       } else {