Guarded parallel comparison for fusion trees #
Each sketch occupies b bits, followed by one guard bit. Multiplication replicates the
query into every field, and subtraction compares all fields without borrowing between fields.
This is the packed comparison step of the fusion node in [FW93], following the
authoritative MIT 6.851 Spring 2021 lecture 12 notes, rather than the accompanying scribe notes:
https://courses.csail.mit.edu/6.851/spring21/lectures/L12.pdf.
Main definitions #
packedNode: guarded sketches, in little-endian field order.queryMultiplier: replicates a query by multiplication.packedDifference: simultaneous guarded subtraction.
Main results #
packedDifference_field: each result field is exactly its guarded scalar difference.packedDifference_guard: the guard is set exactly when the query is at most the sketch.parallelCompare_exec: two actual standard-basis instructions produce the raw comparison.
References #
Multiplying by this constant replicates the query into every field.
Instances For
The node's fields start at bit positions (b + 1) * i.
The replication constant has one bit at the beginning of each field.
Replication is a positional sum, not an extra word-RAM primitive.
The multiplier fits even for zero sketches.
Two fixed standard-basis instructions. Inputs are query in register 0, guarded node in 1, and multiplier in 2. Register 3 receives the replicated query, and 4 the raw guarded result. Precomputing/loading the node and multiplier, and converting the result to a rank, are separate. In particular, this fragment does not assume a unit-cost most-significant-bit operation.
Instances For
The concrete final data, preserving memory and all three input registers.
Instances For
All memory is preserved.
The output register's guards are the simultaneous comparison answers.
Actual checked-overflow execution in exactly two instructions, from arbitrary memory. The total packed width must fit a word; input delivery is the caller's responsibility.