Computed native Morton spread table #
The table may start dirty. Each entry is read only after an earlier native iteration has written it, and its value follows the existing digit recurrence. Every division, remainder, index calculation, load, store and loop instruction is charged. This is an internal stage execution API; the complete counter must derive its constants, padded side and fit premises.
Only the scan and arithmetic/address temporaries change while constructing the table.
Instances For
@[instance_reducible]
instance Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.instDecidableSpreadLocal (i : Fin 128) :
Decidable (SpreadLocal i)
theorem Cslib.Algorithms.WordRAM.ExactTriangle.CountPrime.exec_spreadTable {w k : ℕ} (x : WordRAM.Data 128) (hside : x.regs Reg.paddedSide = 2 ^ k) (h0 : x.regs Reg.zero = 0) (h1 : x.regs Reg.one = 1) (h2 : x.regs Reg.two = 2) (h4 : x.regs Reg.four = 4) (hw : WordRAM.Fits w (x.regs Reg.spread + 4 ^ k + 2 ^ k + 8)) :
∃ (y : WordRAM.Data 128),
WordRAM.ExecWithin w spreadTable x y (11 * (2 ^ k - 1) + 5) ∧ (∀ j < 2 ^ k, y.mem (x.regs Reg.spread + j) = Nat.Morton.spread j) ∧ (∀ (a : ℕ), a < x.regs Reg.spread ∨ x.regs Reg.spread + 2 ^ k ≤ a → y.mem a = x.mem a) ∧ ∀ (i : Fin 128), ¬SpreadLocal i → y.regs i = x.regs i
Construct all 2^k actual spread words in at most 11*(2^k-1)+5 instructions,
preserving the caller memory outside exactly that table.