Boost logo

Boost :

Subject: Re: [boost] [lock-free] CDS -yet another lock-free library
From: Khiszinsky, Maxim (Maxim.Khiszinsky_at_[hidden])
Date: 2010-03-30 11:19:00


Helge Bahmann wrote:

> I'm not sure this works, it is just an attempt based on a bold suspicion
> of what the actual problem is :) But it would sure be interesting if you
> could try that out or something similar

__restrict didn't solve the problem on MS Visual C++ 2008 :-(

static inline atomic64_t load64( atomic64_t volatile const * pMem )
{
  // Atomically loads 64bit value by SSE intrinsics
  __m128i v = _mm_loadl_epi64( (__m128i const * __restrict) pMem ) ;
  return v.m128i_i64[0] ;
}

- infinite loop in spinlock on atomic64_t.

However, Peter Dimov's advice corrected the error - volatile! Yes!
This code

static inline atomic64_t load64( atomic64_t volatile const * pMem )
{
  // Atomically loads 64bit value by SSE intrinsics
  __m128i volatile v = _mm_loadl_epi64( (__m128i const *) pMem ) ;
  return v.m128i_i64[0] ;
}

works well.

Thanks, Peter!

Regards, Max


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