Sort.gats: def of bend-parallel@0.1.0.0 Import: import bend-parallel@0.1.0.0/sort.bend as Sort Lines 456-476 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=456&end_line=476 import Base # The gather's forks: d levels down to blocks of 2^e slots under block i, # with two handles each to perm, src and dst. Block i reads only its # entries of perm, reads src anywhere (no lane writes src) and writes only # its slots of dst. def gats(~T: Data, +d: Nat, +i: U32, +e: Nat, fp: Array & Array, fs: Array & Array, fd: Array & Array) -> Moved: match d: case 0n: (pm, pm2) = fp (src, src2) = fs (dst, dst2) = fd +at = U32.shln(i, e) moved.rejoin(~T, pm2, src2, dst2, gat.go(~T, U32.to_nat((U32.shln(1, e) - 1 : U32)), at, Sd{src, dst}, pm[at])) case 1n+p: (p0, p1) = fp (s0, s1) = fs (d0, d1) = fd +j = (i * 2 : U32) l r = gats(~T, p, j, e, Array.fork(U32, p0), Array.fork(T, s0), Array.fork(T, d0)) gats(~T, p, (j + 1 : U32), e, Array.fork(U32, p1), Array.fork(T, s1), Array.fork(T, d1)) moved.join(~T, l, r) Uses (17): 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=Array.get 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=Moved https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=Sd https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=gat.go https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=moved.join https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=moved.rejoin