Boost logo

Boost :

Subject: Re: [boost] [spinlock] Spin on volatile read, NUMA fairness?
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-12-04 09:01:10


On 4 Dec 2014 at 13:25, Niall Douglas wrote:

> On 4 Dec 2014 at 3:39, Peter Dimov wrote:
>
> > and that it's better to do this:
> >
> > // atomic_bool f_;
> >
> > do
> > {
> > while( f_.load( std::memory_order_relaxed ) )
> > {
> > /* maybe yield */
> > }
> > }
> > while( f_.exchange( true, std::memory_order_acquire ) );
> >
> > instead.
>
> I just tested this form instead, and on VS2013 dual core x86 I saw a
> 45% performance increase. Very nice. Thank you.

FYI on ARMv7 I saw a catastrophic performance loss with the same
measure. Spinlock performance dropped from 17m ops/sec to 2.3m
ops/sec. It would seem that the ARM really hates unconditional atomic
exchange.

Forthcoming Boost.Spinlock now does unconditional exchange on Intel
only, and conditional exchange everywhere else. Sadly without more
CPUs to test it is hard to do much better.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk