Skip to main content

Node

Enum Node 

Source
#[non_exhaustive]
pub enum Node {
Show 20 variants Let { name: Ident, value: Expr, }, Assign { name: Ident, value: Expr, }, Store { buffer: Ident, index: Expr, value: Expr, }, If { cond: Expr, then: Vec<Node>, otherwise: Vec<Node>, }, Loop { var: Ident, from: Expr, to: Expr, body: Vec<Node>, }, IndirectDispatch { count_buffer: Ident, count_offset: u64, }, AsyncLoad { source: Ident, destination: Ident, offset: Box<Expr>, size: Box<Expr>, tag: Ident, }, AsyncStore { source: Ident, destination: Ident, offset: Box<Expr>, size: Box<Expr>, tag: Ident, }, AsyncWait { tag: Ident, }, Trap { address: Box<Expr>, tag: Ident, }, Resume { tag: Ident, }, AllReduce { buffer: Ident, op: CollectiveOp, group: CommGroup, }, AllGather { input: Ident, output: Ident, group: CommGroup, }, ReduceScatter { input: Ident, output: Ident, op: CollectiveOp, group: CommGroup, }, Broadcast { buffer: Ident, root: u32, group: CommGroup, }, Return, Barrier { ordering: MemoryOrdering, }, Block(Vec<Node>), Region { generator: Ident, source_region: Option<GeneratorRef>, body: Arc<Vec<Node>>, }, Opaque(Arc<dyn NodeExtension>),
}
Expand description

Statement nodes - execute effects.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Let

Fields

§name: Ident
§value: Expr
§

Assign

Fields

§name: Ident
§value: Expr
§

Store

Fields

§buffer: Ident
§index: Expr
§value: Expr
§

If

Fields

§cond: Expr
§then: Vec<Node>
§otherwise: Vec<Node>
§

Loop

Fields

§var: Ident
§from: Expr
§to: Expr
§body: Vec<Node>
§

IndirectDispatch

Fields

§count_buffer: Ident
§count_offset: u64
§

AsyncLoad

Fields

§source: Ident
§destination: Ident
§offset: Box<Expr>
§size: Box<Expr>
§tag: Ident
§

AsyncStore

Fields

§source: Ident
§destination: Ident
§offset: Box<Expr>
§size: Box<Expr>
§tag: Ident
§

AsyncWait

Fields

§tag: Ident
§

Trap

Fields

§address: Box<Expr>
§tag: Ident
§

Resume

Fields

§tag: Ident
§

AllReduce

Fields

§buffer: Ident
§

AllGather

Fields

§input: Ident
§output: Ident
§

ReduceScatter

Fields

§input: Ident
§output: Ident
§

Broadcast

Fields

§buffer: Ident
§root: u32
§

Return

§

Barrier

Fields

§

Block(Vec<Node>)

§

Region

Fields

§generator: Ident
§source_region: Option<GeneratorRef>
§body: Arc<Vec<Node>>
§

Opaque(Arc<dyn NodeExtension>)

Implementations§

Source§

impl Node

Source

pub fn let_bind(name: impl Into<Ident>, value: Expr) -> Node

let name = value;

§Examples
use vyre::ir::{Expr, Node};
let _ = Node::let_bind("x", Expr::u32(1));
Source

pub fn assign(name: impl Into<Ident>, value: Expr) -> Node

name = value;

§Examples
use vyre::ir::{Expr, Node};
let _ = Node::assign("x", Expr::u32(2));
Source

pub fn store(buffer: impl Into<Ident>, index: Expr, value: Expr) -> Node

buffer[index] = value;

§Examples
use vyre::ir::{Expr, Node};
let _ = Node::store("out", Expr::u32(0), Expr::u32(1));
Source

pub fn if_then_else(cond: Expr, then: Vec<Node>, otherwise: Vec<Node>) -> Node

if cond { then } else { otherwise }

§Examples
use vyre::ir::{Expr, Node};
let _ = Node::if_then_else(Expr::bool(true), vec![Node::Return], vec![]);
Source

pub fn if_then(cond: Expr, then: Vec<Node>) -> Node

if cond { then }

§Examples
use vyre::ir::{Expr, Node};
let _ = Node::if_then(Expr::bool(true), vec![Node::Return]);
Source

pub fn loop_for( var: impl Into<Ident>, from: Expr, to: Expr, body: Vec<Node>, ) -> Node

for var in from..to { body }

