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
impl KernelScheduler
Sourcepub fn add_kernel(&mut self, spec: KernelSpec) -> Result<(), SchedulerError>
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.
Sourcepub fn add_dependency(
&mut self,
dependent: u32,
dependency: u32,
) -> Result<(), SchedulerError>
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
SchedulerError::KernelNotFoundif either ID is not registered.SchedulerError::CyclicDependencyif the edge would introduce a cycle.
Sourcepub fn dependencies_of(
&self,
kernel_id: u32,
) -> Result<Vec<u32>, SchedulerError>
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.
Sourcepub fn launch_order(&self) -> Result<Vec<u32>, SchedulerError>
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).
Sourcepub fn occupancy(
&self,
kernel_id: u32,
sm_warp_limit: u32,
warp_size: u32,
) -> Result<OccupancyEstimate, SchedulerError>
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.
Sourcepub fn simulate_warp_stats(
&self,
sm_warp_limit: u32,
warp_size: u32,
) -> Result<Vec<WarpStats>, SchedulerError>
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.
Sourcepub fn kernel_count(&self) -> usize
pub fn kernel_count(&self) -> usize
Number of kernels registered in the scheduler.
Sourcepub fn spec(&self, kernel_id: u32) -> Option<&KernelSpec>
pub fn spec(&self, kernel_id: u32) -> Option<&KernelSpec>
Retrieve the KernelSpec for a given ID, if registered.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KernelScheduler
impl RefUnwindSafe for KernelScheduler
impl Send for KernelScheduler
impl Sync for KernelScheduler
impl Unpin for KernelScheduler
impl UnsafeUnpin for KernelScheduler
impl UnwindSafe for KernelScheduler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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