- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
this is more out of curiosity than anything else. When looking at the generated assembly code for a tight loop that polls an atomic state member until it has a certain value, I see that the read of the atomic variable is translated by the compiler (gcc 5.2.0 x64) into 3 identical loads (as shown by the assmbly view in vTune). So:
while (m_state == TS_BUSY_WAITING) { ASM_PAUSE; }
turns into
Block 7:
pause
movl 0x3c(%rdi), %eax
movl 0x3c(%rdi), %eax
movl 0x3c(%rdi), %eax
cmp $0x3, %eax
jz 0x1b5af88 <Block 7>
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Stephan,
Thank you for the report. After investigation it looks like a GCC issue. I have created Bug 84151 in GCC Bugzilla.
Regards,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And here I am thinking this would be some kind of cache-line vodoo to improve performance :-) I'm glad I asked.
Thanks for taking care of this!
Stephan

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page