Skip to main content

Engine

Struct Engine 

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

Sole owner of OA’s local execution services.

The current one-device recorder is thread-affine. Engine intentionally remains neither Send nor Sync until concurrent queue scheduling and submission synchronization are implemented and verified.

Clones share the execution handle and persistence guard: .vkcache persistence runs once, when the last Engine clone drops, never per temporary handle. A clone does not own the log-selection restore that the constructing engine performs on drop.

Implementations§

Source§

impl Engine

Source

pub fn available_devices() -> Result<Vec<DeviceSummary>>

List every Vulkan device, including software CPU implementations.

Creates a temporary instance but no logical device, allocator or pipelines. A listed device may still fail OA capability admission. Ordinals are scoped to the current loader and ICD configuration, not stable across machines.

§Errors

Returns backend initialization or enumeration errors.

Source

pub fn device_info(&self) -> DeviceInfo

Return queried device facts and the allocated descriptor capacities.

Source

pub fn fusion_stats(&self) -> FusionStats

Return engine-lifetime fusion decision and decline counters.

Counts reflect fusion passes that already ran: eager work is fused when it is flushed and captured work when it is captured. This query does not flush, submit or wait, and plan replay does not change the counters. The record is a diagnostic; it never influences route selection.

Source

pub fn builder() -> EngineBuilder

Begin explicit engine configuration.

Source

pub fn new() -> Result<Self>

Create an engine using one compute-capable Vulkan device.

§Errors

Returns an error when Vulkan cannot be loaded, no hardware device meets the compiled Core or Compatibility profile requirements, or logical-device creation fails.

Source

pub fn init_default() -> Result<()>

Initialize this thread’s default compute engine before its first use.

Initialization is lazy and attempted again after a failure. The selected engine remains thread-affine and is reused by later default operations.

§Errors

Returns the same backend or device-selection error as Engine::new.

Source

pub fn set_default(engine: Engine)

Install engine as this thread’s default compute engine.

Replaces any engine previously stored by Engine::init_default or an earlier set_default call. The previous default is dropped after the new engine is installed.

Source

pub fn current() -> Result<Self>

Return this thread’s default compute engine.

Initialization is lazy on first use and the returned handle clones the installed engine, so it remains valid if the default is later replaced.

§Errors

Returns the same backend or device-selection error as Engine::new.

Source

pub fn with_default<T>(use_engine: impl FnOnce(&Self) -> Result<T>) -> Result<T>

Access this thread’s lazily initialized default compute engine.

§Errors

Returns an engine initialization error or an error from use_engine.

Source

pub fn has_graphics(&self) -> bool

Return whether this Engine has an executable graphics path.

Both profiles require enabled dynamic rendering and a graphics queue. Presentation additionally requires WSI support and per-surface present-support negotiation.

Source

pub fn supports_clock_calibration(&self) -> bool

Return whether this Engine’s device can calibrate its timestamp domain against a POSIX monotonic host clock.

Source

pub fn calibrate_clock(&self, sample_count: u32) -> Result<ClockCalibration>

Sample paired device/host timestamps and retain the lowest-deviation pair.

sample_count selects the best of [1, 1024] quasi-simultaneous samples; recalibrate long-running traces periodically because a value farther than half a device-clock period from the sample is inherently ambiguous.

§Errors

Returns InvalidArgument when sample_count is outside [1, 1024], Unavailable when the device lacks calibrated timestamps or usable domains, and a backend error when sampling fails.

Source

pub fn new_presentation_surface<'window>( &self, window: &'window SdlWindow, ) -> Result<PresentationSurface<'window>>

Create one SDL3 Vulkan surface borrowing this Engine and window.

Source

pub fn owns_matrix(&self, matrix: &Matrix) -> bool

Source

pub fn checkpoint(&self) -> Result<Event>

Submit an explicit completion checkpoint to this engine’s compute queue.

Pending eager operations are submitted together as one batch. When no eager work is pending, an empty checkpoint is submitted. The returned event completes after that exact queue point. Dropping it does not wait.

§Errors

Returns an error when command recording, submission, or retirement fails, or when the engine exhausts its timeline epoch space.

Source

pub fn checkpoint_timed(&self) -> Result<Event>

Submit pending eager work with one device timestamp pair around the batch.

