Skip to main content

ParallelOrchestrator

Struct ParallelOrchestrator 

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

Orchestrates the execution of multiple solver stages respecting dependencies.

§Example

use oxiphysics_core::parallel_orchestrator::{ParallelOrchestrator, SolverStage};

struct SimpleStage { name: String, cost: f64, step_count: u64 }

impl SolverStage for SimpleStage {
    fn name(&self) -> &str { &self.name }
    fn step(&mut self, _dt: f64) { self.step_count += 1; }
    fn estimated_cost(&self) -> f64 { self.cost }
}

let mut orch = ParallelOrchestrator::new();
let a = orch.add_stage("broadphase", &[]);
let b = orch.add_stage("narrowphase", &[a]);
let c = orch.add_stage("solver", &[b]);

let mut stages: Vec<Box<dyn SolverStage>> = vec![
    Box::new(SimpleStage { name: "broadphase".into(), cost: 1.0, step_count: 0 }),
    Box::new(SimpleStage { name: "narrowphase".into(), cost: 2.0, step_count: 0 }),
    Box::new(SimpleStage { name: "solver".into(), cost: 3.0, step_count: 0 }),
];

orch.execute(&mut stages, 0.016).expect("execution failed");

Implementations§

Source§

impl ParallelOrchestrator

Source

pub fn new() -> Self

Creates a new empty orchestrator.

Source

pub fn add_stage(&mut self, name: &str, depends_on: &[usize]) -> usize

Registers a new stage with the given name and dependency list.

Returns the index of the newly added stage, which can be used as a dependency for later stages.

§Arguments
  • name - Human-readable stage name.
  • depends_on - Indices of stages that must run before this one.
Source

pub fn num_stages(&self) -> usize

Returns the number of registered stages.

Source

pub fn stage_names(&self) -> &[String]

Returns the registered stage names.

Source

pub fn compute_schedule(&self) -> Result<PipelineSchedule, OrchestratorError>

Computes a PipelineSchedule by topologically sorting stages into waves.

Returns an error if the dependency graph contains a cycle or references an invalid stage index.

Source

pub fn execute( &mut self, stages: &mut [Box<dyn SolverStage>], dt: f64, ) -> Result<(), OrchestratorError>

Executes all registered stages in dependency order.

Stages within the same wave are currently run sequentially. The timings for each stage are accumulated across repeated calls to execute.

§Errors

Returns an error if scheduling fails (cycle or invalid index) or if a scheduled stage index is out of range for the provided stages slice.

Source

pub fn timings(&self) -> &[f64]

Returns per-stage accumulated wall-clock timings in seconds.

Source

pub fn total_time(&self) -> f64

Returns the total accumulated wall-clock time across all stages.

Source

pub fn reset_timings(&mut self)

Resets all accumulated timings to zero.

Trait Implementations§

Source§

impl Clone for ParallelOrchestrator

Source§

fn clone(&self) -> ParallelOrchestrator

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 Debug for ParallelOrchestrator

Source§

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

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

impl Default for ParallelOrchestrator

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

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = 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.