def puts

bend-parallel@0.1.0.0 · sort.bend:316

import bend-parallel@0.1.0.0/sort.bend as Sort
import Base

316# Pass 3's forks: d levels down to the blocks under block i, with two
317# handles each to the keys, the table and perm. Block i reads only its
318# keys, reads and writes only its row of the table, and writes perm only
319# at the slots its row hands it: pass 2 gave each (block, bucket) pair its
320# own run of slots, so no two lanes write one slot.
321def puts(+d: Nat, +i: U32, +e: Nat, +kb: Nat, +k: U32, fk: Array<U32> & Array<U32>, ft: Array<U32> & Array<U32>, fp: Array<U32> & Array<U32>) -> Three:
322  match d:
323    case 0n:
324      (ks, ks2) = fk
325      (t, t2) = ft
326      (pm, pm2) = fp
327      three.rejoin(ks2, t2, pm2, puts.leaf(i, e, kb, k, ks, t, pm))
328    case 1n+p:
329      (k0, k1) = fk
330      (t0, t1) = ft
331      (p0, p1) = fp
332      +j = (i * 2 : U32)
333      l r = puts(p, j, e, kb, k, Array.fork(U32, k0), Array.fork(U32, t0), Array.fork(U32, p0))
334        puts(p, (j + 1 : U32), e, kb, k, Array.fork(U32, k1), Array.fork(U32, t1), Array.fork(U32, p1))
335      three.join(l, r)

Uses (12)

Used by (1)