You are viewing nickclifton

Previous Entry | Next Entry

March 2013 GNU Toolchain Update

Deep Thought
Hi Guys,

  It has been a very quiet month this month.  The GCC sources are still closed to new features, pending the creation of the 4.8 branch.

  The binutils sources now have support for a 64-bit cygwin target called x86_64-cygwin.  Patches for GCC are currently under development and a full gcc port should be ready soon.

  There is a new function attribute for GCC called no_sanitize_address which tells the compiler that it should not instrument memory accesses in that function when compiling with the -fsanitize=address option enabled.

  One new, target specific, feature that has made it into GCC is support for x86 hardware transactional memory.  This is done via intrinsics for Restricted Transactional Memory (RTM) and extensions to the memory model for Hardware Lock Elision (HLE).

  For HLE two new flags can be used to mark a lock as using hardware elision:

    __ATOMIC_HLE_ACQUIRE
      Starts lock elision on a lock variable.
      The memory model in use must be __ATOMIC_ACQUIRE or stronger.

    __ATOMIC_HLE_RELEASE
      Ends lock elision on a lock variable.
      The memory model must be __ATOMIC_RELEASE or stronger.

  So for example:

   while (__atomic_exchange_n (& lockvar, 1, __ATOMIC_ACQUIRE | __ATOMIC_HLE_ACQUIRE))
      _mm_pause ();


    [do stuff with the lock acquired]
 
   __atomic_clear (& lockvar, __ATOMIC_RELEASE | __ATOMIC_HLE_RELEASE);


 The new intrinsics that support Restricted Transactional Memory are:

     unsigned _xbegin (void)

    This tries to start a transaction.  It returns _XBEGIN_STARTED if
    it succeeds, or a status value indicating why the transaction
    could not be started if it fails.

     void _xend (void)
    
    Commits the current transaction.  When no transaction is active
    this will cause a fault.  All memory side effects of the
    transactions will become visible to other threads in an atomic
    manner.

     int _xtest (void)
    
    Returns a non-zero value when a transaction is currently active,
    and otherwise zero.

      void _xabort (unsigned char status)

    Aborts the current transaction.  When no transaction is active
    this is a no-op.  The parameter "status" is included in the return
    value of any _xbegin() call that is aborted by this function.

  Here is a small example:

   if ((status = _xbegin ()) == _XBEGIN_STARTED)
      {

         [do stuff]
        _xend ();
      }
    else
      {

        [examine status to see why the transaction failed and possibly retry].
    }

Cheers
  Nick

Profile

Deep Thought
nickclifton
nickclifton

Latest Month

August 2014
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
31      
Powered by LiveJournal.com
Designed by chasethestars