def rows

bend-parallel@0.1.0.0 · histogram.bend:140

import bend-parallel@0.1.0.0/histogram.bend as Histogram
import Base

140# Pass 1's forks: d levels down to the blocks under block index i. fk and
141# ft are two handles each to the keys and the table. Block i reads only
142# its keys and reads and writes only its row (entries i * 2^kb to
143# i * 2^kb + K - 1): no two lanes touch one slot.
144def rows(+d: Nat, +i: U32, +e: Nat, +kb: Nat, +k: U32, fk: Array<U32> & Array<U32>, ft: Array<U32> & Array<U32>) -> Two:
145  match d:
146    case 0n:
147      (ks, ks2) = fk
148      (t, t2) = ft
149      two.rejoin(ks2, t2, rows.leaf(i, e, kb, k, ks, t))
150    case 1n+p:
151      (k0, k1) = fk
152      (t0, t1) = ft
153      +j = (i * 2 : U32)
154      l r = rows(p, j, e, kb, k, Array.fork(U32, k0), Array.fork(U32, t0))
155        rows(p, (j + 1 : U32), e, kb, k, Array.fork(U32, k1), Array.fork(U32, t1))
156      two.join(l, r)

Uses (12)

Used by (2)