define LFDS700_PAL_CACHE_LINE_LENGTH_IN_BYTES
Source File
└───liblfds700 └───inc └───liblfds700 lfds700_lfds700_porting_abstraction_layer_processor.h
Define
#define LFDS700_PAL_CACHE_LINE_LENGTH_IN_BYTES [cache line length in bytes]
Example
#define LFDS700_PAL_CACHE_LINE_LENGTH_IN_BYTES 32
Optionality
This define is optional. If it omitted, the define can be absent or empty.
Notes
Please see Randon Number Generation and Lock-Free Exponential Backoff.
When two threads attempting to perform atomic operations collide with one another, they both perform back-off - they wait for a certain period before retrying. A random number generator in involved in the computation of the wait period. This computation basically randomly selects a value between 0 and a maximum, where the maximum keeps increasing as the number of consecutive collisions increases, and where the value selected is multipled by a constant, where there is one constant for a CAS operation and another for a DWCAS operation.
A copy of those constants is kept in the same structure as the random number generator state, so that when the random number generator state is loaded from memory, the constant are as well (as all reads from memory read in a whole cache-line at a time).
As such, when allocating a lfds700_misc_prng_state, either on the heap or on the stack, it should be cache-line aligned, and this define specifies the cache length line.
The library code itself does not use this define - it's merely that it should be used by users when allocating lfds700_misc_prng_states. If this is not done, performance will suffer if the lfds700_misc_prng_state ends up spanning two cache lines; the use of this define ensures this will not happen.