[Openmp-commits] [PATCH] D19020: Exponential back off logic for test-and-set lock.

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Tue Apr 12 10:11:20 PDT 2016

jlpeyton created this revision.
jlpeyton added reviewers: hbae, jcownie, AndreyChurbanov.
jlpeyton added a subscriber: openmp-commits.
jlpeyton set the repository for this revision to rL LLVM.

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 the 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.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19020.53422.patch
Type: text/x-patch
Size: 9783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20160412/0adb9377/attachment.bin>

More information about the Openmp-commits mailing list