[jmm-dev] jdk9 APIs [Fences specifically]

Doug Lea dl at cs.oswego.edu
Thu Aug 13 23:19:37 UTC 2015

On 08/13/2015 05:04 PM, Hans Boehm wrote:

> I don't think a fence-based approach works.  Deferring all the stores to the
> end of the loop fundamentally remains correct, even with the StoreStore
> fence, since it's consistent with the producer just running very fast for a
> while. The constraint you're trying to enforce has nothing to do with
> ordering.

I must be missing something fundamental about C++ specs. Are C++
compilers allowed to ignore release fences in between writes
to the same variables? In unrolled form, that's what this would
amount to here.

> Aside from not working correctly, you end up slowing down ARM code in ways
> that are entirely unnecessary, by inserting "dmb ishld" or "dmb ishst"
> fences everywhere.  (How expensive they are varies.  On a number of
> implementations they basically seem to be full fences.)

Right. It does put the programmer in control though; for example
   if ((i % 100) == 99) storeStoreFence()

Considering that the goal is communication latency reduction at
the expense of throughput, only the programmer would be able
to make these tradeoffs.


More information about the jmm-dev mailing list