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>
impl<'b, 'a> Builder<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder, CPUExecutor> for CPUBuilder<'b>
Source§type ErrorType = BuildError
type ErrorType = BuildError
Error type used if error encountered while execution.
Source§fn user_defs(&mut self, user_defs: &str)
fn user_defs(&mut self, user_defs: &str)
Adds additional user definition to code of simulations.
Source§fn transform_helpers(&mut self)
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<'_>,
)
fn add_with_config<T>( &mut self, name: &str, circuit: Circuit<T>, code_config: CodeConfig<'_>, )
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>
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 type_len(&self) -> u32
fn type_len(&self) -> u32
Returns type length in bits (includes only type length not word length if
group_vec enabled).
Source§fn is_executor_per_thread() -> bool
fn is_executor_per_thread() -> bool
Returns true if any executor can be used per native thread.
Source§fn is_data_holder_global() -> bool
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
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
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]>,
)
fn add<T>( &mut self, name: &str, circuit: Circuit<T>, input_placement: Option<(&[usize], usize)>, output_placement: Option<(&[usize], usize)>, arg_inputs: Option<&[usize]>, )
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>)
fn add_simple<T>(&mut self, name: &str, circuit: Circuit<T>)
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
impl<'a> DataHolder<'a, CPUDataReader<'a>, CPUDataWriter<'a>> for CPUDataHolder
Source§fn get(&'a self) -> CPUDataReader<'a>
fn get(&'a self) -> CPUDataReader<'a>
Returns data reader to read data in data holder.
Source§fn get_mut(&'a mut self) -> CPUDataWriter<'a>
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
fn process<F, Out>(&self, f: F) -> 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
fn process_mut<F, Out>(&mut self, f: F) -> Out
Processes data in data holder by given function
f and returns its output value.
Function f can modify data.Source§impl<'a> DataTransformer<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder> for CPUDataInputTransformer
impl<'a> DataTransformer<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder> for CPUDataInputTransformer
Source§type ErrorType = Infallible
type ErrorType = Infallible
Error type used if error encountered while execution.
Source§fn transform(
&mut self,
input: &CPUDataHolder,
) -> Result<CPUDataHolder, Self::ErrorType>
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>
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.fn input_elem_len(&self) -> usize
fn output_elem_len(&self) -> usize
Source§fn output_data_len(&self, len: usize) -> usize
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
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>
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
type ErrorType = Infallible
Error type used if error encountered while execution.
Source§fn transform(
&mut self,
input: &CPUDataHolder,
) -> Result<CPUDataHolder, Self::ErrorType>
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.fn input_elem_len(&self) -> usize
fn output_elem_len(&self) -> usize
Source§fn output_data_len(&self, len: usize) -> usize
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
impl<'a> DataTransforms<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder, CPUDataInputTransformer, CPUDataOutputTransformer> for CPUExecutor
Source§type ErrorType = Infallible
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>
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>
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>
impl<'a> DataWriter for CPUDataWriter<'a>
Source§impl<'a> Executor<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder> for CPUExecutor
impl<'a> Executor<'a, CPUDataReader<'a>, CPUDataWriter<'a>, CPUDataHolder> for CPUExecutor
Source§fn output_len(&self) -> usize
fn output_len(&self) -> usize
Returns number of circuit outputs.
Source§fn real_input_len(&self) -> usize
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
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
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>
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>
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>
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>
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>
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>
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
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
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
fn new_data_from_slice(&mut self, data: &[u32]) -> CPUDataHolder
Creates new data. It returns data holder with data supplied by slice.
Source§fn is_single_buffer(&self) -> bool
fn is_single_buffer(&self) -> bool
Returns true if executor have single buffer property.
Source§fn output_is_aggregated(&self) -> bool
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>
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
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
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>
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
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
fn dont_clear_outputs(&self) -> bool
Returns true if dont_clear_outputs set.
Source§fn is_sequential_execution(&self) -> bool
fn is_sequential_execution(&self) -> bool
Returns true if executor executes simulation in sequentially (not parallel way).
Source§fn inner_loop(&self) -> Option<u32>
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>
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 moreSource§fn execute_reuse(
&mut self,
input: &D,
arg_input: u64,
output: &mut D,
) -> Result<(), Self::ErrorType>
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 moreSource§fn execute_single(
&mut self,
output: &mut D,
arg_input: u64,
) -> Result<(), Self::ErrorType>
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 moreSource§fn execute_buffer(
&mut self,
input: &D,
arg_input: u64,
buffer: &mut D,
) -> Result<D, Self::ErrorType>
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 moreSource§fn execute_buffer_reuse(
&mut self,
input: &D,
arg_input: u64,
output: &mut D,
buffer: &mut D,
) -> Result<(), Self::ErrorType>
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 moreSource§fn execute_buffer_single(
&mut self,
output: &mut D,
arg_input: u64,
buffer: &mut D,
) -> Result<(), Self::ErrorType>
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 moreSource§fn input_data_len(&self, elem_num: usize) -> usize
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
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
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
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
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> 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
Mutably borrows from an owned value. Read more
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>
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 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>
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