[cpp-threads] Memory model question

Peter Dimov pdimov at mmltd.net
Fri Aug 26 22:08:23 BST 2005


Boehm, Hans wrote:

> With the alternate interpretation, the compiler now also has to
> prove that the assignment to global_counter in the initial loop
> iteration actually writes back a modified value.  And I don't think
> that sort of analysis is something that compilers already do.

No, this is not true. The compiler doesn't need to prove anything like that; 
it already has a license to write to global_counter.

x += y;

is implementable as-is, no knowledge about y is required. In fact,

if( y != 0 )
{
    x += y;
}

can be transformed to x += y (at source level) under the alternate 
interpretation, but not under the original.

The alternate model prohibits most (probably all) speculative stores because 
the presence of a race is harder to prove without value analysis. But it 
doesn't affect explicit stores. The primary model prohibits only a portion 
of the speculative stores - those that affect causality. 





More information about the cpp-threads mailing list