Skip to content

Commit

Permalink
Add comment to the SIMD intersection logic. (#14073)
Browse files Browse the repository at this point in the history
I did not know it when I checked in the code, but this is almost exactly the v1
intersection algorithm from the "SIMD compression and the intersection of
sorted integers" paper.
  • Loading branch information
jpountz authored Dec 23, 2024
1 parent 8c7050b commit 42c4c11
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,10 @@ private static int squareDistanceBody128(MemorySegment a, MemorySegment b, int l
@Override
public int findNextGEQ(int[] buffer, int target, int from, int to) {
if (ENABLE_FIND_NEXT_GEQ_VECTOR_OPTO) {
// This effectively implements the V1 intersection algorithm from
// D. Lemire, L. Boytsov, N. Kurz SIMD Compression and the Intersection of Sorted Integers
// with T = INT_SPECIES.length(), ie. T=8 with AVX2 and T=16 with AVX-512
// https://arxiv.org/pdf/1401.6399
for (; from + INT_SPECIES.length() < to; from += INT_SPECIES.length() + 1) {
if (buffer[from + INT_SPECIES.length()] >= target) {
IntVector vector = IntVector.fromArray(INT_SPECIES, buffer, from);
Expand Down

0 comments on commit 42c4c11

Please sign in to comment.