Skip to documentation
SLOP

tiny.accy.kernel.library.histogram

Reference tiny.accy kernel library histogram

Defined in kernel.library.

API (28)

Actions

Public operations.

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

No direct callersNo direct callskernel.libraryhistogram
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/accy/src/kernel/library/histogram/family/model.zig:14

zig
pub const Histogram = struct {    bins: u64,    count: u64,    lo: f32 = 0,    width: f32 = 1,    dtype: DType = .f32,    binning: HistogramBinningPolicy = .lower_inclusive_upper_exclusive,    variant: HistogramVariant = .direct,    threads: u32 = 256,    bin_axis: []const u8 = "b",    element_axis: []const u8 = "n",};

Source: lib/accy/src/kernel/library/histogram/family/model.zig:9

zig
pub const HistogramVariant = enum {    direct,    shared_bins,};

Source: lib/accy/src/kernel/library/histogram/family/tuning.zig:16

zig
pub const HistogramResolvedSchedule = struct {    variant: HistogramVariant,    threads: u32,};

Source: lib/accy/src/kernel/library/histogram/family/binning.zig:7

zig
pub const policy_parameter_name = "histogram_binning_policy";

Source: lib/accy/src/kernel/library/histogram/family/model.zig:51

zig
pub fn histogramBinForValue(instance: Histogram, value: f32) ?usize {    return switch (instance.binning) {        .lower_inclusive_upper_exclusive => {            const relative = (value - instance.lo) / instance.width;            const bins_float: f32 = @floatFromInt(instance.bins);            if (!(relative >= 0) or !(relative < bins_float)) return null;            return @intFromFloat(relative);        },    };}

Source: lib/accy/src/kernel/library/histogram/family/model.zig:43

zig
pub fn histogramBinningPolicyCode(policy: HistogramBinningPolicy) u64 {    return binning.code(policy);}
Called byCallskernel.library.histogramhistogramFamilySpecializationtest sourcelib.accy.src.kernel.library.histogram.family....test: histogram identity and validityprivate sourcelib.accy.src.kernel.library.histogram.family....codekernel.library.histogramhistogramBinningPolicyCode
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/model.zig:47

zig
pub fn histogramBinningPolicyFromCode(value: u64) ?HistogramBinningPolicy {    return binning.fromCode(value);}
Called byCallskernel.library.histogramhistogramInstanceFromSpecializationprivate sourcelib.accy.src.kernel.library.histogram.family....fromCodekernel.library.histogramhistogramBinningPolicyFromCode
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/model.zig:31

zig
pub fn histogramDTypeSupported(dtype: DType) bool {    return dtype == .f32;}
Called byCallsNo direct callskernel.library.histogramhistogramInstanceValidkernel.library.histogramhistogramInstanceFromSpecializationkernel.library.histogramhistogramDTypeSupported
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/model.zig:35

zig
pub fn histogramInstanceValid(instance: Histogram) bool {    if (!histogramDTypeSupported(instance.dtype)) return false;    if (instance.bins == 0 or instance.count == 0) return false;    if (!(instance.width > 0)) return false;    if (instance.variant == .shared_bins and instance.bins > histogram_shared_bins_cap) return false;    return instance.threads != 0;}
Called byCallskernel.library.histogramhistogramInstanceFromSpecializationtest sourcelib.accy.src.kernel.library.histogram.family....test: histogram identity and validitykernel.library.histogramhistogramDTypeSupportedkernel.library.histogramhistogramInstanceValid
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/model.zig:27

zig
pub const histogram_family_version: u32 = 2;

Source: lib/accy/src/kernel/library/histogram/family/model.zig:28

zig
pub const histogram_shared_bins_cap: u64 = 4096;

Source: lib/accy/src/kernel/library/histogram/family/naming.zig:22

zig
pub fn histogramFamilyEntryName(allocator: std.mem.Allocator, instance: Histogram) ![]u8 {    return switch (instance.variant) {        .direct => std.fmt.allocPrint(            allocator,            "accy_kernel_histogram_histogram_family_{d}_{s}",            .{ instance.threads, instance.dtype.name() },        ),        .shared_bins => std.fmt.allocPrint(            allocator,            "accy_kernel_histogram_histogram_family_shared{d}_{d}_{s}",            .{ instance.bins, instance.threads, instance.dtype.name() },        ),    };}

