Struct Allocator

Source
pub struct Allocator { /* private fields */ }
Expand description

An allocator for local variables of a kernel.

A local variable is unique to a unit. That is, each unit have their own copy of a local variable. There are three types of local variables based on their capabilities. - An immutable local variable is obtained by calling Allocator::create_local. - A mutable local variable is obtained by calling Allocator::create_local_mut. The allocator will reuse previously defined mutable variables if possible. - A restricted mutable local variable is obtained by calling Allocator::create_local_restricted. This a is mutable variable that cannot be reused. This is mostly used for loop indices.

§Performance tips

In order, prefer immutable local variables, then mutable, then restricted.

To enable many compiler optimizations, it is preferred to use the [static single-assignment] strategy for immutable variables. That is, each variable must be declared and used exactly once.

static single-assignment

Implementations§

Source§

impl Allocator

Source

pub fn create_local(&self, item: Item) -> ExpandElement

Create a new immutable local variable of type specified by item.

Source

pub fn create_local_mut(&self, item: Item) -> ExpandElement

Create a new mutable local variable of type specified by item. Try to reuse a previously defined but unused mutable variable if possible. Else, this define a new variable.

Source

pub fn create_local_restricted(&self, item: Item) -> ExpandElement

Create a new mutable restricted local variable of type specified by item.

Source

pub fn create_local_array(&self, item: Item, array_size: u32) -> ExpandElement

Source

pub fn create_matrix(&self, matrix: Matrix) -> ExpandElement

Create a matrix variable

Source

pub fn create_pipeline(&self, item: Item, num_stages: u8) -> ExpandElement

Source

pub fn create_barrier(&self, item: Item, level: BarrierLevel) -> ExpandElement

Source

pub fn reuse_local_mut(&self, item: Item) -> Option<ExpandElement>

Source

pub fn add_local_mut(&self, item: Item) -> Rc<Variable>

Add a new variable to the pool with type specified by item for the given scope.

Source

pub fn new_local_index(&self) -> u32

Source

pub fn take_variables(&self) -> Vec<Variable>

Trait Implementations§

Source§

impl Clone for Allocator

Source§

fn clone(&self) -> Allocator

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Allocator

Source§

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

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

impl Default for Allocator

Source§

fn default() -> Allocator

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Allocator

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Allocator

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Allocator

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TypeHash for Allocator

Source§

fn write_hash(hasher: &mut impl Hasher)

Write the structure of the type to the hasher
Source§

fn type_hash() -> u64

Generate a stable hash of the type structure. Read more
Source§

impl Eq for Allocator

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,