Skip to content

perf: vectorized small lblt prototype #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions faer-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,46 @@ impl<T: RealField> core::ops::Mul<&ComplexImpl<T>> for &ComplexImpl<T> {
}
}

impl<T: RealField> core::ops::Neg for ComplexImpl<T> {
type Output = ComplexImpl<T>;

#[inline]
fn neg(self) -> Self::Output {
use math_utils::*;

ComplexImpl(neg(&self.0))
}
}
impl<T: RealField> core::ops::Add<ComplexImpl<T>> for ComplexImpl<T> {
type Output = ComplexImpl<T>;

#[inline]
fn add(self, rhs: ComplexImpl<T>) -> Self::Output {
use math_utils::*;

ComplexImpl(add(&self.0, &rhs.0))
}
}
impl<T: RealField> core::ops::Sub<ComplexImpl<T>> for ComplexImpl<T> {
type Output = ComplexImpl<T>;

#[inline]
fn sub(self, rhs: ComplexImpl<T>) -> Self::Output {
use math_utils::*;

ComplexImpl(sub(&self.0, &rhs.0))
}
}
impl<T: RealField> core::ops::Mul<ComplexImpl<T>> for ComplexImpl<T> {
type Output = ComplexImpl<T>;

#[inline]
fn mul(self, rhs: ComplexImpl<T>) -> Self::Output {
use math_utils::*;

ComplexImpl(mul(&self.0, &rhs.0))
}
}
impl<T> From<Complex<T>> for ComplexImpl<T> {
#[inline]
fn from(value: Complex<T>) -> Self {
Expand Down
6 changes: 4 additions & 2 deletions faer/examples/lblt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use diol::prelude::*;
use dyn_stack::{MemBuffer, MemStack};
use faer::diag::Diag;
use faer::linalg::cholesky::lblt;
use faer::linalg::cholesky::lblt::factor::PivotingStrategy;
use faer::prelude::*;
use faer::reborrow::ReborrowMut;
use faer::stats::prelude::*;
Expand Down Expand Up @@ -88,7 +89,8 @@ fn faer(bencher: Bencher, PlotArg(n): PlotArg) {
let perm_inv = &mut *vec![0usize; n];

let par = Par::Seq;
let params = default();
let mut params: faer::Spec<faer::linalg::cholesky::lblt::factor::LbltParams, f64> = default();
params.pivoting = PivotingStrategy::Partial;

let scratch = lblt::factor::cholesky_in_place_scratch::<usize, f64>(n, par, params);
let mut mem = MemBuffer::new(scratch);
Expand All @@ -113,7 +115,7 @@ fn main() -> eyre::Result<()> {

f
},
[64, 96, 128, 192, 256, 1024, 2048, 4096, 8192].map(PlotArg),
[8, 16, 32, 64, 96, 128, 192, 256, 1024, 2048, 4096, 8192].map(PlotArg),
);

bench.run()?;
Expand Down
9 changes: 6 additions & 3 deletions faer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,19 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate std;

#[doc(hidden)]
pub extern crate generativity;

/// see: [`generativity::make_guard`]
#[macro_export]
macro_rules! make_guard {
($($name:ident),* $(,)?) => {$(
#[allow(unused_unsafe)]
let $name = unsafe { extern crate generativity; ::generativity::Id::new() };
let $name = unsafe { $crate::generativity::Id::new() };
#[allow(unused, unused_unsafe)]
let lifetime_brand = unsafe { extern crate generativity; ::generativity::LifetimeBrand::new(&$name) };
let lifetime_brand = unsafe { $crate::generativity::LifetimeBrand::new(&$name) };
#[allow(unused_unsafe)]
let $name = unsafe { extern crate generativity; ::generativity::Guard::new($name) };
let $name = unsafe { $crate::generativity::Guard::new($name) };
)*};
}

Expand Down
Loading
Loading