[cpp-threads] Review comments on N2176 WRT dependency ordering

Paul E. McKenney paulmck at linux.vnet.ibm.com
Mon Apr 16 22:24:26 BST 2007


On Mon, Apr 16, 2007 at 06:12:14PM +0300, Peter Dimov wrote:
> Paul E. McKenney wrote:
> >Hello again!
> >
> >I once again thank Hans for his careful description of a number of
> >interesting optimization situations relating to dependency-based
> >ordering.  The following text discusses some possible approaches
> >to resolving these situations.
> >
> >Thoughts?
> 
> [...]
> 
> >8. Allow the optimizer to break dependencies except when explicitly
> >told not to.  Potential ways of telling the compiler not to break
> >dependencies include:
> 
> [...]
> 
> N2195 proposes the following minimalistic approach:
> 
> template< class T > inline T * atomic_load_address( T * const * p );
> template< class T > inline T * atomic_load_address( T * const volatile * 
> p );

I do like the template approach!

> Returns: *p.
> 
> Constraint: _Acquire only with respect to **p.

OK -- but what about p->some_field?  Or does **p indicate any dereference
of p?  I had been assuming the more restrictive mode.

> That is, after X * p = atomic_load_address( &q ), *p is guaranteed to be 
> visible, although traversing any additional pointers in *p using ordinary 
> or relaxed loads is not well-defined; one needs an additional 
> atomic_load_address for them.

One way of making the traversal of additional pointers well defined
is to tag the dependency chains of interest.  Functions that are to
be traversed by dependency chains must also be tagged.

>                               Index-based dependencies are not supported.

Why not?  Requiring tagging of the important dependency chains
should make the reduction in optimization tolerable, right?

> atomic_load_address maps to Relaxed on everything except Alpha, where it 
> maps to Acquire.

Makes sense -- and strongly ordered machines need not worry about
the dependency chains either.

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

Thank you for the reminder URL!

						Thanx, Paul



More information about the cpp-threads mailing list