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

Commit 3663870

Browse files
authoredMar 11, 2024··
Export delta functions (#8)
1 parent 4d44d0e commit 3663870

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
 

‎src/lib.zig

+46
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22
const fl = @import("./fastlanez.zig");
33
const std = @import("std");
44

5+
// Transpose
6+
comptime {
7+
for (.{ u8, u16, u32, u64 }) |E| {
8+
const FL = fl.FastLanez(E);
9+
const Wrapper = struct {
10+
fn transpose(in: *const FL.Vector, out: *FL.Vector) callconv(.C) void {
11+
// TODO(ngates): check the performance of this. We may want tranpose to operate on pointers.
12+
out.* = FL.transpose(in.*);
13+
}
14+
15+
fn untranspose(in: *const FL.Vector, out: *FL.Vector) callconv(.C) void {
16+
out.* = FL.untranspose(in.*);
17+
}
18+
};
19+
@export(Wrapper.transpose, .{ .name = "fl_transpose_" ++ @typeName(E) });
20+
@export(Wrapper.untranspose, .{ .name = "fl_untranspose_" ++ @typeName(E) });
21+
}
22+
}
23+
524
// BitPacking
625
comptime {
726
const BitPacking = @import("./bitpacking.zig").BitPacking;
@@ -21,3 +40,30 @@ comptime {
2140
}
2241
}
2342
}
43+
44+
// Delta
45+
comptime {
46+
const Delta = @import("./delta.zig").Delta;
47+
for (.{ u8, i8, u16, i16, u32, i32, u64, i64 }) |E| {
48+
const FL = fl.FastLanez(E);
49+
const D = Delta(FL);
50+
51+
const Wrapper = struct {
52+
fn encode(
53+
in: *const FL.Vector,
54+
base: *FL.BaseVector,
55+
out: *FL.Vector,
56+
) callconv(.C) void {
57+
D.encode(base, in, out);
58+
FL.store(base, 0, FL.load(out, FL.T - 1));
59+
}
60+
61+
fn decode(base: *const FL.BaseVector, in: *const FL.Vector, out: *FL.Vector) callconv(.C) void {
62+
D.decode(base, in, out);
63+
}
64+
};
65+
66+
@export(Wrapper.encode, .{ .name = "fl_delta_encode_" ++ @typeName(E) });
67+
@export(Wrapper.decode, .{ .name = "fl_delta_decode_" ++ @typeName(E) });
68+
}
69+
}

0 commit comments

Comments
 (0)
This repository has been archived.