tiny.accy.kernel.library.extent
Defined in kernel.library.
API (5)
Actions
Public operations.
Values and defaults
Public values and defaults.
Source
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.
lib.accy.src.kernel.library.compaction.filterBody[function] — private source atlib/accy/src/kernel/library/compaction.zig:243in nearest public ownertiny.accy.kernel.library.compactiontiny.accy.kernel.library.extent.indexProduct[function] atlib/accy/src/kernel/library/extent.zig:9lib.accy.src.kernel.library.extent.test_index_extent_accepts_the_full_unsigned_index_range[function] — test source atlib/accy/src/kernel/library/extent.zig:26in nearest public ownertiny.accy.kernel.library.extentlib.accy.src.kernel.library.indexing.gather_body_each[function] — private source atlib/accy/src/kernel/library/indexing.zig:77in nearest public ownertiny.accy.kernel.library.indexinglib.accy.src.kernel.library.indexing.scatter_body_each[function] — private source atlib/accy/src/kernel/library/indexing.zig:700in nearest public ownertiny.accy.kernel.library.indexingtiny.accy.kernel.library.linalg.batchedMatrixProductCellSum[function] atlib/accy/src/kernel/library/linalg.zig:238tiny.accy.kernel.library.linalg.batchedMatrixProductOutputIndex[function] atlib/accy/src/kernel/library/linalg.zig:261tiny.accy.kernel.library.linalg.matrixProductCellSum[function] atlib/accy/src/kernel/library/linalg.zig:169tiny.accy.kernel.library.linalg.matrixProductOutputIndex[function] atlib/accy/src/kernel/library/linalg.zig:202tiny.accy.kernel.library.linalg.matrixVectorProductRowSum[function] atlib/accy/src/kernel/library/linalg.zig:301tiny.accy.kernel.library.linalg.outerProductOutputIndex[function] atlib/accy/src/kernel/library/linalg.zig:208lib.accy.src.kernel.library.random.philox.static.philox_body_each[function] — private source atlib/accy/src/kernel/library/random/philox/static.zig:20in nearest public ownerlib.accy.src.kernel.library.random.philox.staticlib.accy.src.kernel.library.random.threefry.static.threefry_body_each[function] — private source atlib/accy/src/kernel/library/random/threefry/static.zig:20in nearest public ownerlib.accy.src.kernel.library.random.threefry.staticlib.accy.src.kernel.library.scan.prefixSumBody[function] — private source atlib/accy/src/kernel/library/scan.zig:193in nearest public ownertiny.accy.kernel.library.scanlib.accy.src.kernel.library.segmented.segment_sum_body_each[function] — private source atlib/accy/src/kernel/library/segmented.zig:167in nearest public ownertiny.accy.kernel.library.segmentedtiny.accy.kernel.library.stencil.windowCellSum[function] atlib/accy/src/kernel/library/stencil.zig:89lib.accy.src.kernel.library.stencil.windowRuntimeBody[function] — private source atlib/accy/src/kernel/library/stencil.zig:170in nearest public ownertiny.accy.kernel.library.stenciltiny.accy.kernel.library.stencil.windowShapeFamily[function] atlib/accy/src/kernel/library/stencil.zig:380lib.accy.src.kernel.library.stencil.window_body_each[function] — private source atlib/accy/src/kernel/library/stencil.zig:122in nearest public ownertiny.accy.kernel.library.stencil
Audit
| Definitions | 6 |
|---|---|
| Public names | 14 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |