Skip to main content

KernelProgram

Trait KernelProgram 

Source
pub trait KernelProgram: Send + Sync {
    // Required methods
    fn engine(&self) -> Engine;
    fn create_uninitialized(self: Arc<Self>) -> Box<dyn Kernel>;
    fn ledger(&self) -> &Arc<CompileLedger> ⓘ;
    fn resources(&self) -> &ResourceScope;
    fn canonical_hash(&self) -> [u8; 32];
    fn program_id(&self) -> ProgramId;

    // Provided methods
    fn create_kernel(self: Arc<Self>) -> Box<dyn Kernel> { ... }
    fn as_interpreter(self: Arc<Self>) -> Option<Arc<PolydatProgram>> { ... }
}
Expand description

A program on some engine, shared across threads through an Arc; every kernel created from it computes the same values and owns its own inputs, buffers, and outputs.

Required Methods§

Source

fn engine(&self) -> Engine

The engine the program was built for.

Source

fn create_uninitialized(self: Arc<Self>) -> Box<dyn Kernel>

A kernel of this program whose consts are not yet evaluated: what a binder creates, writes the enclosing scope’s values into, and then initializes, so the consts are evaluated once, from the bound values.

Source

fn ledger(&self) -> &Arc<CompileLedger> ⓘ

The compile ledger of the program tree this program belongs to.

Source

fn resources(&self) -> &ResourceScope

The resource scope of the program tree this program belongs to, the one Kernel::resources reports for every kernel created from it.

Source

fn canonical_hash(&self) -> [u8; 32]

The canonical hash of this program, the one Kernel::canonical_hash reports for every kernel created from it.

Source

fn program_id(&self) -> ProgramId

This program’s identity, equal to Kernel::program_id of every kernel created from it.

Provided Methods§

Source

fn create_kernel(self: Arc<Self>) -> Box<dyn Kernel>

A kernel of this program for the calling thread, initialized. It starts from the program on every engine: every input at its declared default, whatever the kernel that became the program had been set to; every shared binding with a cell of its own; and every const evaluated from those inputs (Kernel::init).

§Panics

When a const’s expression fails. A const is evaluated when a kernel is initialized, so a const that fails makes creation fail; the build of the program evaluated the same consts from the same defaults, so this happens only for a const that reads something outside the program, such as a clock or the environment.

Source

fn as_interpreter(self: Arc<Self>) -> Option<Arc<PolydatProgram>>

The interpreter’s program, when this is one: the graph a diagnostic describes node by node. None for a compiled engine’s program.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§