Unlike Engine::checkpoint, this requires at least one pending operation; there is no meaningful device interval for an empty queue checkpoint.

§Errors

Returns the errors from Engine::checkpoint, MissingCapability when timestamps are unavailable, or FailedPrecondition for an empty batch.

Source

pub fn checkpoint_with_timer(&self, timer: &mut Timer) -> Result<Event>

Submit pending eager work bracketed by a device Timer’s timestamps.

The timer must be initialized for TimerDomain::Device on this engine and is single-flight: a new tagged submission is rejected while the previous one is pending. The returned event carries no timing; the elapsed device duration is committed through Timer::commit.

Donor: oa::Engine::submit(oa::Timer*) in oacpp/source/cpp/lib/oa/runtime/engine/engine.cpp.

§Errors

Returns the errors from Engine::checkpoint_timed, or FailedPrecondition when the timer is host-domain, uninitialized, or still pending, or InvalidArgument when it was initialized by another engine.

Source

pub fn capture<T>( &self, capture: impl FnOnce() -> Result<T>, ) -> Result<(ExecutionPlan, T)>

Capture an isolated operation sequence as an immutable execution plan.

Capture records but never submits or waits. The returned value may include matrices produced by the plan; those matrices become observable only after Engine::submit is called for the returned plan.

§Errors

Returns an error when eager work is already pending, capture is nested, the closure fails, or the closure records no executable work.

Source

pub fn submit(&self, plan: &ExecutionPlan) -> Result<Event>

Submit an immutable execution plan to its originating engine.

Any pending eager batch is submitted first. The returned event identifies exact completion of this plan replay. Submission does not wait.

§Errors

Returns an error when the plan belongs to another engine, capture is active, eager flushing fails, or command recording, submission, or retirement fails.

Source

pub fn submit_timed(&self, plan: &ExecutionPlan) -> Result<Event>

Submit a plan with one device timestamp pair around its complete graph.

The returned event exposes the device duration through Event::try_device_duration and Event::device_duration. Timing adds instrumentation only to this replay and does not wait.

§Errors

Returns the errors from Engine::submit, or MissingCapability when the selected compute queue cannot provide timestamps.

Source

pub fn log( &self, level: LogLevel, component: LogComponent, text: impl AsRef<str>, ) -> Result<()>

Write one record through this engine’s logging session.

Filtered records return successfully without formatting or output.

§Errors

Returns the first retained console or file output failure, or an error if the logging session has already been closed.

Source

pub fn set_log_level(&self, level: LogLevel)

Change this engine logger’s minimum severity.

Source

pub fn log_level(&self) -> LogLevel

Return this engine logger’s current minimum severity.

Source

pub fn log_path(&self) -> Option<PathBuf>

Return the active log-file path when file output is enabled.

Source

pub fn flush_log(&self) -> Result<()>

Flush this engine’s logging session and report any retained sink failure.

§Errors

Returns the first console or file output failure.

Source

pub fn close(self) -> Result<()>

Explicitly close this engine’s logging session before releasing the engine.

Existing values retain the execution services they require, but no longer have a selected engine logging session after this call consumes self.

§Errors

Returns the first console or file flush failure.

Source§

impl Engine

Source

pub fn dispatch_kernel( &self, kernel: &Kernel, bindings: &[KernelBinding<'_>], push_constants: &[KernelPush], workgroups: [u32; 3], ) -> Result<()>

Record one eager extension-kernel dispatch.

The dispatch joins the engine’s pending batch like any eager operation: barriers against other recorded work are derived from the declared binding accesses, and completion is observed through Engine::checkpoint or any host read.

§Errors

Returns InvalidArgument when kernel belongs to another engine, when bindings/push_constants counts do not match the kernel’s declared ABI, or when workgroups is zero or exceeds device limits; returns the recording errors from the underlying session otherwise.

Trait Implementations§

Source§

impl Clone for Engine

Source§

fn clone(&self) -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Engine

§

impl !Send for Engine

§

impl !Sync for Engine

§

impl !UnwindSafe for Engine

§

impl Forget for Engine

§

impl Freeze for Engine

§

impl Move for Engine

§

impl Unpin for Engine

§

impl UnsafeUnpin for Engine

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> 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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.