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