the least of the keys of \( p \) threads, one slot of a line of cache per thread, published and read by relaxed accesses
More...
#include <ADS/concurrent/MinBoard.h>
|
| using | Key = K |
| | the type of the keys
|
|
| | MinBoard (std::size_t p, K k=std::numeric_limits< K >::max()) |
| | the board of \( p \) slots, each holding \( k \) (by default the largest key, which no published key is above)
|
| std::size_t | size (void) const |
| | the number \( p \) of the slots
|
| void | publish (std::size_t i, K k) |
| | \( k \) in the slot \( i \), by a relaxed store made only if the slot holds another key, read by a relaxed load
|
| K | at (std::size_t i) const |
| | the key of the slot \( i \), by a relaxed load
|
| K | min (void) const |
| | the least of the keys read in the slots, one relaxed load each: a value of each slot not older than those that happen before the call, not a snapshot of the board
|
| void | reset (K k=std::numeric_limits< K >::max()) |
| | every slot set to \( k \)
|
|
| static constexpr std::size_t | kLine = 64 |
| | the bytes of a slot, a line of cache
|
template<class K>
requires ( std::totally_ordered< K > && std::is_trivially_copyable_v< K > )
class ADS::MinBoard< K >
the least of the keys of \( p \) threads, one slot of a line of cache per thread, published and read by relaxed accesses
◆ Key
◆ MinBoard()
template<class K>
| ADS::MinBoard< K >::MinBoard |
( |
std::size_t | p, |
|
|
K | k = std::numeric_limits< K >::max() ) |
|
inlineexplicit |
the board of \( p \) slots, each holding \( k \) (by default the largest key, which no published key is above)
- Precondition
- \( p \ge 1 \)
◆ at()
the key of the slot \( i \), by a relaxed load
- Precondition
- \( i < p \)
◆ min()
the least of the keys read in the slots, one relaxed load each: a value of each slot not older than those that happen before the call, not a snapshot of the board
In pseudocode (beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{min}() \cr
2 & \quad m \gets S[ 0 ] \cr
3 & \quad \textbf{for}\ i \gets 1\ \textbf{to}\ p - 1\ \textbf{do}
\ m \gets \min( m , S[ i ] )\quad \triangleright\ \text{relaxed} \cr
4 & \quad \textbf{return}\ m
\end{array}}
\]
◆ publish()
\( k \) in the slot \( i \), by a relaxed store made only if the slot holds another key, read by a relaxed load
In pseudocode (beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{publish}( i , k ) \cr
2 & \quad \textbf{if}\ S[ i ] \ne k\ \textbf{then}\ S[ i ] \gets k
\quad \triangleright\ \text{relaxed, the line written only then}
\end{array}}
\]
- Precondition
- \( i < p \); the caller is the only writer of the slot
◆ reset()
template<class K>
| void ADS::MinBoard< K >::reset |
( |
K | k = std::numeric_limits< K >::max() | ) |
|
|
inline |
every slot set to \( k \)
- Precondition
- no other thread accesses the board
◆ size()
the number \( p \) of the slots
◆ kLine
the bytes of a slot, a line of cache
The documentation for this class was generated from the following file: