ParallelExecutorWithDiagnostics

Struct ParallelExecutorWithDiagnostics 

Source
pub struct ParallelExecutorWithDiagnostics<E>{ /* private fields */ }
Expand description

A parallel executor which wraps another parallel executor E and collects diagnostics about:

  • how many threads are used for the parallel computation
  • how many times each thread received a tasks
  • average chunk size; i.e., average number of tasks, that each thread received
  • and finally, explicit chunk sizes for the first task assignments.

The diagnostics are printed on the stdout once the parallel computation is completed. Therefore, this executor is suitable only for test purposed, but not for production.

Any executor can be converted into executor with diagnostics. In the example below, executor of the default runner is converted to executor with diagnostics.

§Examples

use orx_parallel::*;

// normal execution

let range = 0..4096;
let sum = range
    .par()
    .map(|x| x + 1)
    .filter(|x| x.is_multiple_of(2))
    .sum();
assert_eq!(sum, 4196352);

// execution with diagnostics

let range = 0..4096;
let sum = range
    .par()
    .with_runner(DefaultRunner::default().with_diagnostics())
    .map(|x| x + 1)
    .filter(|x| x.is_multiple_of(2))
    .sum();
assert_eq!(sum, 4196352);

// prints diagnostics, which looks something like the following:
//
// - Number of threads used = 5
//
// - [Thread idx]: num_calls, num_tasks, avg_chunk_size, first_chunk_sizes
//   - [0]: 25, 1600, 64, [64, 64, 64, 64, 64, 64, 64, 64, 64, 64]
//   - [1]: 26, 1664, 64, [64, 64, 64, 64, 64, 64, 64, 64, 64, 64]
//   - [2]: 13, 832, 64, [64, 64, 64, 64, 64, 64, 64, 64, 64, 64]
//   - [3]: 0, 0, 0, []
//   - [4]: 0, 0, 0, []

Trait Implementations§

Source§

impl<E> Clone for ParallelExecutorWithDiagnostics<E>

Source§

fn clone(&self) -> ParallelExecutorWithDiagnostics<E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E> ParallelExecutor for ParallelExecutorWithDiagnostics<E>

Source§

type SharedState = SharedStateWithDiagnostics<<E as ParallelExecutor>::SharedState>

Data shared to the thread executors.
Source§

type ThreadExecutor = ThreadExecutorWithDiagnostics<E>

Thread executor that is responsible for executing the tasks allocated to a thread.
Source§

fn new( kind: ComputationKind, params: Params, initial_input_len: Option<usize>, max_num_threads: NonZeroUsize, ) -> Self

Creates a new parallel executor for the given computation kind, parallelization params and initial_input_len.
Source§

fn new_shared_state(&self) -> Self::SharedState

Creates an initial shared state.
Source§

fn do_spawn_new<I>( &self, num_spawned: NumSpawned, shared_state: &Self::SharedState, iter: &I, ) -> bool
where I: ConcurrentIter,

Returns true if it is beneficial to spawn a new thread provided that: Read more
Source§

fn new_thread_executor( &self, thread_idx: usize, shared_state: &Self::SharedState, ) -> Self::ThreadExecutor

Creates a new thread executor provided that the current parallel execution state is shared_state.
Source§

fn complete_task(self, shared_state: Self::SharedState)

Executes the finalization tasks when the entire parallel computation is completed.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

fn get_mut(&mut self) -> &mut T

Returns a mutable reference to self.
Source§

impl<T> SoR<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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