Skip to documentation
SLOP

tiny.accy.kernel.library.extent

Reference tiny.accy kernel library extent

Defined in kernel.library.

API (5)

Actions

Public operations.

Values and defaults

Public values and defaults.

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

Source

Called byCallsNo direct callstest sourcelib.accy.src.kernel.library.extenttest: block count limit rejects overs...kernel.library.extentblockCountWithinLimit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.accy.src.kernel.library.compactionfilterBodykernel.library.extentindexProducttest sourcelib.accy.src.kernel.library.extenttest: index extent accepts the full u...private sourcelib.accy.src.kernel.library.indexinggather body eachprivate sourcelib.accy.src.kernel.library.indexingscatter body each+14 morekernel.library.extentindexExtent
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.accy.src.kernel.library.extenttest: index product checks overflow b...kernel.library.linalgbatchedMatrixProductCellSumkernel.library.linalgbatchedMatrixProductOutputIndexkernel.library.extentindexExtentkernel.library.extentindexProduct
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.accy.src.kernel.library.extenttest: runtime extent argument bounds ...kernel.library.extentruntimeExtentArgument
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/kernel/library/extent.zig

zig
const std = @import("std");pub const runtime_extent_max: u64 = @as(u64, @intCast(std.math.maxInt(i32)));pub fn indexExtent(extent: u64) !i64 {    return std.math.cast(i64, extent) orelse error.ExtentOverflowsIndexRange;}pub fn indexProduct(lhs: u64, rhs: u64) !i64 {    const product = std.math.mul(u64, lhs, rhs) catch return error.ExtentOverflowsIndexRange;    return indexExtent(product);}pub fn runtimeExtentArgument(extent: u64) !u32 {    if (extent == 0 or extent > runtime_extent_max) return error.ExtentOverflowsIndexRange;    return @intCast(extent);}pub fn blockCountWithinLimit(extent: u64, threads: u32, max_blocks: u32) bool {    if (threads == 0) return false;    return extent <= @as(u64, threads) * max_blocks;}const testing = std.testing;test "index extent accepts the full unsigned index range" {    try testing.expectEqual(@as(i64, 0), try indexExtent(0));    try testing.expectEqual(@as(i64, std.math.maxInt(i64)), try indexExtent(@as(u64, @intCast(std.math.maxInt(i64)))));    try testing.expectError(error.ExtentOverflowsIndexRange, indexExtent(@as(u64, @intCast(std.math.maxInt(i64))) + 1));}test "index product checks overflow before conversion" {    try testing.expectEqual(@as(i64, 12), try indexProduct(3, 4));    try testing.expectError(error.ExtentOverflowsIndexRange, indexProduct(std.math.maxInt(u64), 2));}test "runtime extent argument bounds to nonzero i32 range" {    try testing.expectEqual(@as(u32, 1), try runtimeExtentArgument(1));    try testing.expectEqual(@as(u32, @intCast(runtime_extent_max)), try runtimeExtentArgument(runtime_extent_max));    try testing.expectError(error.ExtentOverflowsIndexRange, runtimeExtentArgument(0));    try testing.expectError(error.ExtentOverflowsIndexRange, runtimeExtentArgument(runtime_extent_max + 1));}test "block count limit rejects oversized extents without overflowing" {    try testing.expect(blockCountWithinLimit(1, 32, 4));    try testing.expect(blockCountWithinLimit(128, 32, 4));    try testing.expect(!blockCountWithinLimit(129, 32, 4));    try testing.expect(!blockCountWithinLimit(std.math.maxInt(u64), 32, 1024));    try testing.expect(!blockCountWithinLimit(1, 0, 1024));}

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

zig
pub const extent = @import("extent.zig");

Also reachable as

kernel.library.random.base.extent_mod.

Complete caller list for kernel.library.extent.indexExtent

19 direct callers.

Audit

Definitions6
Public names14
Members0
Version26.7.0
Revisiondaab053ee433