Source: lib/accy/src/kernel/library/histogram/family/naming.zig:7

zig
pub fn histogramFamilyTarget(allocator: std.mem.Allocator, instance: Histogram) ![]u8 {    return switch (instance.variant) {        .direct => std.fmt.allocPrint(            allocator,            "accy.kernel.histogram.histogram_family_{d}_{s}",            .{ instance.threads, instance.dtype.name() },        ),        .shared_bins => std.fmt.allocPrint(            allocator,            "accy.kernel.histogram.histogram_family_shared{d}_{d}_{s}",            .{ instance.bins, instance.threads, instance.dtype.name() },        ),    };}
Called byCallsNo direct callstest sourcelib.accy.src.kernel.library.histogram.family....test: histogram identity and validitykernel.library.histogramresolveHistogramScheduletest sourcelib.accy.src.kernel.library.histogram.family....test: histogram tuning resolves sched...kernel.library.histogramhistogramFamilyTarget
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/accy/src/kernel/library/histogram/family/runtime/arguments.zig:9

zig
pub fn histogramRuntimeArguments(instance: Histogram) ![4]choir_abi.ScalarArgument {    return .{        .{ .u32 = try runtimeExtentArgument(instance.bins) },        .{ .u32 = try runtimeExtentArgument(instance.count) },        .{ .f32 = instance.lo },        .{ .f32 = instance.width },    };}
Called byCallsNo direct callersprivate sourcelib.accy.src.kernel.library.histogram.family....runtimeExtentArgumentkernel.library.histogramhistogramRuntimeArguments
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/runtime/artifact.zig:13

zig
pub fn createHistogramFamilyArtifact(    allocator: std.mem.Allocator,    handle: kernel.BackendHandle,    instance: Histogram,    options: entry.ArtifactOptions,) !kernel.OwnedKernelCallArtifact {    if (!family.histogramInstanceValid(instance)) return error.InvalidKernelLibraryEntry;    const target = try family.histogramFamilyTarget(allocator, instance);    defer allocator.free(target);    const entry_name = try family.histogramFamilyEntryName(allocator, instance);    defer allocator.free(entry_name);    const family_fingerprint = options.shape_family_fingerprint orelse try family.histogramFamilyFingerprint(allocator, instance);    const shape_profile_dimensions = family.histogramShapeProfileDimensions(instance);    const shape_profile = options.shape_profile orelse artifact_product.KernelCallShapeProfile{        .name = "histogram",        .fingerprint = family_fingerprint,        .dimensions = shape_profile_dimensions[0..],    };    var graph = switch (instance.dtype) {        .f32 => try body.HistogramRuntimeFamilyF32.buildNamed(allocator, options.limits, entry_name, instance),        else => return error.UnsupportedDType,    };    defer graph.deinit();    return kernel.createKernelCallArtifact(allocator, handle, &graph, .{        .target = target,        .version = family.histogram_family_version,        .format = options.format,        .kernel_plan = options.kernel_plan,        .element_count_argument = options.element_count_argument,        .shape_family_fingerprint = family_fingerprint,        .shape_profile = shape_profile,        .launch = options.launch orelse try histogramDerivedLaunch(instance),        .runtime_scalar_argument_count = if (options.runtime_scalar_argument_count == 0) 4 else options.runtime_scalar_argument_count,        .static_arguments = options.static_arguments,    });}
Called byCallsNo direct callersprivate sourcelib.accy.src.kernel.library.histogram.family....histogramDerivedLaunchtiny.smggraphdeinitkernel.library.histogramcreateHistogramFamilyArtifact
Static calls · unresolved targets: 0 · external targets: 8.

Source: lib/accy/src/kernel/library/histogram/family/runtime/body.zig:163

zig
pub const HistogramRuntimeFamilyF32 = histogramRuntimeFamily(.f32);

Source: lib/accy/src/kernel/library/histogram/family/shape.zig:33

zig
pub fn histogramFamilyFingerprint(backing_allocator: std.mem.Allocator, instance: Histogram) !u64 {    var family = try histogramShapeFamily(backing_allocator, instance);    defer family.deinit();    return shape.fingerprint(family);}
Called byCallskernel.library.histogramhistogramFamilyTuningKeyprivate; no linklib.accy.src.choir.shapefingerprintkernel.library.histogramhistogramShapeFamilykernel.library.histogramhistogramFamilyFingerprint
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/accy/src/kernel/library/histogram/family/shape.zig:12

zig
pub fn histogramShapeFamily(backing_allocator: std.mem.Allocator, instance: Histogram) !shape.Family {    var builder = try shape.Builder.init(backing_allocator, "histogram");    errdefer builder.deinit();    const bin = try builder.symbol(instance.bin_axis);    const element = try builder.symbol(instance.element_axis);    const bin_expr = try builder.symbolExpression(bin);    const element_expr = try builder.symbolExpression(element);    _ = try builder.tensor("dst", &.{bin_expr});    _ = try builder.tensor("data", &.{element_expr});    try builder.assumeBounds(bin_expr, histogramRuntimeExtentBounds());    try builder.assumeBounds(element_expr, histogramRuntimeExtentBounds());    return builder.finish();}
Called byCallskernel.library.histogramhistogramFamilyFingerprintkernel.library.histogramhistogramFamilySpecializationprivate sourcelib.accy.src.kernel.library.histogram.family....histogramRuntimeExtentBoundskernel.library.histogramhistogramShapeFamily
Static calls · unresolved targets: 0 · external targets: 7.

Source: lib/accy/src/kernel/library/histogram/family/shape.zig:39

zig
pub fn histogramShapeProfileDimensions(instance: Histogram) [2]artifact.KernelCallShapeProfileDimension {    const bounds = histogramRuntimeExtentBounds();    return .{        .{ .name = instance.bin_axis, .runtime_scalar_argument_index = 0, .bounds = bounds },        .{ .name = instance.element_axis, .runtime_scalar_argument_index = 1, .bounds = bounds },    };}
Called byCallsNo direct callersprivate sourcelib.accy.src.kernel.library.histogram.family....histogramRuntimeExtentBoundskernel.library.histogramhistogramShapeProfileDimensions
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/specialization.zig:12

zig
pub fn histogramFamilySpecialization(backing_allocator: std.mem.Allocator, instance: Histogram) !entry.OwnedSpecialization {    var owned = entry.OwnedSpecialization.init(backing_allocator);    errdefer owned.deinit();    const lifetime_allocator = owned.allocator();    const inputs = try lifetime_allocator.alloc(entry.Shape, 1);    inputs[0] = try entry.runtimeShape1D(lifetime_allocator, instance.element_axis, instance.count);    const outputs = try lifetime_allocator.alloc(entry.Shape, 1);    outputs[0] = try entry.runtimeShape1D(lifetime_allocator, instance.bin_axis, instance.bins);    const static_parameters = try lifetime_allocator.alloc(entry.StaticParameter, 1);    static_parameters[0] = try entry.runtimeStaticParameter(        lifetime_allocator,        model.histogram_binning_policy_parameter,        model.histogramBinningPolicyCode(instance.binning),    );    owned.value = .{        .dtype = instance.dtype,        .operation = .{ .indexing = .histogram },        .inputs = inputs,        .outputs = outputs,        .static_parameters = static_parameters,        .schedule = try entry.runtimeThreadBlocks1D(lifetime_allocator, instance.element_axis, instance.count, instance.threads),        .structure = @tagName(instance.variant),    };    owned.value.launch = owned.value.schedule.?.launch();    var family = try shape.histogramShapeFamily(backing_allocator, instance);    errdefer family.deinit();    try owned.takeShapeFamily(&family);    return owned;}
Called byCallstest sourcelib.accy.src.kernel.library.histogram.family....test: histogram instance round-trips ...test sourcelib.accy.src.kernel.library.histogram.family....test: histogram identity and validitykernel.library.OwnedSpecializationallocatorkernel.library.OwnedSpecializationdeinitkernel.library.OwnedSpecializationinitkernel.library.OwnedSpecializationtakeShapeFamilykernel.library.entryruntimeShape1D+4 morekernel.library.histogramhistogramFamilySpecialization
Static calls · unresolved targets: 0 · external targets: 2.

Source: lib/accy/src/kernel/library/histogram/family/specialization.zig:46

zig
pub fn histogramInstanceFromSpecialization(specialization: entry.Specialization) ?Histogram {    if (!specialization.scheduleMatchesLaunch()) return null;    if (!specialization.operationIs(.{ .indexing = .histogram })) return null;    const dtype = specialization.dtype orelse return null;    if (!model.histogramDTypeSupported(dtype)) return null;    if (specialization.inputs.len != 1 or specialization.outputs.len != 1) return null;    if (specialization.reductions.len != 0) return null;    if (specialization.static_parameters.len != 1) return null;    const binning = model.histogramBinningPolicyFromCode(        specialization.staticParameterValue(model.histogram_binning_policy_parameter) orelse return null,    ) orelse return null;    const data = specialization.inputs[0];    const bins_shape = specialization.outputs[0];    if (data.axes.len != 1 or bins_shape.axes.len != 1) return null;    const launch = specialization.launch orelse return null;    if (launch.threadgroup[0] == 0) return null;    const structure = specialization.structure orelse return null;    const variant = std.meta.stringToEnum(HistogramVariant, structure) orelse return null;    const instance = Histogram{        .bins = bins_shape.axes[0].extent,        .count = data.axes[0].extent,        .dtype = dtype,        .binning = binning,        .variant = variant,        .threads = launch.threadgroup[0],        .bin_axis = bins_shape.axes[0].name,        .element_axis = data.axes[0].name,    };    if (!model.histogramInstanceValid(instance)) return null;    return instance;}
Called byCallstest sourcelib.accy.src.kernel.library.histogram.family....test: histogram instance round-trips ...kernel.library.histogramhistogramBinningPolicyFromCodekernel.library.histogramhistogramDTypeSupportedkernel.library.histogramhistogramInstanceValidkernel.library.histogramhistogramInstanceFromSpecialization
Static calls · unresolved targets: 0 · external targets: 3.

Source: lib/accy/src/kernel/library/histogram/family/tuning.zig:30

zig
pub fn histogramFamilyTuningKey(    backing_allocator: std.mem.Allocator,    device_fingerprint: u64,    instance: Histogram,) !tuning.FamilyTuningKey {    const family_fingerprint = try shape.histogramFamilyFingerprint(backing_allocator, instance);    const extents = histogramTuningExtents(instance);    return tuning.FamilyTuningKey.init(        device_fingerprint,        family_fingerprint,        entry.operationFingerprint(histogramTuningOperation(instance)),        instance.dtype,        model.histogram_family_version,        extents[0..],    ) orelse unreachable;}
Called byCallskernel.library.histogramresolveHistogramScheduletest sourcelib.accy.src.kernel.library.histogram.family....test: histogram tuning resolves sched...kernel.library.entryoperationFingerprintkernel.library.histogramhistogramFamilyFingerprintkernel.library.histogramhistogramTuningExtentskernel.library.histogramhistogramTuningOperationkernel.library.tuning.FamilyTuningKeyinitkernel.library.histogramhistogramFamilyTuningKey
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/tuning.zig:76

zig
pub fn histogramThreadCandidatesForCount(count: u64) geometry.Thread1DCandidates {    return geometry.threadCandidatesForExtent(count, histogram_thread_caps);}
Called byCallskernel.library.histogramresolveHistogramScheduletest sourcelib.accy.src.kernel.library.histogram.family....test: histogram tuning resolves sched...kernel.library.geometrythreadCandidatesForExtentkernel.library.histogramhistogramThreadCandidatesForCount
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/tuning.zig:72

zig
pub fn histogramThreadsForCount(count: u64) u32 {    return geometry.threadsForExtent(count, histogram_thread_caps);}
Called byCallsNo direct callerskernel.library.geometrythreadsForExtentkernel.library.histogramhistogramThreadsForCount
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/tuning.zig:21

zig
pub fn histogramTuningExtents(instance: Histogram) [2]u64 {    return .{ instance.bins, instance.count };}
Called byCallsNo direct callskernel.library.histogramhistogramFamilyTuningKeykernel.library.histogramhistogramTuningExtents
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/tuning.zig:25

zig
pub fn histogramTuningOperation(instance: Histogram) entry.Operation {    _ = instance;    return .{ .indexing = .histogram };}
Called byCallsNo direct callskernel.library.histogramhistogramFamilyTuningKeykernel.library.histogramhistogramTuningOperation
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/histogram/family/tuning.zig:47

zig
pub fn resolveHistogramSchedule(    backing_allocator: std.mem.Allocator,    reader: tuning.FamilyTuningReader,    instance: Histogram,) !?HistogramResolvedSchedule {    const key = try histogramFamilyTuningKey(backing_allocator, reader.device_fingerprint, instance);    const record = reader.table.find(key) orelse return null;    const thread_candidates = histogramThreadCandidatesForCount(instance.count);    const variants = [_]HistogramVariant{ .direct, .shared_bins };    for (variants) |variant| {        for (thread_candidates.slice()) |threads| {            var candidate = instance;            candidate.variant = variant;            candidate.threads = threads;            if (variant == .shared_bins and candidate.bins > model.histogram_shared_bins_cap) continue;            const target = try naming.histogramFamilyTarget(backing_allocator, candidate);            defer backing_allocator.free(target);            if (std.mem.eql(u8, target, record.target)) {                return .{ .variant = variant, .threads = threads };            }        }    }    return null;}
Called byCallstest sourcelib.accy.src.kernel.library.histogram.family....test: histogram tuning resolves sched...kernel.library.histogramhistogramFamilyTargetkernel.library.histogramhistogramFamilyTuningKeykernel.library.histogramhistogramThreadCandidatesForCountkernel.library.histogramresolveHistogramSchedule
Static calls · unresolved targets: 0 · external targets: 3.

Source: lib/accy/src/kernel/library/histogram/family/root.zig

zig
const model = @import("model.zig");const naming = @import("naming.zig");const tuning = @import("tuning.zig");const runtime = @import("runtime/root.zig");const shape = @import("shape.zig");const specialization = @import("specialization.zig");pub const HistogramBinningPolicy = model.HistogramBinningPolicy;pub const HistogramVariant = model.HistogramVariant;pub const Histogram = model.Histogram;pub const histogram_family_version = model.histogram_family_version;pub const histogram_shared_bins_cap = model.histogram_shared_bins_cap;pub const histogram_binning_policy_parameter = model.histogram_binning_policy_parameter;pub const histogramDTypeSupported = model.histogramDTypeSupported;pub const histogramInstanceValid = model.histogramInstanceValid;pub const histogramBinningPolicyCode = model.histogramBinningPolicyCode;pub const histogramBinningPolicyFromCode = model.histogramBinningPolicyFromCode;pub const histogramBinForValue = model.histogramBinForValue;pub const histogramFamilyTarget = naming.histogramFamilyTarget;pub const histogramFamilyEntryName = naming.histogramFamilyEntryName;pub const HistogramResolvedSchedule = tuning.HistogramResolvedSchedule;pub const histogramTuningExtents = tuning.histogramTuningExtents;pub const histogramTuningOperation = tuning.histogramTuningOperation;pub const histogramFamilyTuningKey = tuning.histogramFamilyTuningKey;pub const resolveHistogramSchedule = tuning.resolveHistogramSchedule;pub const histogramThreadsForCount = tuning.histogramThreadsForCount;pub const histogramThreadCandidatesForCount = tuning.histogramThreadCandidatesForCount;pub const histogramRuntimeArguments = runtime.histogramRuntimeArguments;pub const HistogramRuntimeFamilyF32 = runtime.HistogramRuntimeFamilyF32;pub const createHistogramFamilyArtifact = runtime.createHistogramFamilyArtifact;pub const histogramShapeFamily = shape.histogramShapeFamily;pub const histogramFamilyFingerprint = shape.histogramFamilyFingerprint;pub const histogramShapeProfileDimensions = shape.histogramShapeProfileDimensions;pub const histogramFamilySpecialization = specialization.histogramFamilySpecialization;pub const histogramInstanceFromSpecialization = specialization.histogramInstanceFromSpecialization;

Source: lib/accy/src/kernel/library/root.zig:9

zig
pub const histogram = @import("histogram/family/root.zig");

Complete call list for kernel.library.histogram.histogramFamilySpecialization

9 direct calls.

Audit

Definitions28
Public names28
Members14
Version26.7.0
Revisiondaab053ee433