[Omp] Two simpler examples (Re: OpenMP spec 2.5 seems to have incorrect flush example on page 12)

Greg Bronevetsky greg at bronevetsky.com
Sat May 5 22:37:41 PDT 2007


In OpenMP volatile is just syntactic sugar for some flushes with lists. As
such, it doesn't offer us any more power than flush. It just puts flushes
in more locations in the code.

Also, how is this stuff handled in pthreads? What is the pthreads memory
model?

                             Greg Bronevetsky

On Sat, 5 May 2007, Yuan Lin wrote:

> Volatile is a property of the memory location. Flush is not. Flush  
> has almost no control of what could happen between two flushes. A  
> compiler may not know the existence of a flush because the access of  
> a shared variable and a flush can be in different routines. To make  
> matters worse, what do we expect a compiler to do when it links a  
> module what is compiled with OpenMP option and a module that does not  
> contain OpenMP code and is not  compiled with OpenMP option?
> 
> I don't know if this will make any of us feel better, I don't think  
> the problem is specific to OpenMP.
> 
> -- Yuan
> 
> 
> On May 5, 2007, at 9:32 PM, Meadows, Lawrence F wrote:
> 
> > Aargh! The compiler inserted memory references that changed the  
> > view of memory by one thread. That was legal because the compiler  
> > didn't know that another thread was viewing the memory. In essence  
> > the compiler added the race. So you have to tell the  compiler that  
> > it can't do that. That is what flush is for. Or volatile.
> >
> > -- Larry
> >
> 
> 



More information about the Omp mailing list