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

The parallel shortest paths from a node \( s \) of a GRAPH whose costs are not negative, beyond the book, on the threads of an executor [see Executor.h]: the stepping algorithms, which relax in parallel all the active nodes whose distance is below a threshold, with the distances of the algorithm of Dijkstra [see ShortestPaths.h], value for value. More...

#include "ADS/Contract.h"
#include "ADS/graph/Graph.h"
#include "ADS/graph/ShortestPaths.h"
#include "ADS/graph/StaticGraph.h"
#include "ADS/parallel/Executor.h"
#include <algorithm>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <vector>
#include "ADS/parallel/impl/ParallelShortestPaths.tpp"

Go to the source code of this file.

Namespaces

namespace  ADS

Functions

template<Executor E, Graph G>
std::vector< typename G::Weight > ADS::deltaStepping (E &ex, const G &g, int s, typename G::Weight delta)
 the distances from \( s \) by the \( \Delta \)-stepping of Meyer and Sanders, infinity() for the nodes not reached and for the unused names, in a vector of g.bound() places
template<Executor E, Graph G>
std::vector< typename G::Weight > ADS::rhoStepping (E &ex, const G &g, int s, std::size_t rho=std::size_t(1)<< 20)
 the distances from \( s \) by the \( \rho \)-stepping of Dong, Gu, Sun and Zhang, infinity() for the nodes not reached and for the unused names, in a vector of g.bound() places

Detailed description

The parallel shortest paths from a node \( s \) of a GRAPH whose costs are not negative, beyond the book, on the threads of an executor [see Executor.h]: the stepping algorithms, which relax in parallel all the active nodes whose distance is below a threshold, with the distances of the algorithm of Dijkstra [see ShortestPaths.h], value for value.

Both relax the arcs of nodes in parallel, each improvement of a head by an atomic minimum ( \( d( u ) \gets \min\{ d( u ) , d( v ) + w( v , u ) \} \) by a compare-and-swap), and differ in the nodes that a step relaxes:

  • deltaStepping( ex , g , s , delta ), the buckets of width \( \Delta \) of Meyer and Sanders, a step relaxing the bucket of the least distance not yet relaxed. It runs as the Delta-stepping of the GAP benchmark suite (Beamer and Zhang): each thread keeps the nodes that it improves in buckets of its own, a step relaxes the shared frontier of the bucket \( c \) (the threads claim 64 nodes at a time) and then each thread relaxes at once its own bucket \( c \) while it holds fewer than 1000 nodes (the fusion of the buckets of Zhang et al.); the threads vote the next bucket, copy their part of it into the frontier, each at a place of its own, and two barriers end the step. The buckets of a thread are a window of 1024 buckets and an overflow past it, spread over the next window when it opens (the bucketing of Julienne, of Dhulipala, Blelloch and Shun), so that a small \( \Delta \) takes no more memory. A node is in a bucket once per improvement, and skipped when its distance has fallen below the bucket; from the step where the entries put back into the bucket of the step are more than a quarter of those relaxed (a bucket wider than the least costs, where a node improves many times), the distance at which each node was last relaxed is kept, and an entry met again at the same distance relaxes nothing. \( \Delta \) at the least cost gives the algorithm of Dijkstra by buckets, the least work and the most steps;
  • rhoStepping( ex , g , s , rho ), the \( \rho \)-stepping of Dong et al.: a node is active when its distance fell since its arcs were last relaxed, made active once by a flag, and a step relaxes the active nodes up to the \( \rho \)-th least distance among them, estimated on a sample, so that each step relaxes about \( \rho \) nodes whatever the costs, with no parameter that depends on their scale; the arcs of a step are cut into blocks of equal numbers of arcs by the prefix sums of the degrees, and the nodes that a block makes active within the threshold are relaxed by the same block, up to 1024 of them.

The threads of deltaStepping() meet at barriers for the whole run, which a thread joins when the executor starts its call: the barrier counts it at its next release and never waits for a call not started, so that the run ends on any executor, one that runs the calls one after the other included. The distances do not depend on the executor nor on the order of the relaxations: they are the least fixed point of \( d( u ) = \min_{( v , u )} d( v ) + w( v , u ) \) with \( d( s ) = 0 \), where each sum is the one of the computer (for the floating points too, since a sum with a cost that is not negative does not decrease, the property on which the algorithm of Dijkstra rests; see Lemma 5 of Shortest paths by steps).

Each step costs work proportional to the arcs of its nodes and depth proportional to the arcs of one node, a chunk of the frontier and the fusion of one thread; a node is relaxed once with Dijkstra, more often here, as many times as its distance falls after it was relaxed, which a smaller \( \Delta \) or \( \rho \) makes rarer at the price of more steps (the trade of the stepping algorithms; see Shortest paths by steps).

The contracts [see Contract.h]: \( s \) is a node, the costs are not negative, \( \Delta > 0 \) and \( \rho \ge 1 \); the distances are sums in the type of the costs, not checked for overflow, as in ShortestPaths.h, and infinity() marks the nodes not reached. The functions are defined in ParallelShortestPaths.tpp.

See also
U. Meyer, P. Sanders, \( \Delta \)-stepping: a parallelizable shortest path algorithm, Journal of Algorithms 49(1), 114-152, 2003, doi:10.1016/S0196-6774(03)00076-2
X. Dong, Y. Gu, Y. Sun, Y. Zhang, Efficient stepping algorithms and implementations for parallel shortest paths, Proc. 33rd SPAA, 184-197, 2021, doi:10.1145/3409964.3461782
Y. Zhang, A. Brahmakshatriya, X. Chen, L. Dhulipala, S. Kamil, S. Amarasinghe, J. Shun, Optimizing ordered graph algorithms with GraphIt, Proc. 18th CGO, 158-170, 2020, doi:10.1145/3368826.3377909
S. Beamer, K. Asanović, D. Patterson, The GAP benchmark suite, arXiv:1508.03619, 2015
L. Dhulipala, G. E. Blelloch, J. Shun, Julienne: a framework for parallel graph algorithms using work-efficient bucketing, Proc. 29th SPAA, 293-304, 2017, doi:10.1145/3087556.3087580
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa