Sort.sums: def of bend-parallel@0.1.0.0 Import: import bend-parallel@0.1.0.0/sort.bend as Sort Lines 132-150 of bend-parallel@0.1.0.0/sort.bend: https://jend.leeeet.dev/read.txt?path=bend-parallel@0.1.0.0/sort.bend&start_line=132&end_line=150 import Base # Pass 2b's forks: d levels down to groups of 2^w columns under group j, # with two handles each to the table, the counts and the offsets. Group j # reads (and when wr writes) only its columns of the table and writes # only its own entries of counts and offs (j * 2^w to j * 2^w + 2^w - 1). def sums(+d: Nat, +wr: Bool, +j: U32, +w: Nat, +k: U32, +o: U32, +step: U32, +nb: Nat, ft: Array & Array, fc: Array & Array, fo: Array & Array) -> Three: match d: case 0n: (t, t2) = ft (cs, cs2) = fc (os, os2) = fo three.rejoin(t2, cs2, os2, sum.go(U32.to_nat((U32.shln(1, w) - 1 : U32)), wr, U32.shln(j, w), k, o, step, nb, Three{t, cs, os})) case 1n+p: (t0, t1) = ft (c0, c1) = fc (o0, o1) = fo +i = (j * 2 : U32) l r = sums(p, wr, i, w, k, o, step, nb, Array.fork(U32, t0), Array.fork(U32, c0), Array.fork(U32, o0)) sums(p, wr, (i + 1 : U32), w, k, o, step, nb, Array.fork(U32, t1), Array.fork(U32, c1), Array.fork(U32, o1)) three.join(l, r) Uses (16): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.fork https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.shln https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=Three https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=sum.go https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=three.join https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=three.rejoin