|
ADS
Algorithms and Data Structures
|
The deterministic reservations of Blelloch, Fineman, Gibbons and Shun, beyond the book: speculativeFor( ex , step , s , e ) runs, on the threads of an executor [see Executor.h], a loop whose iterations \( s , s + 1 , \ldots , e - 1 \) a sequential program would run in this order, each depending on the ones before it, and gives the result of the sequential loop whatever the executor and the number of its threads (see Deterministic reservations, greedy algorithms). More...
#include "ADS/Contract.h"#include "ADS/parallel/Executor.h"#include <atomic>#include <concepts>#include <cstddef>#include <limits>#include <vector>#include "ADS/parallel/impl/SpeculativeFor.tpp"Go to the source code of this file.
Classes | |
| class | ADS::Reservation |
| a place reserved by the least of the iterations that want it More... | |
| struct | ADS::SpeculativeCounts |
| what speculativeFor() did: its rounds and the iterations tried, the failed ones counted again More... | |
Namespaces | |
| namespace | ADS |
Concepts | |
| concept | ADS::SpeculativeStep |
| the two steps of an iteration [see speculativeFor()] | |
Functions | |
| template<Executor E, SpeculativeStep S> | |
| void | ADS::speculativeFor (E &ex, S &step, std::size_t s, std::size_t e, std::size_t g=50, SpeculativeCounts *c=nullptr) |
| the iterations \( [ s , e ) \) of step by deterministic reservations, with the result of the sequential loop; the rounds of at most \( r_{\mathrm{max}} = \lfloor ( e - s ) / g \rfloor + 1 \) iterations; its work in *c, if given | |
The deterministic reservations of Blelloch, Fineman, Gibbons and Shun, beyond the book: speculativeFor( ex , step , s , e ) runs, on the threads of an executor [see Executor.h], a loop whose iterations \( s , s + 1 , \ldots , e - 1 \) a sequential program would run in this order, each depending on the ones before it, and gives the result of the sequential loop whatever the executor and the number of its threads (see Deterministic reservations, greedy algorithms).
An iteration \( i \) is split into the two steps of the object step: step.reserve( i ) reads the state that the earlier iterations left, and either finds that \( i \) has nothing to do (it returns false, and \( i \) is done) or writes \( i \) into a Reservation of each place of the state that it would change, and returns true; step.commit( i ) changes the state if \( i \) holds all its reservations and returns true, or returns false to be tried again in the next round, and the holder of a reservation frees it, so that all of them are free at the end of a round. By Lemma 4 of Deterministic reservations, greedy algorithms the least iteration of a round commits and the result is the sequential one. The phase-parallel framework of Shen, Wan, Gu and Sun generalizes the scheme to the loops whose dependences are not conflicts on places (e.g., the longest increasing subsequence); for the greedy algorithms on graphs the reservations remain the method of the benchmark suites (PBBS, GBBS).
The contracts [see Contract.h]: \( s \le e \), \( g \ge 1 \); the reserve() of distinct iterations write only reservations (and their own places), their commit() only the places whose reservations they hold, and the least iteration of a round commits (else the loop would stop; a round with no commit is a violated precondition).