This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/53436] Volatile behaves strange with OpenMP
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 May 2012 07:59:01 +0000
- Subject: [Bug tree-optimization/53436] Volatile behaves strange with OpenMP
- Auto-submitted: auto-generated
- References: <bug-53436-4@http.gcc.gnu.org/bugzilla/>
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.