pub struct ProgramSpec {
pub name: String,
pub src: String,
pub device: DeviceSpec,
pub ast: Arc<UOp>,
pub global_size: [Arc<UOp>; 3],
pub local_size: Option<[Arc<UOp>; 3]>,
pub vars: Vec<Variable>,
pub var_names: Vec<String>,
pub globals: Vec<usize>,
pub outs: Vec<usize>,
pub ins: Vec<usize>,
pub buf_count: usize,
}Expand description
Program specification containing source code and metadata.
This is returned by Renderer::render() and consumed by Compiler::compile(). It bridges the gap between UOp graphs and compiled executables.
§Tinygrad Alignment
Buffer metadata (globals, outs, ins) matches Tinygrad’s Program class:
globals: Buffer indices from PARAM opsouts: Output buffer indices (written by STORE ops)ins: Input buffer indices (read by LOAD ops)
Fields§
§name: StringKernel name (for debugging/profiling)
src: StringGenerated source code (LLVM IR, CUDA C, Metal, WGSL, etc.)
device: DeviceSpecDevice specification
ast: Arc<UOp>Original AST (for cache key construction via hash consing)
global_size: [Arc<UOp>; 3]Symbolic global work size.
local_size: Option<[Arc<UOp>; 3]>Symbolic local work size. None means direct global-id execution.
vars: Vec<Variable>Variable list (for symbolic shapes/strides)
var_names: Vec<String>Variable names in order for populating vars array at runtime. Includes runtime variables such as core_id.
globals: Vec<usize>Global buffer indices (from PARAM slot values).
Matches Tinygrad’s globals field.
outs: Vec<usize>Output buffer indices (written by STORE ops).
Matches Tinygrad’s outs field.
ins: Vec<usize>Input buffer indices (read by LOAD ops, excluding outputs).
Matches Tinygrad’s ins field.
buf_count: usizeNumber of buffer arguments (for CIF construction at compile time).
Implementations§
Source§impl ProgramSpec
impl ProgramSpec
Sourcepub fn new(name: String, src: String, device: DeviceSpec, ast: Arc<UOp>) -> Self
pub fn new(name: String, src: String, device: DeviceSpec, ast: Arc<UOp>) -> Self
Create a new program specification.
Sourcepub fn set_work_sizes(&mut self, global: [usize; 3], local: [usize; 3])
pub fn set_work_sizes(&mut self, global: [usize; 3], local: [usize; 3])
Set work sizes for GPU execution.
Sourcepub fn set_launch_dims(
&mut self,
global: [Arc<UOp>; 3],
local: Option<[Arc<UOp>; 3]>,
)
pub fn set_launch_dims( &mut self, global: [Arc<UOp>; 3], local: Option<[Arc<UOp>; 3]>, )
Set symbolic work sizes for replay with runtime variables.
Sourcepub fn launch_dims(
&self,
var_vals: &HashMap<&str, i64>,
) -> Result<ConcreteLaunchDims>
pub fn launch_dims( &self, var_vals: &HashMap<&str, i64>, ) -> Result<ConcreteLaunchDims>
Evaluate symbolic launch dimensions using runtime variable values.
Sourcepub fn resolve_launch_dims(
global_size: &[Arc<UOp>; 3],
local_size: Option<&[Arc<UOp>; 3]>,
var_vals: &HashMap<&str, i64>,
) -> Result<ConcreteLaunchDims>
pub fn resolve_launch_dims( global_size: &[Arc<UOp>; 3], local_size: Option<&[Arc<UOp>; 3]>, var_vals: &HashMap<&str, i64>, ) -> Result<ConcreteLaunchDims>
Evaluate launch dimensions stored outside a full ProgramSpec.
Sourcepub fn set_var_names(&mut self, var_names: Vec<String>)
pub fn set_var_names(&mut self, var_names: Vec<String>)
Set variable names for populating vars array at runtime.
Sourcepub fn set_buffer_metadata(
&mut self,
globals: Vec<usize>,
outs: Vec<usize>,
ins: Vec<usize>,
)
pub fn set_buffer_metadata( &mut self, globals: Vec<usize>, outs: Vec<usize>, ins: Vec<usize>, )
Set buffer metadata (globals, outs, ins).
Sourcepub fn apply_derived_metadata_from_ast(&mut self)
pub fn apply_derived_metadata_from_ast(&mut self)
Derive and apply metadata from self.ast.
This mirrors Tinygrad-style program metadata extraction from the kernel graph and keeps renderer wrappers aligned on one metadata path.
Trait Implementations§
Source§impl Clone for ProgramSpec
impl Clone for ProgramSpec
Source§fn clone(&self) -> ProgramSpec
fn clone(&self) -> ProgramSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more