tiny.simd.ProcessorTopology
Defined in tiny.simd.
API (13)
Actions
Public operations.
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: lib/simd/src/topology/model.zig:113
zig
pub const Topology = struct { phase: alloc_phase.capacity.Phase = .initialization, capacity: TopologyCapacity = .{}, allocation: ?[]align(storage_alignment.toByteUnits()) u8 = null, packages: []const Package = &.{}, lps: []const LP = &.{}, pub const Limits: type = TopologyLimits; pub const Capacity: type = TopologyCapacity; pub const claim: alloc_phase.capacity.Declaration = .{ .source = .{ .id = "simd.topology_storage", .kind = .phase_static, .limit_source = .caller, .storage = .{ .covered = &.{ .{ .id = "one_exact_topology_array_region_and_borrowed_views", .lifetime = .steady, .detail = "one exact topology array region and borrowed views", }, }, .excluded = &.{ "caller-owned processor discovery records", "operating-system queries and temporary relationship buffers", }, }, .capacity = .{ .inputs = &.{}, .type_selectors = &.{}, .nodes = &.{ .{ .constant = 0 }, }, .assertions = &.{.{ .scope = .closure_total, .measure = .retained, .relation = .exact, .expression = 0, }}, }, .overload = .{ .kind = .reject_before_seal, .detail = "empty oversize package and SMT bounds reject before allocation", }, .risks = .{ .transitive = .{ .status = .witnessed, .detail = "remapping placement and allocation cleanup are checked together", }, .foreign = .{ .status = .excluded, .detail = "native discovery completes before immutable topology storage is sealed", }, }, .obligations = &.{ .{ .key = "simd_topology_capacity_capacity_model", .role = .capacity_model }, .{ .key = "simd_topology_capacity_overload", .role = .overload }, .{ .key = "simd_topology_remap", .role = .transitive_risk }, .{ .key = "simd_topology_oom", .role = .transitive_risk }, .{ .key = "simd_topology_native", .role = .foreign_risk }, }, }, .bindings = .{ .owner = @This(), .seal = .{ .family = alloc_phase.capacity.selector(@This().activate), .premise = .{ .class = .checked_semantic_fact, .authority = .checker, }, }, .teardown = .{ .family = alloc_phase.capacity.selector(@This().deinit), .premise = .{ .class = .checked_semantic_fact, .authority = .checker, }, }, }, }; pub fn init( allocator: std.mem.Allocator, limits: Limits, ) Error!Topology { const records = limits.records; var mapped_lps: [max_logical_processors]LP = @splat(.{}); var package_sizes: [max_packages]PackageSize = @splat(.{}); const capacity_value = try inspectRecords(records, &mapped_lps, &package_sizes); const allocation = try allocator.alignedAlloc( u8, storage_alignment, capacity_value.storage_bytes, ); errdefer allocator.free(allocation); @memset(allocation, 0); var offset: usize = 0; const packages = take(Package, allocation, &offset, capacity_value.packages); const clusters = take(Cluster, allocation, &offset, capacity_value.clusters); const cores = take(Core, allocation, &offset, capacity_value.cores); const lps = take(LP, allocation, &offset, capacity_value.logical_processors); std.debug.assert(offset == capacity_value.storage_bytes); @memcpy(lps, mapped_lps[0..records.len]); placePackageSlices(packages, clusters, cores, &package_sizes); populateSets(packages, lps, records); return .{ .phase = .initialization, .capacity = capacity_value, .allocation = allocation, .packages = packages, .lps = lps, }; } pub fn initFromRecords( allocator: std.mem.Allocator, records: []const ProcessorRecord, ) Error!Topology { var topology = try init(allocator, .{ .records = records }); topology.activate(); return topology; } pub fn activate(self: *Topology) void { std.debug.assert(self.phase == .initialization); std.debug.assert(self.capacity.logical_processors == self.lps.len); self.phase = .steady; } pub fn deinit(self: *Topology, allocator: std.mem.Allocator) void { std.debug.assert(self.phase != .teardown); self.phase = .teardown; if (self.allocation) |allocation| allocator.free(allocation); self.allocation = null; self.packages = &.{}; self.lps = &.{}; } pub fn allocatedBytes(self: *const Topology) usize { std.debug.assert(self.phase != .teardown); return if (self.allocation) |allocation| allocation.len else 0; }};Source: lib/simd/src/root.zig:92
zig
pub const ProcessorTopology = topology.Topology;Also reachable as
Audit
| Definitions | 9 |
|---|---|
| Public names | 18 |
| Members | 5 |
| Version | 26.7.0 |
| Revision | daab053ee433 |