* [doc, committed] copy-edit x86 transactional memory intrinsics section
@ 2015-02-19 16:20 Sandra Loosemore
2015-02-19 16:45 ` Patrick Marlier
0 siblings, 1 reply; 9+ messages in thread
From: Sandra Loosemore @ 2015-02-19 16:20 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 546 bytes --]
A while ago when I was doing some other work on extend.texi, I noticed
that the section on x86 transactional memory intrinsics was in need of
cleanup. I've checked in this patch to do some content-free
copy-editing -- fixing typos and markup, rephrasing some awkward
sentences, etc.
To tell the truth I don't think the documentation in this section is
useful to anyone who doesn't already know how to use the feature, so it
could still use more content-full editing as well. But, at least this
is an incremental improvement.
-Sandra
[-- Attachment #2: doc.log --]
[-- Type: text/x-log, Size: 133 bytes --]
2015-02-19 Sandra Loosemore <sandra@codesourcery.com>
gcc/
* doc/extend.texi (x86 transactional memory intrinsics):
Copy-edit.
[-- Attachment #3: doc.patch --]
[-- Type: text/x-patch, Size: 3817 bytes --]
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi (revision 220818)
+++ gcc/doc/extend.texi (working copy)
@@ -17257,10 +17257,11 @@ int __builtin_ia32_xtest ()
@node x86 transactional memory intrinsics
@subsection x86 Transactional Memory Intrinsics
-Hardware transactional memory intrinsics for x86. These allow to use
+These hardware transactional memory intrinsics for x86 allow you to use
memory transactions with RTM (Restricted Transactional Memory).
-For using HLE (Hardware Lock Elision) see @ref{x86 specific memory model extensions for transactional memory} instead.
This support is enabled with the @option{-mrtm} option.
+For using HLE (Hardware Lock Elision) see
+@ref{x86 specific memory model extensions for transactional memory} instead.
A memory transaction commits all changes to memory in an atomic way,
as visible to other threads. If the transaction fails it is rolled back
@@ -17271,12 +17272,12 @@ and suitable fallback code always needs
@deftypefn {RTM Function} {unsigned} _xbegin ()
Start a RTM (Restricted Transactional Memory) transaction.
-Returns _XBEGIN_STARTED when the transaction
+Returns @code{_XBEGIN_STARTED} when the transaction
started successfully (note this is not 0, so the constant has to be
-explicitely tested). When the transaction aborts all side effects
+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
-tested fallback path.
+fallback path.
@end deftypefn
@smallexample
@@ -17290,38 +17291,38 @@ if ((status = _xbegin ()) == _XBEGIN_STA
@}
@end smallexample
-Valid abort status bits (when the value is not @code{_XBEGIN_STARTED}) are:
+If the transaction aborts, the return value is one of:
@table @code
@item _XABORT_EXPLICIT
-Transaction explicitely aborted with @code{_xabort}. The parameter passed
-to @code{_xabort} is available with @code{_XABORT_CODE(status)}
+Transaction was explicitly aborted with @code{_xabort}. The parameter passed
+to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
@item _XABORT_RETRY
Transaction retry is possible.
@item _XABORT_CONFLICT
-Transaction abort due to a memory conflict with another thread
+Transaction abort due to a memory conflict with another thread.
@item _XABORT_CAPACITY
-Transaction abort due to the transaction using too much memory
+Transaction abort due to the transaction using too much memory.
@item _XABORT_DEBUG
-Transaction abort due to a debug trap
+Transaction abort due to a debug trap.
@item _XABORT_NESTED
-Transaction abort in a inner nested transaction
+Transaction abort in an inner nested transaction.
@end table
@deftypefn {RTM Function} {void} _xend ()
-Commit the current transaction. When no transaction is active this will
-fault. All memory side effects of the transactions will become visible
-to other threads in an atomic matter.
+Commit the current transaction. When no transaction is active this faults.
+All memory side-effects of the transaction become visible
+to other threads in an atomic manner.
@end deftypefn
@deftypefn {RTM Function} {int} _xtest ()
-Return a value not zero when a transaction is currently active, otherwise 0.
+Return a nonzero value if a transaction is currently active, otherwise 0.
@end deftypefn
@deftypefn {RTM Function} {void} _xabort (status)
Abort the current transaction. When no transaction is active this is a no-op.
-status must be a 8bit constant, that is included in the status code returned
-by @code{_xbegin}
+The @var{status} is an 8-bit constant; its value is encoded in the return
+value from @code{_xbegin}.
@end deftypefn
@node Target Format Checks
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [doc, committed] copy-edit x86 transactional memory intrinsics section
2015-02-19 16:20 [doc, committed] copy-edit x86 transactional memory intrinsics section Sandra Loosemore
@ 2015-02-19 16:45 ` Patrick Marlier
2015-02-19 20:04 ` Sandra Loosemore
0 siblings, 1 reply; 9+ messages in thread
From: Patrick Marlier @ 2015-02-19 16:45 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: GCC Patches
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:
On Thu, Feb 19, 2015 at 5:16 PM, Sandra Loosemore
<sandra@codesourcery.com> wrote:
> A while ago when I was doing some other work on extend.texi, I noticed that
> the section on x86 transactional memory intrinsics was in need of cleanup.
> I've checked in this patch to do some content-free copy-editing -- fixing
> typos and markup, rephrasing some awkward sentences, etc.
>
> To tell the truth I don't think the documentation in this section is useful
> to anyone who doesn't already know how to use the feature, so it could
> still use more content-full editing as well. But, at least this is an
> incremental improvement.
>
> -Sandra
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [doc, committed] copy-edit x86 transactional memory intrinsics section
2015-02-19 16:45 ` Patrick Marlier
@ 2015-02-19 20:04 ` Sandra Loosemore
2015-02-22 8:54 ` [doc, rfa] improve " Sandra Loosemore
0 siblings, 1 reply; 9+ messages in thread
From: Sandra Loosemore @ 2015-02-19 20:04 UTC (permalink / raw)
To: Patrick Marlier; +Cc: GCC Patches
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.
-Sandra
^ permalink raw reply [flat|nested] 9+ messages in thread
* [doc, rfa] improve x86 transactional memory intrinsics section
2015-02-19 20:04 ` Sandra Loosemore
@ 2015-02-22 8:54 ` Sandra Loosemore
2015-02-23 11:59 ` Patrick Marlier
0 siblings, 1 reply; 9+ messages in thread
From: Sandra Loosemore @ 2015-02-22 8:54 UTC (permalink / raw)
To: Patrick Marlier; +Cc: GCC Patches
[-- 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [doc, rfa] improve x86 transactional memory intrinsics section
2015-02-22 8:54 ` [doc, rfa] improve " Sandra Loosemore
@ 2015-02-23 11:59 ` Patrick Marlier
2015-02-24 3:38 ` [doc, rfa] (v2) " Sandra Loosemore
0 siblings, 1 reply; 9+ messages in thread
From: Patrick Marlier @ 2015-02-23 11:59 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: GCC Patches
On 02/22/2015 04:06 AM, Sandra Loosemore wrote:
> 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
>
+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;
I would suggest to set it to something different. Indeed if max_tries ==
0, then it will end up to do the transactional code with no transaction
started.
+...
+
+for (n_tries = 0; n_tries < max_tries; n_tries++)
+ @{
+ status = _xbegin ();
+ if (status == _XBEGIN_STARTED || !(status | _XABORT_RETRY))
Should not be || !(status & _XABORT_RETRY) ?
+ break;
+ @}
+if (status == _XBEGIN_STARTED)
+ @{
+ ... transaction code...
+ _xend ();
+ @}
+else
+ @{
+ ... non transactional fallback path...
+ @}
+@end smallexample
Thanks a lot. It gives a good idea on how to use it. I just would like
to mention that the non transactional and transactional code must
synchronize together (in most cases) to ensure consistency.
--
Patrick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [doc, rfa] (v2) improve x86 transactional memory intrinsics section
2015-02-23 11:59 ` Patrick Marlier
@ 2015-02-24 3:38 ` Sandra Loosemore
2015-02-24 12:21 ` Patrick Marlier
0 siblings, 1 reply; 9+ messages in thread
From: Sandra Loosemore @ 2015-02-24 3:38 UTC (permalink / raw)
To: Patrick Marlier; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]
On 02/23/2015 03:36 AM, Patrick Marlier wrote:
> On 02/22/2015 04:06 AM, Sandra Loosemore wrote:
>
> +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;
>
> I would suggest to set it to something different. Indeed if max_tries ==
> 0, then it will end up to do the transactional code with no transaction
> started.
Good catch....
> +...
> +
> +for (n_tries = 0; n_tries < max_tries; n_tries++)
> + @{
> + status = _xbegin ();
> + if (status == _XBEGIN_STARTED || !(status | _XABORT_RETRY))
>
> Should not be || !(status & _XABORT_RETRY) ?
Yup, that was a think-o.
> + break;
> + @}
> +if (status == _XBEGIN_STARTED)
> + @{
> + ... transaction code...
> + _xend ();
> + @}
> +else
> + @{
> + ... non transactional fallback path...
> + @}
> +@end smallexample
>
> Thanks a lot. It gives a good idea on how to use it. I just would like
> to mention that the non transactional and transactional code must
> synchronize together (in most cases) to ensure consistency.
OK, I added a sentence about that.
Revised patch attached. OK to commit this version?
-Sandra
[-- Attachment #2: doc.log --]
[-- Type: text/x-log, Size: 247 bytes --]
2015-02-23 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: 2471 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,37 @@ 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_EXPLICIT;
+...
+
+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
+
+@noindent
+Note that, in most cases, the transactional and non-transactional code
+must synchronize together to ensure consistency.
+
@node Target Format Checks
@section Format Checks Specific to Particular Target Machines
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [doc, rfa] (v2) improve x86 transactional memory intrinsics section
2015-02-24 3:38 ` [doc, rfa] (v2) " Sandra Loosemore
@ 2015-02-24 12:21 ` Patrick Marlier
2015-02-25 5:18 ` Sandra Loosemore
0 siblings, 1 reply; 9+ messages in thread
From: Patrick Marlier @ 2015-02-24 12:21 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: GCC Patches
On 02/24/2015 01:51 AM, Sandra Loosemore wrote:
> On 02/23/2015 03:36 AM, Patrick Marlier wrote:
>> On 02/22/2015 04:06 AM, Sandra Loosemore wrote:
>>
>> +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;
>>
>> I would suggest to set it to something different. Indeed if max_tries ==
>> 0, then it will end up to do the transactional code with no transaction
>> started.
>
> Good catch....
>
>> +...
>> +
>> +for (n_tries = 0; n_tries < max_tries; n_tries++)
>> + @{
>> + status = _xbegin ();
>> + if (status == _XBEGIN_STARTED || !(status | _XABORT_RETRY))
>>
>> Should not be || !(status & _XABORT_RETRY) ?
>
> Yup, that was a think-o.
>
>> + break;
>> + @}
>> +if (status == _XBEGIN_STARTED)
>> + @{
>> + ... transaction code...
>> + _xend ();
>> + @}
>> +else
>> + @{
>> + ... non transactional fallback path...
>> + @}
>> +@end smallexample
>>
>> Thanks a lot. It gives a good idea on how to use it. I just would like
>> to mention that the non transactional and transactional code must
>> synchronize together (in most cases) to ensure consistency.
>
> OK, I added a sentence about that.
>
> Revised patch attached. OK to commit this version?
>
> -Sandra
>
_XBEGIN_EXPLICIT does not exist right? maybe 0 is better to avoid
confusion? or ~_XBEGIN_STARTED?
But it sounds good to me. Thanks.
--
Patrick
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [doc, rfa] (v2) improve x86 transactional memory intrinsics section
2015-02-24 12:21 ` Patrick Marlier
@ 2015-02-25 5:18 ` Sandra Loosemore
2015-02-27 0:26 ` Gerald Pfeifer
0 siblings, 1 reply; 9+ messages in thread
From: Sandra Loosemore @ 2015-02-25 5:18 UTC (permalink / raw)
To: Patrick Marlier; +Cc: GCC Patches, Gerald Pfeifer, Joseph S. Myers
On 02/24/2015 03:01 AM, Patrick Marlier wrote:
> On 02/24/2015 01:51 AM, Sandra Loosemore wrote:
>> [snip]
>> Revised patch attached. OK to commit this version?
>>
>> -Sandra
>
> _XBEGIN_EXPLICIT does not exist right? maybe 0 is better to avoid
> confusion? or ~_XBEGIN_STARTED?
Argh, I meant to change _XBEGIN_STARTED to _XABORT_EXPLICIT here. :-P
I'll fix that before checking it in.
> But it sounds good to me. Thanks.
Thanks for the review; I think we've got the technical corrections
nailed down now. Doc maintainers, is this OK?
-Sandra
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [doc, rfa] (v2) improve x86 transactional memory intrinsics section
2015-02-25 5:18 ` Sandra Loosemore
@ 2015-02-27 0:26 ` Gerald Pfeifer
0 siblings, 0 replies; 9+ messages in thread
From: Gerald Pfeifer @ 2015-02-27 0:26 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: Patrick Marlier, GCC Patches, Joseph S. Myers
On Tue, 24 Feb 2015, Sandra Loosemore wrote:
> Thanks for the review; I think we've got the technical corrections
> nailed down now. Doc maintainers, is this OK?
You can approve yourself now. Watch out for my next mail. ;-)
Gerald
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-02-26 23:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-19 16:20 [doc, committed] copy-edit x86 transactional memory intrinsics section Sandra Loosemore
2015-02-19 16:45 ` Patrick Marlier
2015-02-19 20:04 ` Sandra Loosemore
2015-02-22 8:54 ` [doc, rfa] improve " Sandra Loosemore
2015-02-23 11:59 ` 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
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).