[concurrency-interest] Atomic.*lazyGet

Boehm, Hans hans.boehm at hp.com
Wed Aug 8 23:45:10 EDT 2012

I'm confused.  LazySet() does have happens-before semantics.  And I don't think that's changeable without serious code breakage.  It doesn't participate in the total synchronization order.  That doesn't really make sense in the current memory model, since the synchronization order is what determines happens-before semantics.  But we kind of know what it's supposed to do.

I'm not sure that we should add more APIs here that we can't really define.  WeakGet would presumably behave like memory_order_acquire in C++, which is kind of, but not really, like including a trailing LoadLoad and LoadStore fence?  (Just LoadLoad would be really weird, and I think quite undesirable and not beneficial to performance.)  The semantics of that are very subtly different from a volatile load.  I'm not sure I would know how to describe it.

On the other, there is currently a large additional overhead for volatile loads on POWER, which could be avoided by weakGet, even as defined above.  See http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html .  I'm not sure Doug's mappings are quite up-to-date in this respect.  On most other architectures the differences seem to be minor to none, or at least getting there.


> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu [mailto:concurrency-
> interest-bounces at cs.oswego.edu] On Behalf Of Aleksey Shipilev
> Sent: Wednesday, August 08, 2012 6:55 AM
> To: Doug Lea
> Cc: concurrency-interest at cs.oswego.edu
> Subject: Re: [concurrency-interest] Atomic.*lazyGet
> On 08/08/2012 05:22 PM, Doug Lea wrote:
> > On 08/08/12 08:29, Aleksey Shipilev wrote:
> >> In short, I would like us to consider adding lazyGet() to our atomic
> >> primitives. Googling around haven't got me to any pointers if anyone
> had
> >> considered this before. If anyone had, please point me there.
> >
> > See previous list discussions of "weakGet()" (which is a better name,
> > in line with weakCompareAndSet), at least as far back as 2006.
> > For example:
> > http://cs.oswego.edu/pipermail/concurrency-interest/2006-
> May/002526.html
> Ah, thanks for the link. I had clearly googled for a different name.
> I'd
> expect search engines to pick up "lazyGet" as well now.
> > The lazySet case, that we did add without incorporation into JMM, was
> > different in that we were confident that we could spec
> > it formally without breaking things in a minor JMM revision
> > when it came up next.
> But it is still not formalized, right? If we blow lazySet() by saying
> "lazySet() is like naked write without HB semantics", why can't we just
> say "weakGet() is like naked read without HB semantics"? No strings
> attached. Granted, this is the wizardry stuff, but it is probably
> easier
> than to introduce Fences and require revamping JMM to fit it there.
> In fact, I would have done the similar thing by hand, if only VM could
> provide me with the appropriate intrinsic. It seems to be better
> engineering route to justify this addition with having the API exposing
> it, but probably it is too much to ask? Should we instead go for
> Unsafe-only route?
> -Aleksey.
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest

More information about the Concurrency-interest mailing list