§Examples
use vyre::ir::{Expr, Node};
let _ = Node::loop_for("i", Expr::u32(0), Expr::u32(4), vec![]);
Source

pub fn loop_( var: impl Into<Ident>, from: Expr, to: Expr, body: Vec<Node>, ) -> Node

for var in from..to { body }

§Examples
use vyre::ir::{Expr, Node};

let node = Node::loop_("i", Expr::u32(0), Expr::u32(4), vec![Node::Return]);
assert!(matches!(node, Node::Loop { .. }));
Source

pub fn forever(body: Vec<Node>) -> Node

Effectively-infinite loop used by persistent kernels (megakernel, event loops, streaming). Lowers to Node::Loop with from: 0, to: u32::MAX. At 1 µs per iteration u32::MAX is ~68 years - for all practical purposes infinite. The inner body drives termination via Node::Return or by observing an atomic shutdown flag the host sets.

Linus principle: one enum variant (Node::Loop) handles both bounded and persistent cases. No cascade of match arms through every pass; no new wire-format tag. An optimizer pass that wants to distinguish “truly unbounded” from “large bound” inspects the to expression.

§Examples
use vyre::ir::Node;

let persistent = Node::forever(vec![Node::Return]);
assert!(matches!(persistent, Node::Loop { .. }));
Source

pub fn block(nodes: Vec<Node>) -> Node

Sequence of statements.

§Examples
use vyre::ir::Node;

assert!(matches!(Node::block(vec![Node::Return]), Node::Block(_)));
Source

pub const fn return_() -> Node

Early return from the entry point.

§Examples
use vyre::ir::Node;

assert!(matches!(Node::return_(), Node::Return));
Source

pub const fn barrier() -> Node

Workgroup barrier statement.

§Examples
use vyre::ir::Node;

assert!(matches!(Node::barrier(), Node::Barrier { .. }));
Source

pub const fn barrier_with_ordering(ordering: MemoryOrdering) -> Node

Workgroup barrier statement with explicit memory ordering.

Source

pub fn call(op_id: impl Into<Ident>, args: Vec<Expr>) -> Node

Statement-level invocation of another registered op by stable op id.

Represented as a named Node::Region whose generator is the callee’s op id and whose body is an internal sequence of Node::Let { name: "arg{i}", value: <arg_expr> } bindings. Every backend already handles Node::Region - the op-registry inliner walks the arg binds, substitutes them into the callee’s fragment, and splices the result in place. No new IR variant is introduced, and the arg values remain fully visible to CSE, DCE, and constant folding through the let-chain.

Source

pub fn indirect_dispatch( count_buffer: impl Into<Ident>, count_offset: u64, ) -> Node

Command-level indirect dispatch metadata.

§Examples
use vyre::ir::Node;

let node = Node::indirect_dispatch("counts", 0);
assert!(matches!(node, Node::IndirectDispatch { .. }));
Source

pub fn async_load_ext( source: impl Into<Ident>, destination: impl Into<Ident>, offset: Expr, size: Expr, tag: impl Into<Ident>, ) -> Node

Begin an asynchronous transfer stream region (GPU-driven).

§Examples
use vyre::ir::{Node, Expr};

let node = Node::async_load_ext("ssd", "vram", Expr::u32(0), Expr::u32(1024), "tag-0");
assert!(matches!(node, Node::AsyncLoad { .. }));
Source

pub fn async_load(tag: impl Into<Ident>) -> Node

Begin an asynchronous transfer stream region (legacy/host-driven).

Source

pub fn async_store( source: impl Into<Ident>, destination: impl Into<Ident>, offset: Expr, size: Expr, tag: impl Into<Ident>, ) -> Node

Begin an asynchronous store transfer stream region (GPU-driven).

Source

pub fn async_wait(tag: impl Into<Ident>) -> Node

Wait for an asynchronous transfer stream region.

§Examples
use vyre::ir::Node;

let node = Node::async_wait("stage-a");
assert!(matches!(node, Node::AsyncWait { .. }));
Source

pub fn trap(address: Expr, tag: impl Into<Ident>) -> Node

Trap the current execution lane (GPU-initiated page fault).

Source

pub fn resume(tag: impl Into<Ident>) -> Node

Resume a previously trapped execution lane.

Source

pub fn opaque(node: impl NodeExtension) -> Node

Wrap a downstream extension statement node.

Source

pub fn opaque_arc(node: Arc<dyn NodeExtension>) -> Node

Wrap a shared downstream extension statement node.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Node

§

impl !UnwindSafe for Node

§

impl Freeze for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more