pub struct MegakernelConfig {
pub worker_count: u32,
pub max_wall_time: Duration,
pub expected_items_per_worker: u32,
pub workload: MegakernelWorkloadHints,
}Expand description
Configuration for one megakernel dispatch invocation.
Fields§
§worker_count: u32Number of persistent worker workgroups.
max_wall_time: DurationMaximum wall-clock time the megakernel runs before draining queued work and exiting.
expected_items_per_worker: u32Hint to the scheduler about expected items per worker.
workload: MegakernelWorkloadHintsOptional workload-shape hints consumed by the launch policy.
Implementations§
Source§impl MegakernelConfig
impl MegakernelConfig
Sourcepub fn validate(&self) -> Result<(), BackendError>
pub fn validate(&self) -> Result<(), BackendError>
Validate the config and surface actionable errors.
§Errors
Returns an error when the worker count is zero or the wall-clock budget is empty, because either condition would make persistent dispatch unschedulable.
Sourcepub fn dispatch_grid(
&self,
queue_len: u32,
max_workgroup_size_x: u32,
) -> [u32; 3]
pub fn dispatch_grid( &self, queue_len: u32, max_workgroup_size_x: u32, ) -> [u32; 3]
Compute the direct-dispatch grid for queue_len logical work slots.
worker_count is the caller’s persistent worker-workgroup ceiling; the
returned grid never launches more workgroups than that ceiling or the
backend occupancy cap.
Sourcepub const fn launch_request(
&self,
queue_len: u32,
max_workgroup_size_x: u32,
max_compute_workgroups_per_dimension: u32,
max_compute_invocations_per_workgroup: u32,
) -> MegakernelLaunchRequest
pub const fn launch_request( &self, queue_len: u32, max_workgroup_size_x: u32, max_compute_workgroups_per_dimension: u32, max_compute_invocations_per_workgroup: u32, ) -> MegakernelLaunchRequest
Build a policy request from this config and adapter limits.
Sourcepub fn launch_request_for_tasks(
&self,
tasks: &[TaskWorkItem],
max_workgroup_size_x: u32,
max_compute_workgroups_per_dimension: u32,
max_compute_invocations_per_workgroup: u32,
) -> Result<MegakernelLaunchRequest, BackendError>
pub fn launch_request_for_tasks( &self, tasks: &[TaskWorkItem], max_workgroup_size_x: u32, max_compute_workgroups_per_dimension: u32, max_compute_invocations_per_workgroup: u32, ) -> Result<MegakernelLaunchRequest, BackendError>
Build a policy request from device-visible continuation task slots.
Paused, completed, empty, running, and faulted tasks do not add launch lanes. Yielded and requeued tasks stay schedulable so the GPU can resume them without a CPU-side republish loop.
§Errors
Returns BackendError when a task slot contains an invalid state word.
Sourcepub fn launch_recommendation(
&self,
queue_len: u32,
max_workgroup_size_x: u32,
max_compute_workgroups_per_dimension: u32,
max_compute_invocations_per_workgroup: u32,
) -> Result<MegakernelLaunchRecommendation, BackendError>
pub fn launch_recommendation( &self, queue_len: u32, max_workgroup_size_x: u32, max_compute_workgroups_per_dimension: u32, max_compute_invocations_per_workgroup: u32, ) -> Result<MegakernelLaunchRecommendation, BackendError>
Recommend one launch shape through the shared megakernel policy.
§Errors
Returns BackendError when adapter limits are malformed.
Sourcepub fn launch_recommendation_for_tasks(
&self,
tasks: &[TaskWorkItem],
max_workgroup_size_x: u32,
max_compute_workgroups_per_dimension: u32,
max_compute_invocations_per_workgroup: u32,
) -> Result<MegakernelLaunchRecommendation, BackendError>
pub fn launch_recommendation_for_tasks( &self, tasks: &[TaskWorkItem], max_workgroup_size_x: u32, max_compute_workgroups_per_dimension: u32, max_compute_invocations_per_workgroup: u32, ) -> Result<MegakernelLaunchRecommendation, BackendError>
Recommend one launch shape for a continuation task queue.
§Errors
Returns BackendError when adapter limits are malformed or any task
slot contains an invalid state word.
Trait Implementations§
Source§impl Clone for MegakernelConfig
impl Clone for MegakernelConfig
Source§fn clone(&self) -> MegakernelConfig
fn clone(&self) -> MegakernelConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more