Skip to main content

KernelResourceBudget

Struct KernelResourceBudget 

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

A kernel’s per-launch resource requirements.

Constructed with KernelResourceBudget::new, which rejects a zero thread count (a launch with no threads is meaningless and would poison the occupancy arithmetic). A registers_per_thread or shared_mem_per_block_bytes of zero means the kernel uses none of that resource and is therefore unconstrained by it.

Implementations§

Source§

impl KernelResourceBudget

Source

pub const fn new( registers_per_thread: u32, shared_mem_per_block_bytes: usize, threads_per_block: u32, ) -> Option<KernelResourceBudget>

Construct a budget. Returns None when threads_per_block is zero.

Source

pub const fn registers_per_thread(self) -> u32

Registers each thread requires (compiler-reported).

Source

pub const fn shared_mem_per_block_bytes(self) -> usize

Shared-memory bytes each block declares at launch.

Source

pub const fn threads_per_block(self) -> u32

Threads per block of the planned launch shape.

Source

pub const fn registers_per_block(self) -> u64

Registers one block consumes: registers_per_thread · threads_per_block.

The product is computed in u64 after widening both u32 factors, so it is exact for every input: the maximum product (2^32 - 1)^2 = 2^64 - 2^33 + 1 is strictly less than u64::MAX, so the multiplication never overflows and no saturation or wrapping is possible.

Source

pub const fn blocks_limited_by_registers(self, unit_registers: u32) -> u32

Blocks per unit limited by a register file of unit_registers.

Unconstrained (u32::MAX) when the kernel uses no registers or the capacity is unreported (zero) — an unreported capacity must surface as “no information” for the planner, never a fabricated bound.

Source

pub const fn blocks_limited_by_shared_mem( self, unit_shared_mem_bytes: usize, ) -> u32

Blocks per unit limited by unit_shared_mem_bytes of shared memory. Same unconstrained semantics as the register limiter.

Source

pub const fn blocks_limited_by_threads(self, max_threads_per_unit: u32) -> u32

Blocks per unit limited by max_threads_per_unit resident threads. Unconstrained when the capacity is unreported (zero).

Source

pub const fn occupancy_limits( self, unit_registers: u32, unit_shared_mem_bytes: usize, max_threads_per_unit: u32, ) -> OccupancyLimits

Intersect this budget with one compute unit’s capacities.

The capacities are the themis GpuTopology per-unit accessors (registers_per_unit(), shared_mem_per_unit_bytes(), max_threads_per_unit()), passed as plain quantities so this crate stays no_std and dependency-free; the typed pairing lives in moirai’s occupancy planner.

Trait Implementations§

Source§

impl Clone for KernelResourceBudget

Source§

fn clone(&self) -> KernelResourceBudget

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 Copy for KernelResourceBudget

Source§

impl Debug for KernelResourceBudget

Source§

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

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

impl Eq for KernelResourceBudget

Source§

impl Hash for KernelResourceBudget

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for KernelResourceBudget

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KernelResourceBudget

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.