[Bug tree-optimization/53436] Volatile behaves strange with OpenMP

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 22 09:55:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53436

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-22 07:59:01 UTC ---
(In reply to comment #4)
> (In reply to comment #3)
> > The testcase is not valid OpenMP, there is no flush operation in between the
> > store and reads, 
> 
> Is that also needed with volatile variables? Would be quite counterintuitive.

I believe so.  Volatile only makes sure the compiler emits a store of the
variable to memory, but the CPU can just store it into a cache.  There is
nothing that orders that store compared to other stores/loads.
So, just use the appropriate OpenMP directives for synchronization, rather than
bad attempts at busy waiting using volatile.



More information about the Gcc-bugs mailing list