Skip to main content

Runtime

Trait Runtime 

Source
pub trait Runtime: Send + Sync {
    type Buffer: RuntimeBuffer;

    // Required methods
    fn capabilities(&self) -> RuntimeCapabilities;
    fn zeros(&self, length: usize) -> Result<Self::Buffer>;
    fn upload(&self, values: &[Complex64]) -> Result<Self::Buffer>;
    fn to_host(&self, buffer: &Self::Buffer) -> Result<Vec<Complex64>>;
    fn fill(&self, buffer: &mut Self::Buffer, value: Complex64) -> Result<()>;
    fn axpy(
        &self,
        alpha: Complex64,
        input: &Self::Buffer,
        output: &mut Self::Buffer,
    ) -> Result<()>;
    fn scale(&self, alpha: Complex64, buffer: &mut Self::Buffer) -> Result<()>;
    fn dotc(
        &self,
        left: &Self::Buffer,
        right: &Self::Buffer,
    ) -> Result<Complex64>;

    // Provided method
    fn norm(&self, buffer: &Self::Buffer) -> Result<f64> { ... }
}
Expand description

Coarse-grained storage and vector primitives required by iterative methods.

A future GPU or MPI backend implements this trait with its native buffer. No basis, model, or operator-string type crosses this boundary.

Required Associated Types§

Source

type Buffer: RuntimeBuffer

Backend-native vector type.

Required Methods§

Source

fn capabilities(&self) -> RuntimeCapabilities

Report the execution resources supplied by this runtime.

Source

fn zeros(&self, length: usize) -> Result<Self::Buffer>

Allocate a zero-filled complex vector.

Source

fn upload(&self, values: &[Complex64]) -> Result<Self::Buffer>

Copy a host slice into backend-owned storage.

Source

fn to_host(&self, buffer: &Self::Buffer) -> Result<Vec<Complex64>>

Copy backend-owned storage to the host.

Source

fn fill(&self, buffer: &mut Self::Buffer, value: Complex64) -> Result<()>

Fill a backend buffer with one complex value.

Source

fn axpy( &self, alpha: Complex64, input: &Self::Buffer, output: &mut Self::Buffer, ) -> Result<()>

Compute output += alpha * input.

Source

fn scale(&self, alpha: Complex64, buffer: &mut Self::Buffer) -> Result<()>

Scale a vector in place.

Source

fn dotc(&self, left: &Self::Buffer, right: &Self::Buffer) -> Result<Complex64>

Return the conjugating inner product of two buffers.

Provided Methods§

Source

fn norm(&self, buffer: &Self::Buffer) -> Result<f64>

Return the Euclidean norm derived from Runtime::dotc.

Implementors§