Skip to documentation
SLOP

tiny.pluck.state

Reference tiny.pluck state

Defined in tiny.pluck.

API (25)

Actions

Public operations.

Types and contracts

Public types and contracts.

No direct callersNo direct callstiny.pluckstate
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/pluck/src/state/callstack.zig:6

zig
pub const CallstackKey = struct {    callstack: []const i32,    prob: f64,};

Source: lib/pluck/src/state/machine.zig:198

zig
pub fn checkLimits(state: *LazyKCState) bool {    if (state.stats.limit_reason != null) return true;    if (state.manager.iteLimitExceeded()) {        state.stats.limit_reason = .ite_limit;        return true;    }    if (state.cfg.max_depth) |max| {        if (state.depth > max and !state.cfg.sample_after_max_depth) {            state.stats.limit_reason = .max_depth;            return true;        }    }    if (state.manager.limits.checkTimeLimit()) {        state.stats.limit_reason = .time_limit;        return true;    }    if (state.manager.limits.checkIteLimit(state.manager.num_recursive_calls)) {        state.stats.limit_reason = .ite_limit;        return true;    }    return false;}

Source: lib/pluck/src/state/machine.zig:173

zig
pub fn clearSampledFlips(state: *LazyKCState) void {    var sampled_iter = state.sampled_flips.iterator();    while (sampled_iter.next()) |entry| {        state.allocator.free(entry.key_ptr.callstack);    }    state.sampled_flips.clearRetainingCapacity();}
Called byCallsNo direct callsstatedeinitstateclearSampledFlips
Static calls · unresolved targets: 0 · external targets: 4.

Source: lib/pluck/src/state/machine.zig:268

zig
pub fn currentAddress(state: *LazyKCState, p: f64) !Bdd {    return currentAddressForCallstack(state, state.callstack.items, p);}
Called byCallsNo direct callersstatecurrentAddressForCallstackstatecurrentAddress
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/pluck/src/state/machine.zig:272

zig
pub fn currentAddressForCallstack(state: *LazyKCState, callstack_items: []const i32, p: f64) !Bdd {    const key = StateCallstackKey{        .callstack = callstack_items,        .prob = p,    };    if (state.var_of_callstack.get(key)) |existing| {        return existing;    }    const addr = if (state.cfg.use_strict_order) blk: {        const pos = findInsertPosition(state, key);        const new_var = try state.manager.newVarAtPosition(@intCast(pos), true);        if (state.manager.iteLimitExceeded()) break :blk Bdd.FALSE;        const callstack_copy = try state.allocator.dupe(i32, callstack_items);        const new_key = StateCallstackKey{ .callstack = callstack_copy, .prob = p };        try state.sorted_callstacks.insert(state.allocator, pos, new_key);        break :blk new_var;    } else blk: {        break :blk try state.manager.newVar(true);    };    if (state.manager.iteLimitExceeded()) return Bdd.FALSE;    const callstack_copy = try state.allocator.dupe(i32, callstack_items);    try state.var_of_callstack.put(        state.allocator,        StateCallstackKey{ .callstack = callstack_copy, .prob = p },        addr,    );    try state.wmc_params.setWeight(state.manager.topVar(addr), 1.0 - p, p);    return addr;}
Called byCallsstatecurrentAddressstatefindInsertPositionstatecurrentAddressForCallstack
Static calls · unresolved targets: 2 · external targets: 7.

Source: lib/pluck/src/state/machine.zig:150

zig
pub fn deinit(state: *LazyKCState) void {    state.callstack.deinit(state.allocator);    var iter = state.var_of_callstack.iterator();    while (iter.next()) |entry| {        state.allocator.free(entry.key_ptr.callstack);    }    state.var_of_callstack.deinit(state.allocator);    for (state.sorted_callstacks.items) |key| {        state.allocator.free(key.callstack);    }    state.sorted_callstacks.deinit(state.allocator);    clearSampledFlips(state);    state.sampled_flips.deinit(state.allocator);    state.stacktrace_buf.deinit(state.allocator);    state.wmc_params.deinit();    for (state.deferred_weights.items) |deferred| {        state.allocator.free(deferred.guards);    }    state.deferred_weights.deinit(state.allocator);    state.weight_dd.deinit();    state.def_thunks.deinit(state.allocator);}
Called byCallsprivate sourcelib.accy.src.kernel.program.execution.Cpudeinitprivate sourcelib.accy.src.kernel.program.execution.CpuensureMachineprivate sourcelib.machine.src.checkpoint.roots.testcaptureprivate sourcelib.machine.src.checkpoint.roots.testpublishDeltaChainprivate sourcelib.machine.src.checkpoint.testcaptureAt+45 morestateclearSampledFlipsstatedeinit
Static calls · unresolved targets: 0 · external targets: 12.

