#[repr(C)]pub struct Application {Show 18 fields
pub compiled: Option<MachineCode<f64>>,
pub compiled_simd: Option<MachineCode<f64>>,
pub use_simd: bool,
pub use_threads: bool,
pub count_states: usize,
pub count_params: usize,
pub count_obs: usize,
pub count_diffs: usize,
pub config: Config,
pub prog: Program,
pub compiled_fast: Option<MachineCode<f64>>,
pub bytecode: CompiledMir,
pub params: Vec<f64>,
pub can_fast: bool,
pub first_state: usize,
pub first_param: usize,
pub first_obs: usize,
pub first_diff: usize,
}Fields§
§compiled: Option<MachineCode<f64>>§compiled_simd: Option<MachineCode<f64>>§use_simd: bool§use_threads: bool§count_states: usize§count_params: usize§count_obs: usize§count_diffs: usize§config: Config§prog: Program§compiled_fast: Option<MachineCode<f64>>§bytecode: CompiledMir§params: Vec<f64>§can_fast: bool§first_state: usize§first_param: usize§first_obs: usize§first_diff: usizeImplementations§
Source§impl Application
impl Application
Sourcepub fn call(&mut self, args: &[f64]) -> Vec<f64>
pub fn call(&mut self, args: &[f64]) -> Vec<f64>
Calls the compiled function.
args is a slice of f64 values, corresponding to the states.
The output is a Vec<f64>, corresponding to the observables (the expressions passed
to compile).
Sourcepub fn call_params(&mut self, args: &[f64], params: &[f64]) -> Vec<f64>
pub fn call_params(&mut self, args: &[f64], params: &[f64]) -> Vec<f64>
Sets the params and calls the compiled function.
args is a slice of f64 values, corresponding to the states.
params is a slice of f64 values, corresponding to the params.
The output is a Vec<f64>, corresponding to the observables (the expressions passed
to compile).
pub fn interpret<T>(&mut self, args: &[T], outs: &mut [T])where
T: Element,
pub fn interpret_matrix(&mut self, args: &[f64], outs: &mut [f64], n: usize)
Sourcepub fn evaluate<T>(&self, args: &[T], outs: &mut [T])where
T: Element,
pub fn evaluate<T>(&self, args: &[T], outs: &mut [T])where
T: Element,
Generic evaluate function for compiled Symbolica expressions
Sourcepub fn evaluate_single<T>(&self, args: &[T]) -> T
pub fn evaluate_single<T>(&self, args: &[T]) -> T
Generic evaluate_single function for compiled Symbolica expressions
Sourcepub fn evaluate_matrix<T>(&self, args: &[T], outs: &mut [T], n: usize)where
T: Element,
pub fn evaluate_matrix<T>(&self, args: &[T], outs: &mut [T], n: usize)where
T: Element,
Generic evaluate function for compiled Symbolica expressions The main entry point to compute matrices. The actual dispatched method depends on the configuration and the type of the arguments.
Sourcepub fn fast_func(&mut self) -> Result<FastFunc<'_>>
pub fn fast_func(&mut self) -> Result<FastFunc<'_>>
Returns a fast function.
Application call functions need to copy the input argument slice into
the function memory area and then copy the output to a Vec. This process
is acceptable for large and complex functions but incurs a penalty for
small functions. Therefore, for a certain subset of applications, Symjit
can compile a fast funcction and return a function pointer. Examples:
fn test_fast() -> Result<()> {
let x = Expr::var("x");
let y = Expr::var("y");
let z = Expr::var("z");
let u = &x * &(&y - &z).pow(&Expr::from(2));
let mut comp = Compiler::new();
let mut app = comp.compile(&[x, y, z], &[u])?;
let f = app.fast_func()?;
if let FastFunc::F3(f, _) = f {
let res = f(3.0, 5.0, 9.0);
println!("fast\t{:?}", &res);
}
Ok(())
}The conditions for a fast function are:
- A fast function can have 1 to 8 arguments.
- No SIMD and no parameters.
- It returns only a single value.
If these conditions are met, you can generate a fast functin by calling
app.fast_func(), with a return type of Result<FastFunc>. FastFunc is an
enum with eight variants F1, F2, ..., F8`, corresponding to
functions with 1 to 8 arguments.
Source§impl Application
impl Application
pub fn new(prog: Program, reals: HashSet<Loc>) -> Result<Application>
pub fn with_mir( prog: Program, reals: HashSet<Loc>, mir: Mir, ) -> Result<Application>
pub fn seal(self) -> Result<Applet>
pub fn as_applet(&self) -> &Applet
pub fn exec(&mut self)
pub fn exec_callable(&mut self, xx: &[f64]) -> f64
pub fn prepare_simd(&mut self)
pub fn get_fast( &mut self, ) -> Option<fn(*const f64, *const &mut [f64], usize, *const f64) -> i32>
pub fn exec_vectorized(&mut self, states: &mut Matrix<'_>, obs: &mut Matrix<'_>)
pub fn exec_vectorized_simple( &mut self, states: &Matrix<'_>, obs: &mut Matrix<'_>, )
pub fn exec_vectorized_scalar( &mut self, states: &mut Matrix<'_>, obs: &mut Matrix<'_>, threads: bool, )
pub fn exec_vectorized_simd( &mut self, states: &mut Matrix<'_>, obs: &mut Matrix<'_>, threads: bool, l: usize, )
pub fn dump(&mut self, name: &str, what: &str) -> bool
pub fn dumps(&self) -> Vec<u8> ⓘ
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Application
impl !RefUnwindSafe for Application
impl !Send for Application
impl !Sync for Application
impl Unpin for Application
impl UnsafeUnpin for Application
impl !UnwindSafe for Application
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> 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