[cpp-threads] High-level vs. low-level

Peter Dimov pdimov at mmltd.net
Thu Jul 13 19:10:23 BST 2006


Just a quick response; detailed reply later:

Herb Sutter wrote:

>> In some cases (amortized constant) he'll also
>> need to look up the C++ memory model specification. Not a big deal,
>> admittedly.
>
> I don't think this is true, and I think there's a misconception here.
> My difficulty is that I think the vast majority of programmers won't
> (and don't) look up the memory model -- they will (and do) just assume
> sequential consistency. (We can also have a separate debate over
> whether they should be expected to look at the memory model. :-) )
>
> I don't think this is speculation, because it's been amply observed to
> be that people expect and rely on SC in practice. [...]


>> One approach to bridge this gap between the research community and
>> the C++ programming community is to provide a way to achieve
>> sequential consistency
>> by using an ordinary syntax, but this obviously leads to suboptimal
>> implementations.
>
> Yes, and this is the critical point. "Suboptimal" compared to what,
> and for some measure of raw performance or for correctness and
> maintainability? In Hans's presentation about the C++MM, he has this
> line:
>
>   "Fundamental assumption: Usability is more important than 5%
> performance."

You have to pick one or the other :-) The current model behind the 
high-level loads and stores is (IIUC) ld.acq+st.rel, which has been proven 
to result in close to optimal performance.

I'm not sure that a sequentially consistent model can achieve the above 
"within 5%" performance goal. On x86, for example, all stores would need to 
be fully locked (lock xchg).




More information about the cpp-threads mailing list