Source: lib/pluck/src/state/machine.zig:310

zig
pub fn findInsertPosition(state: *const LazyKCState, key: StateCallstackKey) usize {    const items = state.sorted_callstacks.items;    var left: usize = 0;    var right: usize = items.len;    while (left < right) {        const mid = left + (right - left) / 2;        const cmp = callstack.compareCallstacks(items[mid].callstack, key.callstack);        if (state.cfg.use_reverse_order) {            if (cmp == .gt) {                left = mid + 1;            } else {                right = mid;            }        } else {            if (cmp == .lt) {                left = mid + 1;            } else {                right = mid;            }        }    }    return left;}
Called byCallsstatecurrentAddressForCallstackstatecompareCallstacksstatefindInsertPosition
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/pluck/src/state/machine.zig:92

zig
pub fn init(    allocator: Allocator,    manager: *Manager,    definitions: *const Definitions,    cfg: LazyKCConfig,) LazyKCState {    return initChecked(allocator, manager, definitions, cfg) catch        @panic("LazyKCState.init: out of memory");}
Called byCallsNo direct callersstateinitCheckedstateinit
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/pluck/src/state/machine.zig:102

zig
pub fn initChecked(    allocator: Allocator,    manager: *Manager,    definitions: *const Definitions,    cfg: LazyKCConfig,) !LazyKCState {    const wmc_params = if (cfg.dual)        WmcParams.initDual(allocator, cfg.vector_size)    else        WmcParams.init(allocator);    var weight_dd_state = WeightDD.init(allocator, manager) catch |err| switch (err) {        error.OutOfMemory => return error.OutOfMemory,        error.NaNWeight, error.NonFiniteWeight => unreachable,    };    const weight_one = weight_dd_state.leaf(1.0) catch |err| switch (err) {        error.OutOfMemory => return error.OutOfMemory,        error.NaNWeight, error.NonFiniteWeight => unreachable,    };    const now = time.nanoTimestamp();    return LazyKCState{        .allocator = allocator,        .manager = manager,        .wmc_params = wmc_params,        .weight_dd = weight_dd_state,        .weight_dd_root = weight_one,        .weight_dd_one = weight_one,        .deferred_weights = .empty,        .cfg = cfg,        .stats = LazyKCStats{},        .callstack = .empty,        .var_of_callstack = .empty,        .sorted_callstacks = .empty,        .depth = 0,        .definitions = definitions,        .current_def_name = null,        .stacktrace_buf = .empty,        .query = null,        .next_thunk_id = 0,        .start_time = now,        .registry = null,        .sampled_flips = .{},        .prng = std.Random.DefaultPrng.init(@intCast(@max(0, now))),        .def_thunks = .{},    };}
Called byCallsstateinitbdd.WmcParamsinitbdd.WmcParamsinitDualweight_dd.WeightDDinitweight_dd.WeightDDleafstateinitChecked
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/pluck/src/state/machine.zig:235

zig
pub fn maybeSampleBdd(state: *LazyKCState) void {    const calls = state.stats.num_forward_calls;    if (calls == 0) return;    if (!std.math.isPowerOfTwo(calls)) return;    recordBddSample(state);}
Called byCallsNo direct callersstaterecordBddSamplestatemaybeSampleBdd
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/pluck/src/state/machine.zig:341

zig
pub fn popCallstack(state: *LazyKCState) void {    _ = state.callstack.pop();}

Source: lib/pluck/src/state/machine.zig:337

zig
pub fn pushCallstack(state: *LazyKCState, index: i32) !void {    try state.callstack.append(state.allocator, index);}

Source: lib/pluck/src/state/machine.zig:226

