Re: Max-specific C code optimization guidelines ?

Hello,

“…and the result you get is not shared among threads.”

It should, but according to “speculative register promotion” and others “Out-Of-Thin-Air Stores” it seems not a compiler guarantee.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2338.html

http://preshing.com/20120625/memory-ordering-at-compile-time

I do not want to frightened you ; i did a quick test on my macbook with agressive optimization and everything looks correct (assembly test joined) and my question is more to speculate (and i’m not an expert) that to solve issues…

…but i do not use ATOMIC anymore for this kind off synchronization as i consider mutex much more safe and i do not think speed matters for that as i do nothing RT like DSP callback.

(ATOMIC_INCREMENT != 1)

movl	%esi,0x04(%esp,1)
movl	$0x00000001,(%esp,1)

calll	0x0000200f	; symbol stub for: _OSAtomicAdd32Barrier

subl	$0x01,%eax
jne	0x00000f9a

My 2 cents.

Guru’s opinion ?

Attachments:
  1. asm.txt
Jul 30, 2012 at 9:41am #229903