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
impl KernelResourceBudget
Sourcepub const fn new(
registers_per_thread: u32,
shared_mem_per_block_bytes: usize,
threads_per_block: u32,
) -> Option<KernelResourceBudget>
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.
Sourcepub const fn registers_per_thread(self) -> u32
pub const fn registers_per_thread(self) -> u32
Registers each thread requires (compiler-reported).
Shared-memory bytes each block declares at launch.
Sourcepub const fn threads_per_block(self) -> u32
pub const fn threads_per_block(self) -> u32
Threads per block of the planned launch shape.
Sourcepub const fn registers_per_block(self) -> u64
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.
Sourcepub const fn blocks_limited_by_registers(self, unit_registers: u32) -> u32
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.
Blocks per unit limited by unit_shared_mem_bytes of shared memory.
Same unconstrained semantics as the register limiter.
Sourcepub const fn blocks_limited_by_threads(self, max_threads_per_unit: u32) -> u32
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).
Sourcepub const fn occupancy_limits(
self,
unit_registers: u32,
unit_shared_mem_bytes: usize,
max_threads_per_unit: u32,
) -> OccupancyLimits
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
impl Clone for KernelResourceBudget
Source§fn clone(&self) -> KernelResourceBudget
fn clone(&self) -> KernelResourceBudget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more