tiny.accy.executable.composition
Defined in executable.
API (17)
Actions
Public operations.
CpuObjectCompilation.deinitCpuObjectCompilation.materializerCpuObjectMetadata.deinitCpuObjectMetadata.entrySymbolCpuObjectMetadata.initcompileCpuObjectdtypeelementTypematerializeCpuObjectruntimeEvidence
Types and contracts
Public types and contracts.
BoundaryMetadataCpuObjectCompilationCpuObjectCompileOptionsCpuObjectMetadataRuntimeEvidenceRuntimeEvidenceError
Namespaces
Public namespaces.
Source
Source: lib/accy/src/executable/composition/artifact.zig:10
pub const BoundaryMetadata = struct { element_type: choir.composition.ElementType, dimensions: []const u64, byte_size: usize, fn deinit(self: *BoundaryMetadata, allocator: Allocator) void { if (self.dimensions.len != 0) allocator.free(@constCast(self.dimensions)); self.* = undefined; }};Source: lib/accy/src/executable/composition/artifact.zig:21
pub const CpuObjectMetadata = struct { allocator: Allocator, fingerprint: u64, artifact_fingerprint: u64, artifacts: []Artifact, input_boundaries: []BoundaryMetadata, output_boundaries: []BoundaryMetadata, pub fn init( allocator: Allocator, fragment: *const executable.CompiledFragment, ) !CpuObjectMetadata { const plan = fragment.artifactPlan(); if (plan.kernels.items.len == 0) return error.InvalidArtifact; const artifacts = try allocator.alloc(Artifact, plan.kernels.items.len); var artifact_count: usize = 0; errdefer { var index = artifact_count; while (index != 0) { index -= 1; artifacts[index].deinit(); } allocator.free(artifacts); } for (plan.kernels.items, 0..) |kernel, index| { if (kernel.artifact.backend != .cpu or kernel.artifact.format != .cpu_object) return error.InvalidArtifact; const object = switch (kernel.artifact.payload) { .bytes => |bytes| bytes, else => return error.InvalidArtifact, }; var artifact = try choir.backends.artifact.objectFileArtifact( allocator, .{ .architecture = .x86_64, .triple = "x86_64-unknown-linux-gnu", .cpu = "x86-64", }, .{ .name = "sysv", .calling_convention = "c", .object_format = "elf", .pointer_width_bits = 64, .endianness = .little, }, kernel.artifact.entry_name, object, &.{}, ); errdefer artifact.deinit(); try artifact.options.add(.{ .key = "accy.kernel_id", .value = .{ .unsigned = kernel.kernel_id } }); try artifact.options.add(.{ .key = "accy.work_item_id", .value = .{ .unsigned = kernel.work_item_id } }); try artifact.options.add(.{ .key = "accy.argument_count", .value = .{ .unsigned = kernel.artifact.argument_count } }); try artifact.options.add(.{ .key = "accy.scalar_argument_count", .value = .{ .unsigned = kernel.artifact.scalar_argument_count } }); try artifact.verification.replace(artifact.allocator, .{ .state = .passed, .stage = "accy.cpu_object" }); artifacts[index] = artifact; artifact_count += 1; } const input_boundaries = try retainBoundaries(allocator, plan, plan.input_slot_ids); errdefer deinitBoundaries(allocator, input_boundaries); const output_boundaries = try retainBoundaries(allocator, plan, plan.output_slot_ids); errdefer deinitBoundaries(allocator, output_boundaries); return .{ .allocator = allocator, .fingerprint = fragment.fingerprint(), .artifact_fingerprint = fragment.artifactFingerprint(), .artifacts = artifacts, .input_boundaries = input_boundaries, .output_boundaries = output_boundaries, }; } pub fn entrySymbol(self: *const CpuObjectMetadata) ?[]const u8 { for (self.artifacts) |artifact| { if (artifact.linkage.provided_symbols.items.len != 0) return artifact.linkage.provided_symbols.items[0].name; } return null; } pub fn deinit(self: *CpuObjectMetadata) void { var artifact_index = self.artifacts.len; while (artifact_index != 0) { artifact_index -= 1; self.artifacts[artifact_index].deinit(); } deinitBoundaries(self.allocator, self.output_boundaries); deinitBoundaries(self.allocator, self.input_boundaries); self.allocator.free(self.artifacts); self.* = undefined; }};Source: lib/accy/src/executable/composition/cpu/compilation.zig:19
pub const CpuObjectCompilation = struct { allocator: Allocator, fragment_id: ChoirComposition.FragmentId, launch_tuning_artifact: []const u8, input_product: choir.product.ProductKey, compiled_fragment: ?*executable.CompiledFragment, metadata: composition.CpuObjectMetadata, pub fn deinit(self: *CpuObjectCompilation) void { if (self.compiled_fragment) |fragment| fragment.deinit(); self.metadata.deinit(); self.input_product.record.release(); if (self.launch_tuning_artifact.len != 0) self.allocator.free(@constCast(self.launch_tuning_artifact)); self.* = undefined; } pub fn materializer(self: *CpuObjectCompilation) ChoirComposition.FragmentMaterializer { return .{ .id = self.fragment_id, .context = self, .materialize = materialize, }; }};Source: lib/accy/src/executable/composition/cpu/compilation.zig:14
pub const CpuObjectCompileOptions = struct { request: executable.FragmentCompilationRequest, compiler: executable.FragmentCompilerOptions = .{},};Source: lib/accy/src/executable/composition/cpu/runtime.zig:11
pub const RuntimeEvidence = struct { invocation_count: u64, completed_invocation_count: u64, failed_invocation_count: u64, loaded_artifact_count: usize, live_buffer_count: usize,};Source: lib/accy/src/executable/composition/cpu/runtime.zig:19
pub const RuntimeEvidenceError = error{ForeignLoadedFragment};Source: lib/accy/src/executable/composition/cpu/compilation.zig:44
pub fn compileCpuObject( allocator: Allocator, fragment_id: ChoirComposition.FragmentId, module: *accy.SemanticModule, options: CpuObjectCompileOptions, report: *preparation.publication.PreparationReport, comptime configuration: choir.product.operation.Configuration,) !CpuObjectCompilation { defer module.deinit(); const launch_tuning_artifact: []const u8 = if (options.compiler.launch_tuning_artifact.len == 0) &.{} else try allocator.dupe(u8, options.compiler.launch_tuning_artifact); errdefer if (launch_tuning_artifact.len != 0) allocator.free(@constCast(launch_tuning_artifact)); var compiler_options = options.compiler; compiler_options.artifact_format = .cpu_object; var backend_state = gpu.cpu.State.init(allocator); defer backend_state.deinit(); var plan: executable.fragment.FragmentPreparationPlan = undefined; try plan.init(allocator, backend_state.handle(), compiler_options); defer plan.deinit(); const prepared = try preparation.publication.prepare(allocator, .{ .draft = module }, .{ .source = options.request.source, .variant = options.request.variant, .work = options.request.work, .record_bytes = options.request.record_bytes, .options = plan.run_options, }, report, configuration); defer prepared.deinit(); try recordPreparation(compiler_options.instrumentation, report); const input_record = try prepared.stage(.semantic).metadata().retain(); errdefer input_record.release(); const compiled_fragment = try executable.compileFragmentFromPreparedModule( allocator, backend_state.handle(), prepared, compiler_options, options.request.artifact_workspace, configuration, ); errdefer compiled_fragment.deinit(); const metadata = try composition.CpuObjectMetadata.init(allocator, compiled_fragment); return .{ .allocator = allocator, .fragment_id = fragment_id, .launch_tuning_artifact = launch_tuning_artifact, .input_product = choir.product.productKey(input_record), .compiled_fragment = compiled_fragment, .metadata = metadata, };}Source: lib/accy/src/executable/composition/cpu/materialization.zig:10
pub fn materializeCpuObject( compilation: *cpu.CpuObjectCompilation, allocator: Allocator, module: *const ChoirComposition.CompositionModule, fragment: *const ChoirComposition.Fragment,) !ChoirComposition.MaterializedFragment { try verifyDurableFragment(compilation, module, fragment); const compiled_fragment = compilation.compiled_fragment orelse return error.AlreadyMaterialized; const state = try allocator.create(cpu.runtime.State); state.* = cpu.runtime.State.init(allocator, fragment.id); var state_owned = true; errdefer if (state_owned) { state.deinitUnloaded(); allocator.destroy(state); }; const runtime_input_sizes = try retainByteSizes(allocator, compilation.metadata.input_boundaries); var input_sizes_owned = true; errdefer if (input_sizes_owned) allocator.free(runtime_input_sizes); const runtime_output_sizes = try retainByteSizes(allocator, compilation.metadata.output_boundaries); var output_sizes_owned = true; errdefer if (output_sizes_owned) allocator.free(runtime_output_sizes); compilation.compiled_fragment = null; const load_options = executable.FragmentCompilerOptions{ .artifact_format = .cpu_object, .launch_tuning_artifact = compilation.launch_tuning_artifact, }; const loaded_fragment = try executable.loadFragment( allocator, state.handle(), compiled_fragment, load_options, ); var loaded_owned = true; errdefer if (loaded_owned) loaded_fragment.deinit(); state.install(loaded_fragment, runtime_input_sizes, runtime_output_sizes); state_owned = false; loaded_owned = false; input_sizes_owned = false; output_sizes_owned = false; return .{ .state = state, .vtable = &cpu.runtime.vtable, };}Source: lib/accy/src/executable/composition/cpu/runtime.zig:72
pub fn runtimeEvidence(fragment: ChoirComposition.LoadedFragment) RuntimeEvidenceError!RuntimeEvidence { if (fragment.vtable != &vtable) return error.ForeignLoadedFragment; const state: *State = @ptrCast(@alignCast(fragment.state)); state.mutex.lock(); defer state.mutex.unlock(); return .{ .invocation_count = state.invocation_count, .completed_invocation_count = state.completed_invocation_count, .failed_invocation_count = state.failed_invocation_count, .loaded_artifact_count = state.cpu.loaded.count(), .live_buffer_count = state.cpu.buffers.count(), };}Source: lib/accy/src/executable/composition/root.zig
const artifact = @import("artifact.zig");const cpu = @import("cpu/root.zig");pub const element = @import("element.zig");pub const CpuObjectCompileOptions = cpu.CpuObjectCompileOptions;pub const CpuObjectCompilation = cpu.CpuObjectCompilation;pub const CpuObjectMetadata = artifact.CpuObjectMetadata;pub const BoundaryMetadata = artifact.BoundaryMetadata;pub const RuntimeEvidence = cpu.RuntimeEvidence;pub const RuntimeEvidenceError = cpu.RuntimeEvidenceError;pub const compileCpuObject = cpu.compileCpuObject;pub const materializeCpuObject = cpu.materializeCpuObject;pub const runtimeEvidence = cpu.runtimeEvidence;pub const elementType = element.elementType;pub const dtype = element.dtype;Source: lib/accy/src/executable/root.zig:3
pub const composition = @import("composition/root.zig");Audit
| Definitions | 15 |
|---|---|
| Public names | 15 |
| Members | 23 |
| Version | 26.7.0 |
| Revision | daab053ee433 |