Skip to main content

Par

Enum Par 

Source
pub enum Par<'team> {
    Seq,
    Rayon(NonZeroUsize),
    // some variants omitted
}
Expand description

determines the parallelization configuration, and carries the right to execute with it

Par is neither Copy nor Clone: a Team owns exclusive authority over reserved threads, so a duplicate could hand the same threads to two concurrent children. Every function that runs work takes Par by value; a caller that needs another phase lends the parallelism with Par::reborrow, and concurrent children are created by splitting (see utils::thread::split), never by copying. Queries that only need the size (workspace requirements, thresholds) use ParShape or Par::degree.

use faer::{Par, ParShape};
// sizes are plain values
fn is_copy<T: Copy>() {}
is_copy::<ParShape>();
// phases lend, they do not copy
fn phase(_: Par<'_>) {}
let mut par = Par::Seq;
phase(par.reborrow());
phase(par);

Not Copy:

ⓘ
fn is_copy<T: Copy>() {}
is_copy::<faer::Par<'static>>();

Not Clone:

ⓘ
fn is_clone<T: Clone>() {}
is_clone::<faer::Par<'static>>();

A phase that takes the parallelism consumes it:

ⓘ
fn phase(_: faer::Par<'_>) {}
let par = faer::Par::Seq;
phase(par);
phase(par);

Concurrent children cannot both use the parent:

ⓘ
fn phase(_: faer::Par<'_>) {}
let par = faer::Par::Seq;
faer::utils::thread::join_raw(|_| phase(par), |_| phase(par), faer::Par::Seq);

Variants§

§

Seq

sequential, non portable across different platforms

§

Rayon(NonZeroUsize)

parallelized using the global rayon threadpool, non portable across different platforms

Implementations§

Source§

impl Par<'_>

Source

pub fn reborrow(&mut self) -> Par<'_>

lends the parallelism for one phase. The parent is exclusively borrowed and unusable while the lent value lives, so a phase sequence never holds the authority twice.

Source

pub fn shape(&self) -> ParShape

the shape of this parallelism, without the right to execute with it

Source

pub fn rayon(nthreads: usize) -> Self

returns Par::Rayon(nthreads) if nthreads is non-zero, or Par::Rayon(rayon::current_num_threads()) otherwise

Source

pub fn degree(&self) -> usize

the number of threads that should ideally execute an operation with the given parallelism

Trait Implementations§

Source§

impl<'team> Debug for Par<'team>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'team> Freeze for Par<'team>

§

impl<'team> RefUnwindSafe for Par<'team>

§

impl<'team> Send for Par<'team>

§

impl<'team> Sync for Par<'team>

§

impl<'team> Unpin for Par<'team>

§

impl<'team> UnsafeUnpin for Par<'team>

§

impl<'team> UnwindSafe for Par<'team>

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<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl ?Sized + Rng)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V