pub struct Application {Show 17 fields
pub prog: Program,
pub mir: Mir,
pub compiled: Box<dyn Compiled<f64>>,
pub compiled_simd: Option<Box<dyn Compiled<f64>>>,
pub compiled_fast: Option<Box<dyn Compiled<f64>>>,
pub params: Vec<f64>,
pub use_simd: bool,
pub use_threads: bool,
pub can_fast: bool,
pub first_state: usize,
pub first_param: usize,
pub first_obs: usize,
pub first_diff: usize,
pub count_states: usize,
pub count_params: usize,
pub count_obs: usize,
pub count_diffs: usize,
}Fields§
§prog: Program§mir: Mir§compiled: Box<dyn Compiled<f64>>§compiled_simd: Option<Box<dyn Compiled<f64>>>§compiled_fast: Option<Box<dyn Compiled<f64>>>§params: Vec<f64>§use_simd: bool§use_threads: bool§can_fast: bool§first_state: usize§first_param: usize§first_obs: usize§first_diff: usize§count_states: usize§count_params: usize§count_obs: usize§count_diffs: 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).
Sourcepub fn evaluate<T>(&mut self, args: &[T], outs: &mut [T])where
T: Copy,
pub fn evaluate<T>(&mut self, args: &[T], outs: &mut [T])where
T: Copy,
Generic evaluate function for compiled Symbolica expressions
Sourcepub fn evaluate_single<T>(&mut self, args: &[T]) -> T
pub fn evaluate_single<T>(&mut self, args: &[T]) -> T
Generic evaluate_single function for compiled Symbolica expressions
Sourcepub fn evaluate_simd<T>(&mut self, args: &[T], outs: &mut [T])where
T: Copy,
pub fn evaluate_simd<T>(&mut self, args: &[T], outs: &mut [T])where
T: Copy,
Generic SIMD evaluate function for compiled Symbolica expressions
Sourcepub fn evaluate_simd_single<T>(&mut self, args: &[T]) -> T
pub fn evaluate_simd_single<T>(&mut self, args: &[T]) -> T
Generic SIMD evaluate_single function for compiled Symbolica expressions
Sourcepub fn evaluate_matrix_with_threads(
&mut self,
args: &[f64],
outs: &mut [f64],
n: usize,
)
pub fn evaluate_matrix_with_threads( &mut self, args: &[f64], outs: &mut [f64], n: usize, )
Generic evaluate function for compiled Symbolica expressions
Sourcepub fn evaluate_matrix_without_threads(
&mut self,
args: &[f64],
outs: &mut [f64],
n: usize,
)
pub fn evaluate_matrix_without_threads( &mut self, args: &[f64], outs: &mut [f64], n: usize, )
Generic evaluate function for compiled Symbolica expressions
pub fn evaluate_matrix_with_threads_simd( &mut self, args: &[f64], outs: &mut [f64], n: usize, transpose: bool, )
pub fn evaluate_matrix_without_threads_simd( &mut self, args: &[f64], outs: &mut [f64], n: usize, transpose: bool, )
pub fn evaluate_matrix_bytecode( &mut self, args: &[f64], outs: &mut [f64], n: usize, )
Sourcepub fn evaluate_matrix(&mut self, args: &[f64], outs: &mut [f64], n: usize)
pub fn evaluate_matrix(&mut self, args: &[f64], outs: &mut [f64], n: usize)
Generic evaluate function for compiled Symbolica expressions
pub fn evaluate_complex_matrix( &mut self, args: &[Complex<f64>], outs: &mut [Complex<f64>], n: usize, )
Sourcepub fn evaluate_simd_matrix<T>(&mut self, args: &[T], outs: &mut [T], n: usize)where
T: Copy,
pub fn evaluate_simd_matrix<T>(&mut self, args: &[T], outs: &mut [T], n: usize)where
T: Copy,
Generic evaluate function for compiled Symbolica expressions
Sourcepub fn call_simd(&mut self, args: &[__m256d]) -> Result<Vec<__m256d>, Error>
pub fn call_simd(&mut self, args: &[__m256d]) -> Result<Vec<__m256d>, Error>
Calls the compiled SIMD function.
args is a slice of __m256d values, corresponding to the states.
The output is an Result wrapping Vec<__m256d>, corresponding to the observables
(the expressions passed to compile).
Note: currently, this function only works on X86-64 CPUs with the AVX extension. Intel
introduced the AVX instruction set in 2011; therefore, most intel and AMD processors
support it. If SIMD is not supported, this function returns None.
Sourcepub fn call_simd_params(
&mut self,
args: &[__m256d],
params: &[f64],
) -> Result<Vec<__m256d>, Error>
pub fn call_simd_params( &mut self, args: &[__m256d], params: &[f64], ) -> Result<Vec<__m256d>, Error>
Sets the params and calls the compiled SIMD function.
args is a slice of __m256d values, corresponding to the states.
params is a slice of f64 values.
The output is a Result wrapping a Vec<__m256d>, corresponding to the observables
(the expressions passed to compile).
Note: currently, this function only works on X86-64 CPUs with the AVX extension. Intel
introduced the AVX instruction set in 2011; therefore, most intel and AMD processors
support it. If SIMD is not supported, this function returns None.
Sourcepub fn fast_func(&mut self) -> Result<FastFunc<'_>, Error>
pub fn fast_func(&mut self) -> Result<FastFunc<'_>, Error>
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>, df: &Defuns, ) -> Result<Application, Error>
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)>
pub fn exec_vectorized(&mut self, states: &Matrix, obs: &mut Matrix)
pub fn exec_vectorized_simple(&mut self, states: &Matrix, obs: &mut Matrix)
pub fn exec_vectorized_scalar( &mut self, states: &Matrix, obs: &mut Matrix, threads: bool, )
pub fn exec_vectorized_simd( &mut self, states: &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 !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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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