public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: Patrick Marlier <patrick.marlier@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [doc, rfa] improve x86 transactional memory intrinsics section
Date: Sun, 22 Feb 2015 08:54:00 -0000	[thread overview]
Message-ID: <54E947AA.40606@codesourcery.com> (raw)
In-Reply-To: <54E63B38.80402@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

On 02/19/2015 12:36 PM, Sandra Loosemore wrote:
> On 02/19/2015 09:38 AM, Patrick Marlier wrote:
>> Thanks Sandra. Just a minor comment.
>>
>> -Valid abort status bits (when the value is not
>> @code{_XBEGIN_STARTED}) are:
>> +If the transaction aborts, the return value is one of:
>>
>> Here it is really bits. So maybe something like that:
>> If the transaction aborts, the return value is a combination of the
>> following bits:
>
> So "combination" == "bit mask"?  Can there be more than one abort
> condition at a time?  (If there's more than one _xabort call, it seems
> there can be only one status....)
>
> I'll draft a patch to fix this, and expand the example to show how a
> user should test for these conditions, once I understand how it's
> supposed to work.

I found some additional documentation online that gave me a few clues. 
Is the attached patch OK to commit?

-Sandra


[-- Attachment #2: doc.log --]
[-- Type: text/x-log, Size: 247 bytes --]

2015-02-21  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/
	* doc/extend.texi (x86 transactional memory intrinsics):
	Reorganize discussion of _xbegin.  Clarify that the return
	value is a bit mask.  Expand example and move to end of section.

[-- Attachment #3: doc.patch --]
[-- Type: text/x-patch, Size: 2335 bytes --]

Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi	(revision 220892)
+++ gcc/doc/extend.texi	(working copy)
@@ -17274,24 +17274,11 @@ and suitable fallback code always needs 
 Start a RTM (Restricted Transactional Memory) transaction. 
 Returns @code{_XBEGIN_STARTED} when the transaction
 started successfully (note this is not 0, so the constant has to be 
-explicitly tested).  If the transaction aborts, all side-effects
-are undone and an abort code is returned. There is no guarantee
-any transaction ever succeeds, so there always needs to be a valid
-fallback path.
-@end deftypefn
-
-@smallexample
-#include <immintrin.h>
-
-if ((status = _xbegin ()) == _XBEGIN_STARTED) @{
-    ... transaction code...
-    _xend ();
-@} else @{
-    ... non transactional fallback path...
-@}
-@end smallexample
+explicitly tested).  
 
-If the transaction aborts, the return value is one of:
+If the transaction aborts, all side-effects 
+are undone and an abort code encoded as a bit mask is returned.
+The following macros are defined:
 
 @table @code
 @item _XABORT_EXPLICIT
@@ -17309,6 +17296,11 @@ Transaction abort due to a debug trap.
 Transaction abort in an inner nested transaction.
 @end table
 
+There is no guarantee
+any transaction ever succeeds, so there always needs to be a valid
+fallback path.
+@end deftypefn
+
 @deftypefn {RTM Function} {void} _xend ()
 Commit the current transaction. When no transaction is active this faults.
 All memory side-effects of the transaction become visible
@@ -17325,6 +17317,33 @@ The @var{status} is an 8-bit constant; i
 value from @code{_xbegin}.
 @end deftypefn
 
+Here is an example showing handling for @code{_XABORT_RETRY}
+and a fallback path for other failures:
+
+@smallexample
+#include <immintrin.h>
+
+int n_tries, max_tries;
+unsigned status = _XBEGIN_STARTED;
+...
+
+for (n_tries = 0; n_tries < max_tries; n_tries++) 
+  @{
+    status = _xbegin ();
+    if (status == _XBEGIN_STARTED || !(status | _XABORT_RETRY))
+      break;
+  @}
+if (status == _XBEGIN_STARTED) 
+  @{
+    ... transaction code...
+    _xend ();
+  @} 
+else 
+  @{
+    ... non transactional fallback path...
+  @}
+@end smallexample
+
 @node Target Format Checks
 @section Format Checks Specific to Particular Target Machines
 

  reply	other threads:[~2015-02-22  3:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19 16:20 [doc, committed] copy-edit " Sandra Loosemore
2015-02-19 16:45 ` Patrick Marlier
2015-02-19 20:04   ` Sandra Loosemore
2015-02-22  8:54     ` Sandra Loosemore [this message]
2015-02-23 11:59       ` [doc, rfa] improve " Patrick Marlier
2015-02-24  3:38         ` [doc, rfa] (v2) " Sandra Loosemore
2015-02-24 12:21           ` Patrick Marlier
2015-02-25  5:18             ` Sandra Loosemore
2015-02-27  0:26               ` Gerald Pfeifer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54E947AA.40606@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=patrick.marlier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).