Skip to documentation
SLOP

tiny.simd.ShuffledIota

Reference tiny.simd ShuffledIota

Defined in thread.pool.

API (5)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callsthread.poolShuffledIota
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/simd/src/thread/pool.zig:141

zig
pub const ShuffledIota = struct {    coprime: u32 = 1,    pub fn init(coprime: u32) ShuffledIota {        return .{ .coprime = coprime };    }    pub fn next(        self: ShuffledIota,        current: u32,        size: u32,    ) u32 {        std.debug.assert(size != 0);        std.debug.assert(current < size);        return @intCast(            (@as(u64, current) + self.coprime) % @as(u64, size),        );    }    pub fn coprimeNonzero(a_value: u32, b_value: u32) bool {        std.debug.assert(a_value != 0);        std.debug.assert(b_value != 0);        var a = a_value;        var b = b_value;        const trailing_a = @ctz(a);        const trailing_b = @ctz(b);        if (@min(trailing_a, trailing_b) != 0) return false;        a >>= @intCast(trailing_a);        b >>= @intCast(trailing_b);        while (true) {            const previous_a = a;            a = @max(previous_a, b);            b = @min(previous_a, b);            if (b == 1) return true;            a -= b;            if (a == 0) return false;            a >>= @intCast(@ctz(a));        }    }    pub fn findAnotherCoprime(size: u32, start: u32) u32 {        std.debug.assert(size != 0);        if (size <= 2) return 1;        const increment: u32 = if (size & 1 == 0) 2 else 1;        var candidate = start | 1;        var attempts: u64 = 0;        const max_attempts = @as(u64, size) * 16;        while (attempts < max_attempts) : (attempts += 1) {            if (coprimeNonzero(candidate, size)) return candidate;            candidate +%= increment;            if (candidate == 0) candidate = 1;        }        unreachable;    }};

Source: lib/simd/src/root.zig:132

zig
pub const ShuffledIota = thread.ShuffledIota;
Called byCallsNo direct callsShuffledIotafindAnotherCoprimetest sourcelib.simd.src.thread.pooltest: Highway binary coprime agrees f...test sourcelib.simd.src.thread.pooltest: Highway shuffled iota detects c...ShuffledIotacoprimeNonzero
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.simd.src.thread.pool.ThreadPoolconfigureWorkerstest sourcelib.simd.src.thread.pooltest: Highway independent shuffles re...test sourcelib.simd.src.thread.pooltest: Highway shuffled iota detects c...ShuffledIotacoprimeNonzeroShuffledIotafindAnotherCoprime
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.simd.src.thread.pool.ThreadPoolconfigureWorkerstest sourcelib.simd.src.thread.pooltest: Highway shuffled iota detects c...ShuffledIotainit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.simd.src.thread.pool.ThreadPoolconfigureWorkerstest sourcelib.simd.src.thread.pooltest: Highway shuffled iota detects c...ShuffledIotanext
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

thread.ShuffledIota.

Audit

Definitions5
Public names15
Members1
Version26.7.0
Revisiondaab053ee433