tiny.accy.choir.publication
Defined in choir.
API (6)
Actions
Public operations.
Module: An opaque handle holds one reference to one stage record of the chosen stage, together with the allocator that made the handle, so a caller can pass it on or reopen it with the stage checked at compile time.PlanStage.nameStage.schemairRecord: Returns five fixed bytes, a version of 1 and the stage's number, for the semantic, contract and tensor stages, and any other stage is a compile error.
Types and contracts
Public types and contracts.
Source
Source: lib/accy/src/choir/publication.zig
zig
const std = @import("std");const choir = @import("choir");const operation = choir.product.operation;const revision = choir.product.revision;pub const Stage = enum(u8) { semantic, contract, tensor, dispatch, memory, kernel, target, pub fn name(self: Stage) []const u8 { return switch (self) { .semantic => "accy.semantic", .contract => "accy.contract", .tensor => "accy.tensor_opt", .dispatch => "accy.dispatch", .memory => "accy.memory", .kernel => "accy.kernel/gpu", .target => "accy.target", }; } pub fn schema(comptime self: Stage) revision.record.Version { return .{ .name = "accy-" ++ @tagName(self) ++ "-record", .version = 1 }; }};/// An opaque handle holds one reference to one stage record of the chosen/// stage, together with the allocator that made the handle, so a caller can/// pass it on or reopen it with the stage checked at compile time./// `fromRevision` returns `error.WrongStage` when the record belongs to another/// stage, checks the record's schema gates, and then takes a reference. The/// handle holds no compiler state and no cache, and those live in the job that/// runs the stage. `deinit` drops the reference and frees the handle, and/// `retain` makes a second handle over the same record. `plan` decodes the/// stage's typed plan for the dispatch, memory, kernel and target stages, and/// asking for it on another stage is a compile error.pub fn Module(comptime stage: Stage) type { return opaque { const Self = @This(); const Data = struct { allocator: std.mem.Allocator, product: operation.Product }; pub fn fromRevision( allocator: std.mem.Allocator, published: *const revision.Revision, ) !*Self { if (!std.mem.eql(u8, published.address().stage, stage.name())) { return error.WrongStage; } try published.requireGates(&.{ operation.schema_identity, stage.schema() }); const retained = try published.retain(); errdefer retained.release(); const data = try allocator.create(Data); data.* = .{ .allocator = allocator, .product = .{ .revision = retained } }; return @ptrCast(data); } pub fn deinit(self: *Self) void { const data: *Data = @ptrCast(@alignCast(self)); data.product.release(); data.allocator.destroy(data); } pub fn retain(self: *const Self, allocator: std.mem.Allocator) !*Self { return fromRevision(allocator, self.record()); } pub fn record(self: *const Self) *const revision.Revision { const data: *const Data = @ptrCast(@alignCast(self)); return data.product.revision; } pub fn plan( self: *const Self, allocator: std.mem.Allocator, limits: choir.bytecode.image.Limits, ) !@import("root.zig").record.codec.Decoded(Plan(stage)) { if (Plan(stage) == void) @compileError("this stage has no separate plan record"); const image = try self.open(allocator, limits); defer image.destroy(); return @import("root.zig").record.codec.decode( allocator, Plan(stage), stage, image.stage(), ); } pub fn eql(self: *const Self, other: *const Self) bool { return self.record().eql(other.record()); } pub fn open( self: *const Self, allocator: std.mem.Allocator, limits: choir.bytecode.image.Limits, ) !*choir.product.entity.Image { const data: *const Data = @ptrCast(@alignCast(self)); return data.product.open(allocator, limits); } };}/// Returns five fixed bytes, a version of 1 and the stage's number, for the/// semantic, contract and tensor stages, and any other stage is a compile/// error. The compiler writes these bytes as the stage payload of the first/// three stages, and the checker compares against them. The first three stages/// keep only their compiler image and store no plan and no cached analysis, so/// these five bytes are their whole payload. The checker refuses a stage record/// of one of those stages with `error.InvalidStageRecord` when its payload/// differs from these bytes.pub fn irRecord(comptime stage: Stage) [5]u8 { comptime requireIrStage(stage); return .{ 1, 0, 0, 0, @backingInt(stage) };}fn requireIrStage(comptime stage: Stage) void { switch (stage) { .semantic, .contract, .tensor => {}, else => @compileError("this stage requires its complete typed plan schema"), }}pub fn Plan(comptime stage: Stage) type { const records = @import("root.zig").record; return switch (stage) { .dispatch => records.dispatch.Record, .memory => records.memory.Record, .kernel => records.kernel.Record, .target => records.target.Record, else => void, };}Source: lib/accy/src/choir/root.zig:2
zig
pub const publication = @import("publication.zig");Complete caller list for choir.publication.Module
14 direct callers.
lib.accy.src.preparation.test.checkHandleFailure[function] — private source atlib/accy/src/preparation/test.zig:4246in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.expectTargetVariant[function] — private source atlib/accy/src/preparation/test.zig:293in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.expectTensorKernelCall[function] — private source atlib/accy/src/preparation/test.zig:3756in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_Accy_publication_Contract_producers_seal_only_after_accounting[function] — test source atlib/accy/src/preparation/test.zig:546in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_Accy_publication_Contract_through_Target_consumes_each_newly_sealed_predecessor[function] — test source atlib/accy/src/preparation/test.zig:2610in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_Accy_publication_restores_exact_Kernel_programs_into_Target_after_source_destruction[function] — test source atlib/accy/src/preparation/test.zig:210in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_Accy_publication_runs_recorded_Dispatch_and_Memory_producers_before_sealing[function] — test source atlib/accy/src/preparation/test.zig:152in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_Accy_publication_runs_recorded_Kernel_producers_before_sealing[function] — test source atlib/accy/src/preparation/test.zig:503in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_Accy_retained_artifact_compilation_preserves_captured_CPU_ABI_arguments[function] — test source atlib/accy/src/preparation/test.zig:3333in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_IR_stages_retain_immutable_images_after_source_destruction[function] — test source atlib/accy/src/preparation/test.zig:4177in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_Kernel_validates_multiple_program_images_within_the_same_gate_scratch[function] — test source atlib/accy/src/preparation/test.zig:1348in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_Target_owns_sibling_target_contracts_after_source_destruction[function] — test source atlib/accy/src/preparation/test.zig:1408in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_stages_own_typed_plans_and_reject_invalid_references[function] — test source atlib/accy/src/preparation/test.zig:1152in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_stages_reject_missing_gates_and_wrong_predecessor_records[function] — test source atlib/accy/src/preparation/test.zig:4210in nearest public ownerlib.accy.src.preparation.test
Complete caller list for choir.publication.irRecord
9 direct callers.
lib.accy.src.preparation.publication.encodeRecord[function] — private source atlib/accy/src/preparation/publication.zig:530in nearest public ownertiny.accy.preparation.publicationlib.accy.src.preparation.publication.verifyStage[function] — private source atlib/accy/src/preparation/publication.zig:645in nearest public ownertiny.accy.preparation.publicationlib.accy.src.preparation.test.Chain.init[function] — private source atlib/accy/src/preparation/test.zig:1097in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_Accy_publication_Contract_producers_seal_only_after_accounting[function] — test source atlib/accy/src/preparation/test.zig:546in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_Accy_publication_Contract_through_Target_consumes_each_newly_sealed_predecessor[function] — test source atlib/accy/src/preparation/test.zig:2610in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_Contract_rejects_unsupported_dialects[function] — test source atlib/accy/src/preparation/test.zig:4233in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_IR_stages_retain_immutable_images_after_source_destruction[function] — test source atlib/accy/src/preparation/test.zig:4177in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_stages_reject_missing_gates_and_wrong_predecessor_records[function] — test source atlib/accy/src/preparation/test.zig:4210in nearest public ownerlib.accy.src.preparation.testlib.accy.src.preparation.test.test_sealed_Accy_stages_require_predecessor_gate_evidence_beyond_its_address[function] — test source atlib/accy/src/preparation/test.zig:4264in nearest public ownerlib.accy.src.preparation.test
Audit
| Definitions | 7 |
|---|---|
| Public names | 7 |
| Members | 7 |
| Version | 26.7.0 |
| Revision | daab053ee433 |