CPUDataWriter

Struct CPUDataWriter 

Source
pub struct CPUDataWriter<'a> { /* private fields */ }
Expand description

CPU Data writer.

See more in DataWriter.

Trait Implementations§

Source§

impl<'b, 'a> Builder<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder, CPUExecutor> for CPUBuilder<'b>

Source§

type ErrorType = BuildError

Error type used if error encountered while execution.
Source§

fn user_defs(&mut self, user_defs: &str)

Adds additional user definition to code of simulations.
Source§

fn transform_helpers(&mut self)

Adds transform helpers. Read more
Source§

fn add_with_config<T>( &mut self, name: &str, circuit: Circuit<T>, code_config: CodeConfig<'_>, )
where T: Clone + Copy + Ord + PartialEq + Eq + Hash + Default + TryFrom<usize>, <T as TryFrom<usize>>::Error: Debug, usize: TryFrom<T>, <usize as TryFrom<T>>::Error: Debug,

Adds circuit to builder. name is name of function, circuit is circuit to simulate, code_config is code configuration.
Source§

fn build(self) -> Result<Vec<CPUExecutor>, Self::ErrorType>

Build code to simulations. If build succeeded then returns executors for simulations in addition order.
Source§

fn word_len(&self) -> u32

Returns length processor word in bits.
Source§

fn type_len(&self) -> u32

Returns type length in bits (includes only type length not word length if group_vec enabled).
Source§

fn is_empty(&self) -> bool

Returns true if nothing added to build.
Source§

fn is_executor_per_thread() -> bool

Returns true if any executor can be used per native thread.
Source§

fn is_data_holder_global() -> bool

Returns true if any data holder is global and it can be shared between any executors from any builder of that type.
Source§

fn is_data_holder_in_builder() -> bool

Returns true if any data holder is global and it can be shared between any executors from this builder.
Source§

fn preferred_input_count(&self) -> usize

Returns hint about preferred count of input.
Source§

fn add<T>( &mut self, name: &str, circuit: Circuit<T>, input_placement: Option<(&[usize], usize)>, output_placement: Option<(&[usize], usize)>, arg_inputs: Option<&[usize]>, )
where T: Clone + Copy + Ord + PartialEq + Eq + Hash + Default + TryFrom<usize>, <T as TryFrom<usize>>::Error: Debug, usize: TryFrom<T>, <usize as TryFrom<T>>::Error: Debug,

Adds circuit to builder. name is name of function, circuit is circuit to simulate. input_placement, output_placement and arg_inputs are part of code configuration of this simulation configuration.
Source§

fn add_simple<T>(&mut self, name: &str, circuit: Circuit<T>)
where T: Clone + Copy + Ord + PartialEq + Eq + Hash + Default + TryFrom<usize>, <T as TryFrom<usize>>::Error: Debug, usize: TryFrom<T>, <usize as TryFrom<T>>::Error: Debug,

Adds circuit to builder. name is name of function, circuit is circuit to simulate.
Source§

impl<'a> DataHolder<'a, CPUDataReader<'a>, CPUDataWriter<'a>> for CPUDataHolder

Source§

fn len(&self) -> usize

Returns current length of data.
Source§

fn get(&'a self) -> CPUDataReader<'a>

Returns data reader to read data in data holder.
Source§

fn get_mut(&'a mut self) -> CPUDataWriter<'a>

Returns data writer to write data to data holder.
Source§

fn process<F, Out>(&self, f: F) -> Out
where F: FnMut(&[u32]) -> Out,

Processes data in data holder by given function f and returns its output value.
Source§

fn process_mut<F, Out>(&mut self, f: F) -> Out
where F: FnMut(&mut [u32]) -> Out,

Processes data in data holder by given function f and returns its output value. Function f can modify data.
Source§

fn copy(&self) -> Self

Make copy of DataHolder with data that holds Data holder.
Source§

fn fill(&mut self, value: u32)

Fills data in data holder by given 32-bit value.
Source§

fn release(self) -> Vec<u32>

Release data from data holder.
Source§

fn free(self)

Free data holder with same data.
Source§

impl<'a> DataTransformer<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder> for CPUDataInputTransformer

Source§

type ErrorType = Infallible

Error type used if error encountered while execution.
Source§

fn transform( &mut self, input: &CPUDataHolder, ) -> Result<CPUDataHolder, Self::ErrorType>

Transforms data in input data holder. If succeeded then returns data holder with transformed data.
Source§

fn transform_reuse( &mut self, input: &CPUDataHolder, output: &mut CPUDataHolder, ) -> Result<(), Self::ErrorType>

Transforms data in input data holder. If succeeded then store transformed data in output data holder.
Source§

fn input_elem_len(&self) -> usize

Source§

fn output_elem_len(&self) -> usize

Source§

fn output_data_len(&self, len: usize) -> usize

Returns output data length. len is input data (for transformer) length.
Source§

impl<'a> DataTransformer<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder> for CPUDataOutputTransformer

Source§

fn transform_reuse( &mut self, output: &CPUDataHolder, input: &mut CPUDataHolder, ) -> Result<(), Self::ErrorType>

changed names of arguments: output - really input data, input - really output data

Source§

type ErrorType = Infallible

Error type used if error encountered while execution.
Source§

fn transform( &mut self, input: &CPUDataHolder, ) -> Result<CPUDataHolder, Self::ErrorType>

Transforms data in input data holder. If succeeded then returns data holder with transformed data.
Source§

fn input_elem_len(&self) -> usize

Source§

fn output_elem_len(&self) -> usize

Source§

fn output_data_len(&self, len: usize) -> usize

Returns output data length. len is input data (for transformer) length.
Source§

impl<'a> DataTransforms<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder, CPUDataInputTransformer, CPUDataOutputTransformer> for CPUExecutor

Source§

type ErrorType = Infallible

Error type used if error encountered while execution.
Source§

fn input_transformer( &self, input_elem_len: usize, bit_mapping: &[usize], ) -> Result<CPUDataInputTransformer, Self::ErrorType>

Returns input data transfomer. This transformer transforms input data in external form to internal form. Form of external input form described by input_elem_len and bit_mapping. input_len is length of input element in external form in bits and it should be divisible by to 32. bit_mapping is list of mapping: index of list is bit of output’s element (pack element) and value is bit of input’s (in external form) element. Input data is organized as tuple of 32-bit words. Single element of input data has input_elem_len bits.
Source§

fn output_transformer( &self, output_elem_len: usize, bit_mapping: &[usize], ) -> Result<CPUDataOutputTransformer, Self::ErrorType>

Returns output data transfomer. This transformer transforms output data in internal form to external form of output. Form of external output form described by output_elem_len and bit_mapping. output_len is length of output element in external form in bits and it should be divisble by 32-bit. bit_mapping is list of mapping: index of list is bit of input’s element (pack element) and value is bit of output’s (in external form) element. Output data is organized as tuple of 32-bit words. Single element of input data has output_elem_len bits.
Source§

impl<'a> DataWriter for CPUDataWriter<'a>

Source§

fn get_mut(&mut self) -> &mut [u32]

Returns mutable slice with data from Data holder.
Source§

impl<'a> Executor<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder> for CPUExecutor

Source§

type ErrorType = Error

Error type used if error encountered while execution.
Source§

fn input_len(&self) -> usize

Returns number of circuit inputs.
Source§

fn output_len(&self) -> usize

Returns number of circuit outputs.
Source§

fn real_input_len(&self) -> usize

Returns number of pack elements for input data (for assigned circuit inputs).
Source§

fn real_output_len(&self) -> usize

Returns number of pack elements for output data (for assigned circuit outputs).
Source§

fn elem_count(&self, input_len: usize) -> usize

Returns element count based on input length in 32-bit words.
Source§

unsafe fn execute_internal( &mut self, input: &CPUDataHolder, arg_input: u64, ) -> Result<CPUDataHolder, Self::ErrorType>

Only for implementation. Read more
Source§

unsafe fn execute_reuse_internal( &mut self, input: &CPUDataHolder, arg_input: u64, output: &mut CPUDataHolder, ) -> Result<(), Self::ErrorType>

Only for implementation. Read more
Source§

unsafe fn execute_single_internal( &mut self, output: &mut CPUDataHolder, arg_input: u64, ) -> Result<(), Self::ErrorType>

Only for implementation. Read more
Source§

unsafe fn execute_buffer_internal( &mut self, input: &CPUDataHolder, arg_input: u64, buffer: &mut CPUDataHolder, ) -> Result<CPUDataHolder, Self::ErrorType>

Only for implementation. Read more
Source§

unsafe fn execute_buffer_reuse_internal( &mut self, input: &CPUDataHolder, arg_input: u64, output: &mut CPUDataHolder, buffer: &mut CPUDataHolder, ) -> Result<(), Self::ErrorType>

Only for implementation. Read more
Source§

unsafe fn execute_buffer_single_internal( &mut self, output: &mut CPUDataHolder, arg_input: u64, buffer: &mut CPUDataHolder, ) -> Result<(), Self::ErrorType>

Only for implementation. Read more
Source§

fn new_data(&mut self, len: usize) -> CPUDataHolder

Creates new data. It returns data holder with zeroed data with length len 32-bit words.
Source§

fn new_data_from_vec(&mut self, data: Vec<u32>) -> CPUDataHolder

Creates new data. It returns data holder with data supplied by vector data.
Source§

fn new_data_from_slice(&mut self, data: &[u32]) -> CPUDataHolder

Creates new data. It returns data holder with data supplied by slice.
Source§

fn try_clone(&self) -> Option<Self>
where Self: Sized,

Try clone executor if possible.
Source§

fn is_single_buffer(&self) -> bool

Returns true if executor have single buffer property.
Source§

fn word_len(&self) -> u32

Returns processor word length.
Source§

fn output_is_aggregated(&self) -> bool

Returns true if output data will be processed by aggr_output_code.
Source§

fn aggr_output_len(&self) -> Option<usize>

Returns length of additional buffer in 32-bit words for aggr_output_code.
Source§

fn is_aggregated_to_buffer(&self) -> bool

Returns true if output data will be processed by aggr_output_code and stored to additional buffer.
Source§

fn input_is_populated(&self) -> bool

Returns true if input data will be populated by pop_input_code.
Source§

fn pop_input_len(&self) -> Option<usize>

Returns length of additional buffer in 32-bit words for pop_input_code.
Source§

fn is_populated_from_buffer(&self) -> bool

Returns true if input data will be populated from additional buffer.
Source§

fn dont_clear_outputs(&self) -> bool

Returns true if dont_clear_outputs set.
Source§

fn is_sequential_execution(&self) -> bool

Returns true if executor executes simulation in sequentially (not parallel way).
Source§

fn inner_loop(&self) -> Option<u32>

Returns inner loop maximal number of iterations.
Source§

fn execute(&mut self, input: &D, arg_input: u64) -> Result<D, Self::ErrorType>

Executes simulation. Input data passed by input argument as data holder. Additionaly if some circuit inputs assigned to arg input then arg_input will be used, otherwise arg_input will be ignored. If execution successfully finished then method returns data holder with output data. Read more
Source§

fn execute_reuse( &mut self, input: &D, arg_input: u64, output: &mut D, ) -> Result<(), Self::ErrorType>

Executes simulation. Input data passed by input argument as data holder. Additionaly if some circuit inputs assigned to arg input then arg_input will be used, otherwise arg_input will be ignored. If execution successfully finished then method store output data into output data holder and returns Ok. Read more
Source§

fn execute_single( &mut self, output: &mut D, arg_input: u64, ) -> Result<(), Self::ErrorType>

Executes simulation. Input data passed by output argument as data holder. Additionaly if some circuit inputs assigned to arg input then arg_input will be used, otherwise arg_input will be ignored. If execution successfully finished then method returns data holder with output data. Read more
Source§

fn execute_buffer( &mut self, input: &D, arg_input: u64, buffer: &mut D, ) -> Result<D, Self::ErrorType>

Executes simulation. Input data passed by input argument as data holder. Additionaly if some circuit inputs assigned to arg input then arg_input will be used, otherwise arg_input will be ignored. Additional buffer data holder holds data for pop_input_code or can be stored by aggr_output_code. If execution successfully finished then method returns data holder with output data. Read more
Source§

fn execute_buffer_reuse( &mut self, input: &D, arg_input: u64, output: &mut D, buffer: &mut D, ) -> Result<(), Self::ErrorType>

Executes simulation. Input data passed by input argument as data holder. Additionaly if some circuit inputs assigned to arg input then arg_input will be used, otherwise arg_input will be ignored. Additional buffer data holder holds data for pop_input_code or can be stored by aggr_output_code. If execution successfully finished then method store output data into output data holder and returns Ok. Read more
Source§

fn execute_buffer_single( &mut self, output: &mut D, arg_input: u64, buffer: &mut D, ) -> Result<(), Self::ErrorType>

Executes simulation. Input data passed by output argument as data holder. Additionaly if some circuit inputs assigned to arg input then arg_input will be used, otherwise arg_input will be ignored. Additional buffer data holder holds data for pop_input_code or can be stored by aggr_output_code. If execution successfully finished then method store output data into output data holder and returns Ok. Read more
Source§

fn input_data_len(&self, elem_num: usize) -> usize

Returns input data (for circuit inputs) length in 32-bit words for given number of elements.
Source§

fn output_data_len(&self, elem_num: usize) -> usize

Returns output data (for circuit outputs) length in 32-bit words for given number of elements.
Source§

fn new_data_input_elems(&mut self, elem_num: usize) -> D

Returns input data holder (for circuit inputs) with zeroed data with length matched to given number of elements.
Source§

fn new_data_output_elems(&mut self, elem_num: usize) -> D

Returns output data holder (for circuit outputs) with zeroed data with length matched to given number of elements.
Source§

fn need_clear_outputs(&self) -> bool

Returns true if data should be cleared manually.

Auto Trait Implementations§

§

impl<'a> Freeze for CPUDataWriter<'a>

§

impl<'a> RefUnwindSafe for CPUDataWriter<'a>

§

impl<'a> Send for CPUDataWriter<'a>

§

impl<'a> Sync for CPUDataWriter<'a>

§

impl<'a> Unpin for CPUDataWriter<'a>

§

impl<'a> !UnwindSafe for CPUDataWriter<'a>

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> 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, 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.