Subject: Re: [boost] [lock-free] CDS -yet another lock-free library
From: Helge Bahmann (hcb_at_[hidden])
Date: 2010-03-31 03:25:07


On Wed, 31 Mar 2010, Khiszinsky, Maxim wrote:

> Giovanni Piero Deretta wrote
>
>> Shouldn't volatile go in the cast and not in v? It is fine if v is
>> stored in a register, but you want the read to pMem not to be cached.
>> What you are doing with the cast right now is casting away
>> volatile-ness in addition of changing the type of the pointed object.
>> The fact that it is now working is probably just due to the fact that
>> the compiler is confused: the compiler is still free to hoist the
>> loads from pmem, as long as all stores and loads to v (which is in the
>> stack) are done.
>
> Yes, I agree
> However, the parameter of _mm_loadl_epi64 is declared as non-volatile and casting
> _mm_loadl_epi64( (__m128i volatile const *) pMem )
> generates error.
> The solution from CDS library is a workaround for MS Visual C++ compiler. I cannot invent something better now.

> Second solution: use 64bit CAS to load/store 64bit values on x86. It
> seems too heavy for just loading/storing it isn't?

this is actually what I do in Boost.Atomic; I *think* it is cheaper than
shuffling around the values between SSE and general purpose registers (it
sure is cheaper than MMX considering you also have to issue emms)

Regards,
Helge