[cpp-threads] C++ memory model

N.M. Maclaren nmm1 at cam.ac.uk
Tue Sep 22 08:49:32 BST 2009


On Sep 22 2009, Boehm, Hans wrote:
>
>> As an aside, Fortran has backed off from this, and has 
>> specified a simple sequentially consistent segment model, 
>> with implementation dependent atomic semantics.  There are 
>> good reasons for this, as it is targetting a much wider range 
>> of architectures (including distributed memory clusters), and 
>> considerable scalability (thousands of threads and upwards).  
>> Sequentially consistent atomics are not good news for such 
>> requirements ....
>> 
> That seems to be the general belief. I personally haven't been convinced 
> of wither the truth or falsity of the above statement.

That should convince you!  Seriously.  If nobody knows how to implement
something, requiring it in a standard is NOT good news, even if people
are quite certain it can be done.  As experience with Algol 68 should
have taught everybody ....

Consider the following (reasonable) scenario.  There are N threads and
N atomic variables, each of which is accessed more-or-less randomly by
a random collection of M threads in any interval of time T, but by all
threads over longer periods.  How can that be implemented scalably in,
say, the case where M = T = sqrt(N)?

Like you, I haven't been convinced whether it is possible or impossible,
but I have been convinced that it is at least a difficult problem and
it is quite likely that there is no known solution.

> So far, it looks to me more and more like the issues are similar to the 
> shared memory case: It's easy to implement something cheaper whose 
> semantics we can't rigorously define (particularly if you don't have 
> control over the underlying architecture, which implements something 
> cheaper without a simple definition). Once you look at the fundamental 
> properties that need to be enforced for something of manageable 
> complexity, I have a hard time convincing myself that the alternatives 
> are really much cheaper, unless you expose something similar to a 
> message-passing model instead, which of course presents different 
> tradeoffs.

Yes.  The reason it was taken was as the standard committee compromise
between the people who demanded atomics and those who wanted them
excluded and higher level primitives provided instead (e.g. reductions).

Regards,
Nick Maclaren.





More information about the cpp-threads mailing list