tiny.simd.IndexRangePartition
Defined in thread.ranges.
API (11)
Actions
Public operations.
Fields and members
Public fields and members.
Source
Source: lib/simd/src/thread/range.zig:39
zig
pub const IndexRangePartition = struct { range: IndexRange, task_size: u32, task_count: u32, pub fn single( task_size: usize, ) error{ EmptyTask, TaskTooLarge }!IndexRangePartition { if (task_size == 0) return error.EmptyTask; if (task_size > std.math.maxInt(u32)) return error.TaskTooLarge; return .{ .range = .{ .begin = 0, .end = task_size }, .task_size = @intCast(task_size), .task_count = 1, }; } pub fn init( range: IndexRange, task_size: usize, ) error{ InvalidRange, EmptyTask, RangeTooLarge, TaskTooLarge }!IndexRangePartition { if (range.begin >= range.end) return error.InvalidRange; if (task_size == 0) return error.EmptyTask; if (range.count() > std.math.maxInt(u32)) return error.RangeTooLarge; if (task_size > std.math.maxInt(u32)) return error.TaskTooLarge; const task_count = std.math.divCeil( u32, @intCast(range.count()), @intCast(task_size), ) catch unreachable; std.debug.assert(task_count != 0); return .{ .range = range, .task_size = @intCast(task_size), .task_count = task_count, }; } pub fn taskSize(self: IndexRangePartition) usize { return self.task_size; } pub fn taskCount(self: IndexRangePartition) usize { return self.task_count; } pub fn rangeAt( self: IndexRangePartition, task_index: usize, ) error{TaskOutOfBounds}!IndexRange { if (task_index >= self.task_count) return error.TaskOutOfBounds; const begin = self.range.begin + task_index * self.task_size; return .{ .begin = begin, .end = begin + @min(self.task_size, self.range.end - begin), }; } pub fn visitAll( self: IndexRangePartition, context: anytype, comptime visit: fn (@TypeOf(context), IndexRange) void, ) void { for (0..self.task_count) |task_index| { visit(context, self.rangeAt(task_index) catch unreachable); } } pub fn visitFirst( self: IndexRangePartition, context: anytype, comptime visit: fn (@TypeOf(context), IndexRange) void, ) void { visit(context, self.rangeAt(0) catch unreachable); } pub fn visitRemaining( self: IndexRangePartition, context: anytype, comptime visit: fn (@TypeOf(context), IndexRange) void, ) void { for (1..self.task_count) |task_index| { visit(context, self.rangeAt(task_index) catch unreachable); } }};Source: lib/simd/src/root.zig:113
zig
pub const IndexRangePartition = thread.IndexRangePartition;Also reachable as
Audit
| Definitions | 9 |
|---|---|
| Public names | 27 |
| Members | 3 |
| Version | 26.7.0 |
| Revision | daab053ee433 |