ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
MinBoard.h File Reference

A board of the least keys of \( p \) threads, beyond the book: each thread \( i \) owns a slot, where publish( i , k ) writes its key \( k \) (e.g., the least \( f \) of the OPEN list of a worker of a parallel search), and any thread reads by min() the least of the slots (the bound that the workers compare their own with). More...

#include "ADS/Contract.h"
#include <atomic>
#include <concepts>
#include <cstddef>
#include <limits>
#include <memory>
#include <type_traits>

Go to the source code of this file.

Classes

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

Namespaces

namespace  ADS

Detailed description

A board of the least keys of \( p \) threads, beyond the book: each thread \( i \) owns a slot, where publish( i , k ) writes its key \( k \) (e.g., the least \( f \) of the OPEN list of a worker of a parallel search), and any thread reads by min() the least of the slots (the bound that the workers compare their own with).

The slots are atomic words on lines of cache of their own, so that a publish writes one line that no other slot shares, and publish() stores only when the key changes, so that a worker whose key stays leaves its line in the caches of the readers; every access is relaxed, with no read-modify-write and no fence, so that a publish costs a load and at most a store, and a min() \( p \) loads.

The board gives coherence only. Each slot has one writer, its owner, and a modification order, that of its publishes; a read of a slot reads one of its values, not older than any value of the slot whose publish happens before the read (in particular, the last one of the reader itself, if it is the owner), and two reads of one slot by one thread never read the second older than the first. min() returns the least of the \( p \) values that it reads, one per slot and not at the same time, so that it need not be the least of the slots at any instant; when the keys of each slot only decrease (or only grow), the value returned lies between the least key of the board at the end of the call and that at its start (resp. the reverse), and the values returned to one thread only decrease (resp. grow). The relaxed accesses order nothing else: a thread that reads \( k \) in a slot does not see by that read the writes that the owner made before publishing it, which need their own synchronization (see A board of least keys).

The contracts [see Contract.h]: \( p \ge 1 \); a slot \( i < p \) is written only by one thread at a time (its owner); reset() runs with no other operation.

Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa