src/parallel.bend relies on unsafe/foreign
raw source on the hub · import bend-visgraph@1.0.0.0/src/parallel.bend as Parallel
The build and the degree count on every thread. Each def here that hands one array to two tasks relies on Base's @unsafe Array.fork: the tasks that share an array read it, write cells no other task writes, or add to cells atomically.
5 imports
import Base import ./graph.bend as G import ./penetrable.bend as P import ./report.bend as Report import ./vg.bend as VG
Types
type Blocks source · line 23 · raw
Data
The stack runs on blocks in parallel; a merge then walks the blocks in order.
BOne@b:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Block -> Blocks
BJoin@a:Blocks -> @b:Blocks -> Blocks
type Chunks source · line 58 · raw
Data
CNilChunks
CCon@start:U32 -> @count:U32 -> @next:Chunks -> Chunks
type Cut source · line 69 · raw
Type
Cut@lefts:Array<U32> -> @rights:Array<U32> -> @cs:Chunks -> @m:U32 -> Cut
type Halves source · line 98 · raw
Data
Halves@a:Chunks -> @na:U32 -> @b:Chunks -> @nb:U32 -> Halves
Definitions
def fork3 source · line 11 · raw
@a:Pair(Array<F32>, Array<F32>) -> @b:Pair(Array<U32>, Array<U32>) -> @c:Pair(Array<U32>, Array<U32>) -> Pair(0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols, 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols)
def fork_cols source · line 17 · raw
@c:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols -> Pair(0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols, 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols)
def block_of source · line 27 · raw
@l:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Local -> Blocks
def block_leaf source · line 34 · raw
@+s:U32 -> @+e:U32 -> @c:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols -> Blocks
It forks nothing, so the runtime runs it once the tree has grown, on any idle thread; work done before a fork runs while the tree grows, on a few threads.
def block_tree source · line 38 · raw
@depth:Nat -> @+s:U32 -> @+e:U32 -> @cc:Pair(0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols, 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols) -> Blocks
def merge source · line 51 · raw
@bs:Blocks -> @m:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Merged -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Merged
def close source · line 62 · raw
@full:Bool -> @+start:U32 -> @+end:U32 -> @cs:Chunks -> Chunks
def cut source · line 72 · raw
@count:Nat -> @+i:U32 -> @lr:Pair(Array<U32>, U32) -> @rr:Pair(Array<U32>, U32) -> @+start:U32 -> @+acc:U32 -> @+target:U32 -> @cs:Chunks -> @+m:U32 -> Cut
def fork_depth source · line 87 · raw
Nat
def block_depth source · line 91 · raw
@+n:U32 -> Nat
At most 512 blocks, and at least 32 points in each unless n is below 64.
def target source · line 95 · raw
@+visits:F32 -> U32
About two chunks for each of the tree's leaves.
def halve source · line 101 · raw
@k:Nat -> @cs:Chunks -> @+na:U32 -> @+total:U32 -> @acc:Chunks -> Halves
def halves source · line 108 · raw
@cs:Chunks -> @+m:U32 -> Halves
def chunks source · line 111 · raw
@cs:Chunks -> @o:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Out -> @+index:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Out
def leaf source · line 120 · raw
@cs:Chunks -> @c:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols -> @xs:Array<F32> -> @+index:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
def tree source · line 123 · raw
@depth:Nat -> @h:Halves -> @cc:Pair(0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols, 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols) -> @xx:Pair(Array<F32>, Array<F32>) -> @+index:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
def split source · line 136 · raw
@+index:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> @ys:Array<F32> -> @xs:Array<F32> -> @c:Cut -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
def cut_all source · line 140 · raw
@+index:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> @+n:U32 -> @ys:Array<F32> -> @xs:Array<F32> -> @lefts:Array<U32> -> @r:Pair(Array<U32>, F32) -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
def merged source · line 144 · raw
@+index:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> @+n:U32 -> @ys:Array<F32> -> @xs:Array<F32> -> @m:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Merged -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
def passed source · line 148 · raw
@+index:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> @+n:U32 -> @xs:Array<F32> -> @cc:Pair(0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols, 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Cols) -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
def built source · line 153 · raw
@+index:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> @ys:Array<F32> -> @xs:Array<F32> -> @+n:U32 -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
def visibility source · line 158 · raw
@+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> @ys:Array<F32> -> @xs:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Xs -> @+n:U32 -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
G.build on every thread: the stack runs on blocks, then the sweeps on chunks of equal work.
def chosen source · line 165 · raw
@is_visibility:Bool -> @+g:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Graph -> @+dir:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Direction -> @+k:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Weight -> @+lo:F32 -> @+hi:F32 -> @+limit:U32 -> @ys:Array<F32> -> @xs:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Xs -> @+n:U32 -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
def build source · line 173 · raw
@o:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/vg.Options -> @s:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/vg.Series -> 0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges
VG.build on every thread.
def degrees_tree source · line 180 · raw
@depth:Nat -> @es:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges -> @dd:Pair(Array<U32>, Array<U32>) -> Array<U32>
Forks down the build's tree of EJoin into Report.degrees, which forks nothing, so the runtime spreads the tallies over every thread.
def degrees source · line 195 · raw
@es:0xe3f5cb14a0b4bd4d5826a0042d3c3d23/src/graph.Edges -> @+n:U32 -> Array<U32>
VG.degrees on every thread.