CSR graph representation, scratch layout, and word-RAM CSR primitives #
Register allocation (Reg), scratch memory layout (kOffAddr..kTopAddr), compressed sparse
row predicates (csrOffset, CSRAt, PartialCSRAt), and shared array/CSR subroutines
(zeroBlockCode, incCurCode, prefixSumCode, backfillStepCode).
Shared with CslibFrontier.Algorithms.WordRAM.TwoSAT.
Registers and scratch memory layout #
Constant 3 (words per DFS stack frame).
Base address of the CSR offset array being traversed.
Base address of the CSR edge array being traversed.
Base address of the visited-flag array.
Base address of the finishing-order output array.
Base address of the explicit DFS stack.
Base address of the transpose fill cursors.
Base address of the transpose CSR offset array.
Base address of the transpose CSR edge array.
Base address of the forward finishing order.
Base address of the component-index array.
Stack depth or inner loop counter.
Number of finished vertices.
Current component index.
Finished count before the current root.
Current edge position.
End of the current edge range.
Address scratch register.
Output-list header register (end-to-end programs).
Address of the forward CSR offset array in the scratch layout based at wb.
Address of the forward CSR edge array.
Address of the transpose CSR offset array.
Address of the transpose CSR edge array.
Address of the transpose fill cursors.
Address of the forward finishing order.
Address of the second-pass finishing order.
Address of the explicit DFS stack (3 words per frame).
Address of the component-index array.
First address past the scratch layout.
Reusable CSR representation and shared array/CSR primitives #
Zero [baseReg, baseReg + nVerts) in 4 * N + 4 instructions via Cslib.WordRAM.zeroFill.
zeroBlockCode baseReg does not read the word width.
zeroBlockCode baseReg is rand-free.
Increment mem[curB + vReg] by 1 in 4 instructions.
incCurCode does not read the word width.
incCurCode is rand-free.
Prefix sums turning out-degrees at offB into CSR offsets and fill cursors.
prefixSumCode does not read the word width.
prefixSumCode is rand-free.
Decrement curB[vReg] and write uReg into edgeB[curB[vReg]] in 6 instructions.
backfillStepCode does not read the word width.