[cpp-threads] Alternatives to SC

Doug Lea dl at cs.oswego.edu
Tue Jan 30 00:30:31 GMT 2007


Boehm, Hans wrote:
>>
> I think that you should be able to write these using "raw" atomics in
> C++.  The intent is for that to give you atomicity at low cost, which is
> kind of what you get from normal Java variables.  

Sorry, I'm not sure I quite get this:

If I want the kinds of variables that won't cause blow-ups
after register spills etc, then I should use raw atomics. And the
reason I should use them is that we aren't sure that optimizers
would do the right thing of all "normal" variables were of this kind.
Which wouldn't make one very confident that they'll do the right
thing with raw atomics?

>>
>> I think the other issues along these lines involve invented
>> writes. These might be more controversial. Do you have a list of
>> them handy?
> I don't, and that's really what would scare me about trying to change
> this.  .

I do share your concerns. But am momentarily more optimistic.

> 
> It seems to me that essentially any flow- or context-sensitive compiler
> analysis makes this sort of assumption by default.  For Java, compiler
> implementers were forced to think about this from the start.  (And a
> smaller number probably actually did :-) ) 

Well, the hotspot server compiler was initially based on Cliff
Click's high-performance Fortran compiler, and to the best of
my knowledge copes fine with these rules. I don't know how it
fares against the most highly optimizing C++ compilers though,
so don't know if there are some important cases of optimizations
that would be disabled.

I'm guessing that right about now, systems programmers reading
our postings are thinking about asking their local
compiler developers if any of these kinds of optimizations are
actually performed, and thus cause programs using their current
schemes based on ad-hoc pre-standardized barrier macros etc
to not actually work. It may be that the pressure on compiler
writers to not cause such systems software to mysteriously crash
will do a good job of exploring this territory for us.

But I'm not arguing strenuously to scrap normal vs raw-atomic
scheme -- I just think that they make the spec a lot harder,
and perhaps needlessly harder, which was main point of my last mail.

-Doug



More information about the cpp-threads mailing list