This repository provides:
- libslock, a cross-platform interface to atomic operations and other common operations
- implementations of a number of well-known locking algorithms
- benchmarks testing the performance of atomic operations and various locking algorithms
The package has been tested on x86_64 Intel and AMD machines, Tilera and Sparc architectures.
A version of this code was used in the paper "Everything you always wanted to know about synchronization but were afraid to ask" (accessible here: http://dl.acm.org/citation.cfm?doid=2517349.2522714).
Makefile parameters:
Can be passed using LOCK_VERSION
to the Makefile. LOCK_VERSION
can take one of the following values:
USE_TTAS_LOCKS
- use test-and-test-and-set locksUSE_SPINLOCK_LOCKS
- use test-and-set spinlocksUSE_TICKET_LOCKS
- use ticket locksUSE_HTICKET_LOCKS
- use hierarchical ticket locksUSE_MCS_LOCKS
- use MCS locksUSE_CLH_LOCKS
- use CLH locksUSE_HCLH_LOCKS
- use HCLH locksUSE_ARRAY_LOCKS
- use array locksUSE_RW_LOCKS
- use read-write locks (not used in paper, not optimized)USE_MUTEX_LOCKS
- use the phtread mutex
Can be passed using PLATFORM
to the Makefile; the settings are specific to the platforms we were using (topology, etc.); for other platforms the characteristics can be defined in platform_defs.h
. The pre-defined platforms are:
XEON
- 8 x 10-core Intel severOPTERON
- 8 x 6-core AMD serverNIGARA
- 8-core SparcT2 machineTILERA
- 36-core Tilera machine
Detailed descriptions of these platforms can be found in the paper.
The OPTERON_OPTIMIZE
option uses some of the Opteron-specific optimizations mentioned in the paper.
Atomic operation to be tested
For the benchmarks testing atomic operations, this parameter selects the desired operation. Can be passed to the Makefile using PRIMITIVE
:
TEST_FAI
- fetch-and-incrementTEST_TAS
- test-and-setTEST_CAS
- compare-and-swapTEST_SWAP
- atomic swapTEST_CAS_FAI
- fetch-and-increment implemented using compare-and-swap
ALTERNATE_SOCKETS
is used for thread placement on the Niagara; if not set, hardware threads begin by being assinged to the same core; if set threads are disitributed evenly among the cores