Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Export delta functions (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatesn authored Mar 11, 2024
1 parent 4d44d0e commit 3663870
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
const fl = @import("./fastlanez.zig");
const std = @import("std");

// Transpose
comptime {
for (.{ u8, u16, u32, u64 }) |E| {
const FL = fl.FastLanez(E);
const Wrapper = struct {
fn transpose(in: *const FL.Vector, out: *FL.Vector) callconv(.C) void {
// TODO(ngates): check the performance of this. We may want tranpose to operate on pointers.
out.* = FL.transpose(in.*);
}

fn untranspose(in: *const FL.Vector, out: *FL.Vector) callconv(.C) void {
out.* = FL.untranspose(in.*);
}
};
@export(Wrapper.transpose, .{ .name = "fl_transpose_" ++ @typeName(E) });
@export(Wrapper.untranspose, .{ .name = "fl_untranspose_" ++ @typeName(E) });
}
}

// BitPacking
comptime {
const BitPacking = @import("./bitpacking.zig").BitPacking;
Expand All @@ -21,3 +40,30 @@ comptime {
}
}
}

// Delta
comptime {
const Delta = @import("./delta.zig").Delta;
for (.{ u8, i8, u16, i16, u32, i32, u64, i64 }) |E| {
const FL = fl.FastLanez(E);
const D = Delta(FL);

const Wrapper = struct {
fn encode(
in: *const FL.Vector,
base: *FL.BaseVector,
out: *FL.Vector,
) callconv(.C) void {
D.encode(base, in, out);
FL.store(base, 0, FL.load(out, FL.T - 1));
}

fn decode(base: *const FL.BaseVector, in: *const FL.Vector, out: *FL.Vector) callconv(.C) void {
D.decode(base, in, out);
}
};

@export(Wrapper.encode, .{ .name = "fl_delta_encode_" ++ @typeName(E) });
@export(Wrapper.decode, .{ .name = "fl_delta_decode_" ++ @typeName(E) });
}
}

0 comments on commit 3663870

Please sign in to comment.