Skip to main content

KernelScheduler

Struct KernelScheduler 

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

Kernel dependency graph and launch-order scheduler.

Kernels are registered via add_kernel and dependencies added via add_dependency. Once the graph is complete, launch_order returns a topological ordering that satisfies all constraints.

Implementations§

Source§

impl KernelScheduler

Source

pub fn new() -> Self

Create an empty scheduler.

Source

pub fn add_kernel(&mut self, spec: KernelSpec) -> Result<(), SchedulerError>

Register a kernel with the scheduler.

§Errors

Returns SchedulerError::DuplicateKernel if a kernel with the same ID has already been registered.

Source

pub fn add_dependency( &mut self, dependent: u32, dependency: u32, ) -> Result<(), SchedulerError>

Declare that kernel dependent must not start until kernel dependency has finished.

§Errors
Source

pub fn dependencies_of( &self, kernel_id: u32, ) -> Result<Vec<u32>, SchedulerError>

Return the IDs of all direct dependencies of kernel_id.

§Errors

Returns SchedulerError::KernelNotFound if the ID is not registered.

Source

pub fn launch_order(&self) -> Result<Vec<u32>, SchedulerError>

Compute a valid topological launch order for all registered kernels.

Uses Kahn’s algorithm with a min-heap (via BTreeSet) for deterministic output: among ready kernels, the one with the smallest ID is picked first.

§Errors

Returns SchedulerError::CycleDetected if the graph contains a cycle (which should not happen if add_dependency correctly enforces the acyclicity invariant, but is checked defensively here).

Source

pub fn occupancy( &self, kernel_id: u32, sm_warp_limit: u32, warp_size: u32, ) -> Result<OccupancyEstimate, SchedulerError>

Compute occupancy for a specific kernel.

§Errors

Returns SchedulerError::KernelNotFound if the ID is not registered.

Source

pub fn simulate_warp_stats( &self, sm_warp_limit: u32, warp_size: u32, ) -> Result<Vec<WarpStats>, SchedulerError>

Simulate execution and return warp statistics for each kernel in launch order.

The simulation model:

  • Active warps = min(warps_per_group * work_groups, sm_warp_limit).
  • Stalled warps = max(0, total_warps_launched − active_warps).
§Errors

Returns an error if a valid launch order cannot be produced.

Source

pub fn kernel_count(&self) -> usize

Number of kernels registered in the scheduler.

Source

pub fn spec(&self, kernel_id: u32) -> Option<&KernelSpec>

Retrieve the KernelSpec for a given ID, if registered.

Trait Implementations§

Source§

impl Default for KernelScheduler

Source§

fn default() -> Self

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

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