]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix HLE example in manual
authorAndi Kleen <ak@linux.intel.com>
Fri, 21 Jun 2013 13:51:48 +0000 (13:51 +0000)
committerAndi Kleen <ak@gcc.gnu.org>
Fri, 21 Jun 2013 13:51:48 +0000 (13:51 +0000)
The HLE example in the manual only commits when using bool
for the flag, because __atomic_clear only writes bool, and
HLE requires the acquire and release to match.

So when the example is copied with e.g. an int variable it
does not commit and causes slower than expected performance.

Some people are running into problems because of this.

Switch it over to use __atomic_store.

Also fix a minor typo nearby.

gcc/:
2013-06-21  Andi Kleen  <ak@linux.intel.com>

* doc/extend.texi: Dont use __atomic_clear in HLE
example.  Fix typo.

From-SVN: r200304

gcc/ChangeLog
gcc/doc/extend.texi

index 16590940a0dde969547f8f054f655510e3d944aa..889cbcc63d88b05e5f77e1dd9393a0ae2e6f0303 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-21  Andi Kleen  <ak@linux.intel.com>
+
+       * doc/extend.texi: Dont use __atomic_clear in HLE
+       example.  Fix typo.
+
 2013-06-21  Andi Kleen  <ak@linux.intel.com>
 
        * doc/extend.texi: Document that __atomic_clear and
index 213cf00a7385eb650282cd9488d6685820ce5804..77295f15440127b7990eb80ef415082088c8d85c 100644 (file)
@@ -7525,18 +7525,20 @@ End lock elision on a lock variable.
 Memory model must be @code{__ATOMIC_RELEASE} or stronger.
 @end table
 
-When a lock acquire fails it's required for good performance to abort
+When a lock acquire fails it is required for good performance to abort
 the transaction quickly. This can be done with a @code{_mm_pause}
 
 @smallexample
 #include <immintrin.h> // For _mm_pause
 
+int lockvar;
+
 /* Acquire lock with lock elision */
 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
     _mm_pause(); /* Abort failed transaction */
 ...
 /* Free lock with lock elision */
-__atomic_clear(&lockvar, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
+__atomic_store(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
 @end smallexample
 
 @node Object Size Checking