In article <
36aa431c-c0f6-4642...@googlegroups.com>,
First, the academic literature on ordering models is terrible. My eyes
glaze over and it's just so boring.
I'm going to guess "niev" means naive. I find that surprising since x86
is basically TSO. TSO is a good idea. I think weakly ordered CPUs are a
bad idea.
TSO is just a handy name for the Sparc and x86 effective ordering for
writeback cacheable memory: loads are ordered, and stores are buffered and
will complete in order but drain separately from the main CPU pipeline. TSO
can allow loads to hit stores in the buffer and see the new value, this
doesn't really matter for general ordering purposes.
TSO lets you write basic producer/consumer code with no barriers. In fact,
about the only type of code that doesn't just work with no barriers on TSO
is Lamport's Bakery Algorithm since it relies on "if I write a location and
read it back and it's still there, other CPUs must see that value as well",
which isn't true for TSO.
Lock free programming "just works" with TSO or stronger ordering guarantees,
and it's extremely difficult to automate putting in barriers for complex
algorithms for weakly ordered systems. So code for weakly ordered systems
tend to either toss in lots of barriers, or use explicit locks (with
barriers). And extremely weakly ordered systems are very hard to reason
about, and especially hard to program since many implementations are not as
weakly ordered as the specification says they could be, so just running your
code and having it work is insufficient. Alpha was terrible in this regard,
and I'm glad it's silliness died with it.
HP PA-RISC was documented as weakly ordered, but all implementations
guaranteed full system sequential consistency (and it was tested in and
enforced, but not including things like cache flushing, which did need
barriers). No one wanted to risk breaking software from the original in-order
fully sequential machines that might have relied on it. It wasn't really a
performance issue, especially once OoO was added.
Weakly ordered CPUs are a bad idea in much the same way in-order VLIW is a bad
idea. Certain niche applications might work out fine, but not for a general
purpose CPU. It's better to throw some hardware at making TSO perform well,
and keep the software simple and easy to get right.
Kent