lib/accy/src/kernel/library/random/feistel/profile.zig
daab053ee43316e1809a84551d573ddd1e5bf3d2
1 const choir_abi = @import("choir_abi");
2 const random = @import("../root.zig");
3 const types = @import("types.zig");
4
5 const base = random.base;
6
7 const std = base.std;
8 const artifact_product = base.artifact_product;
9 const shape = base.shape;
10 const runtimeExtentArgument = base.runtimeExtentArgument;
11 const randomRuntimeExtentBounds = base.randomRuntimeExtentBounds;
12 const randomShapeFamily = base.randomShapeFamily;
13
14 const Feistel = types.Feistel;
15
16 pub fn feistelRuntimeArguments(instance: Feistel) ![3]choir_abi.ScalarArgument {
17 return .{
18 .{ .u32 = try runtimeExtentArgument(instance.count) },
19 .{ .u32 = instance.seedLo() },
20 .{ .u32 = instance.seedHi() },
21 };
22 }
23
24 pub fn feistelShapeProfileDimensions(instance: Feistel) [1]artifact_product.KernelCallShapeProfileDimension {
25 return .{
26 .{ .name = instance.count_axis, .runtime_scalar_argument_index = 0, .bounds = randomRuntimeExtentBounds() },
27 };
28 }
29
30 pub fn feistelFamilyFingerprint(backing_allocator: std.mem.Allocator, instance: Feistel) !u64 {
31 var family = try feistelShapeFamily(backing_allocator, instance);
32 defer family.deinit();
33 return shape.fingerprint(family);
34 }
35
36 pub fn feistelShapeFamily(backing_allocator: std.mem.Allocator, instance: Feistel) !shape.Family {
37 return randomShapeFamily(backing_allocator, "feistel", instance.count_axis);
38 }