Skip to content
  • Jonathan Peyton's avatar
    Exponential back off logic for test-and-set lock · 377aa40d
    Jonathan Peyton authored
    This change adds back off logic in the test and set lock for better contended
    lock performance. It uses a simple truncated binary exponential back off
    function. The default back off parameters are tuned for x86.
    
    The main back off logic has a two loop structure where each is controlled by a
    user-level parameter:
    max_backoff - limits the outer loop number of iterations.
        This parameter should be a power of 2.
    min_ticks - the inner spin wait loop number of "ticks" which is system
        dependent and should be tuned for your system if you so choose.
        The "ticks" on x86 correspond to the time stamp counter,
        but on other architectures ticks is a timestamp derived
        from gettimeofday().
    
    The user can modify these via the environment variable:
    KMP_SPIN_BACKOFF_PARAMS=max_backoff[,min_ticks]
    Currently, since the default user lock is a queuing lock,
    one would have to also specify KMP_LOCK_KIND=tas to use the test-and-set locks.
    
    Differential Revision: http://reviews.llvm.org/D19020
    
    llvm-svn: 266329
    377aa40d
Loading