This is an archive of the discontinued LLVM Phabricator instance.

Exponential back off logic for test-and-set lock.
ClosedPublic

Authored by jlpeyton on Apr 12 2016, 10:11 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

jlpeyton updated this revision to Diff 53422.Apr 12 2016, 10:11 AM
jlpeyton retitled this revision from to Exponential back off logic for test-and-set lock..
jlpeyton updated this object.
jlpeyton added reviewers: hbae, jcownie, AndreyChurbanov.
jlpeyton set the repository for this revision to rL LLVM.
jlpeyton added a subscriber: openmp-commits.
hbae edited edge metadata.Apr 13 2016, 8:01 AM

LGTM.

This revision was automatically updated to reflect the committed changes.