From b7f42a5bb50c421fd4c47a73b730c6083e2fd823 Mon Sep 17 00:00:00 2001 From: Nicholas Gates Date: Tue, 19 Mar 2024 10:56:51 +0000 Subject: [PATCH] More BitPacking fixes --- src/bitpacking.zig | 4 ++-- src/fastlanez.zig | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bitpacking.zig b/src/bitpacking.zig index f38225e..ed698e3 100644 --- a/src/bitpacking.zig +++ b/src/bitpacking.zig @@ -60,11 +60,11 @@ test "bitpack range" { const fl = @import("./fastlanez.zig"); const BP = BitPacking(fl.FastLanez(u8)); - const W = 3; + const W = 6; var ints: [1024]u8 = undefined; for (0..1024) |i| { - ints[i] = @intCast(i % 7); + ints[i] = @intCast(i % std.math.maxInt(std.meta.Int(.unsigned, W))); } var packed_ints: [128 * W]u8 = undefined; diff --git a/src/fastlanez.zig b/src/fastlanez.zig index 6620901..7fdf27d 100644 --- a/src/fastlanez.zig +++ b/src/fastlanez.zig @@ -185,8 +185,8 @@ pub fn FastLanez(comptime Element: type) type { self.t += 1; var tmp: MM1024 = undefined; - if (self.input_idx == 0) { - tmp = load(input, 0); + if (self.bit_idx % T == 0) { + tmp = load(input, self.input_idx); self.input_idx += 1; } else { tmp = state; @@ -197,7 +197,7 @@ pub fn FastLanez(comptime Element: type) type { var next: MM1024 = and_rshift(tmp, shift_bits, bitmask(mask_bits)); - if (mask_bits != Width and self.input_idx < Width) { + if (mask_bits != Width) { tmp = load(input, self.input_idx); self.input_idx += 1;