zig
pub fn recordBddSample(state: *LazyKCState) void {    if (@as(usize, state.stats.bdd_samples_len) >= LazyKCStats.MaxBddSamples) return;    const idx: usize = @intCast(state.stats.bdd_samples_len);    state.stats.bdd_samples_forward_calls[idx] = state.stats.num_forward_calls;    state.stats.bdd_samples_vars[idx] = @intCast(state.manager.var_order.items.len);    state.stats.bdd_samples_nodes[idx] = @intCast(state.manager.nodes.items.len);    state.stats.bdd_samples_len += 1;}
Called byCallsNo direct callsstatemaybeSampleBddstaterecordFinalBddSamplestaterecordBddSample
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/pluck/src/state/machine.zig:242

zig
pub fn recordFinalBddSample(state: *LazyKCState) void {    const calls = state.stats.num_forward_calls;    if (calls == 0) return;    if (state.stats.bdd_samples_len > 0) {        const last_idx: usize = @intCast(state.stats.bdd_samples_len - 1);        if (state.stats.bdd_samples_forward_calls[last_idx] == calls) return;    }    recordBddSample(state);}
Called byCallsNo direct callersstaterecordBddSamplestaterecordFinalBddSample
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/pluck/src/state/machine.zig:252

zig
pub fn recordManagerStats(state: *LazyKCState) void {    if (state.stats.limit_reason == null and state.manager.iteLimitExceeded()) {        state.stats.limit_reason = .ite_limit;    }    if (state.stats.limit_reason == null and state.manager.timeLimitExceeded()) {        state.stats.limit_reason = .time_limit;    }    state.stats.num_recursive_calls = state.manager.num_recursive_calls;    state.stats.ite_cache_hits = state.manager.ite_cache_hits;    state.stats.ite_cache_misses = state.manager.ite_cache_misses;    state.stats.unique_table_grows = state.manager.unique_table_grows;    state.stats.ite_cache_grows = state.manager.ite_cache_grows;    state.stats.variable_count = state.manager.var_order.items.len;    state.stats.node_count = state.manager.nodes.items.len;}

Source: lib/pluck/src/state/machine.zig:181

zig
pub fn startTimeLimit(state: *LazyKCState) void {    state.start_time = time.nanoTimestamp();    if (state.cfg.time_limit) |limit| {        state.manager.limits.startTimeLimit(limit);    }    if (state.cfg.ite_limit) |limit| {        state.manager.startIteLimit(limit);    }}

Source: lib/pluck/src/state/machine.zig:191

zig
pub fn stopTimeLimit(state: *LazyKCState) void {    state.manager.limits.stopTimeLimit();    state.manager.stopIteLimit();    const elapsed = time.nanoTimestamp() - state.start_time;    state.stats.time_ns = @intCast(@max(0, elapsed));}

Source: lib/pluck/src/root.zig:23

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

Source: lib/pluck/src/state/root.zig

zig
const config = @import("config.zig");const stats = @import("stats.zig");const callstack = @import("callstack.zig");const machine = @import("machine.zig");pub const LazyKCConfig = config.LazyKCConfig;pub const FallbackMode = config.FallbackMode;pub const InferenceMode = config.InferenceMode;pub const LimitReason = stats.LimitReason;pub const LazyKCStats = stats.LazyKCStats;pub const CallstackKey = callstack.CallstackKey;pub const CallstackHashContext = callstack.CallstackHashContext;pub const compareCallstacks = callstack.compareCallstacks;pub const LazyKCState = machine.LazyKCState;pub const init = machine.init;pub const initChecked = machine.initChecked;pub const deinit = machine.deinit;pub const startTimeLimit = machine.startTimeLimit;pub const stopTimeLimit = machine.stopTimeLimit;pub const checkLimits = machine.checkLimits;pub const recordBddSample = machine.recordBddSample;pub const maybeSampleBdd = machine.maybeSampleBdd;pub const recordFinalBddSample = machine.recordFinalBddSample;pub const recordManagerStats = machine.recordManagerStats;pub const clearSampledFlips = machine.clearSampledFlips;pub const currentAddress = machine.currentAddress;pub const currentAddressForCallstack = machine.currentAddressForCallstack;pub const findInsertPosition = machine.findInsertPosition;pub const pushCallstack = machine.pushCallstack;pub const popCallstack = machine.popCallstack;

Complete caller list for state.deinit

50 direct callers.

Audit

Definitions18
Public names18
Members2
Version26.7.0
Revisiondaab053ee433