DualModuleParallelUnit

Struct DualModuleParallelUnit 

Source
pub struct DualModuleParallelUnit<SerialModule: DualModuleImpl + Send + Sync> {
Show 14 fields pub unit_index: usize, pub partition_info: Arc<PartitionInfo>, pub partition_unit: PartitionUnitPtr, pub is_active: bool, pub whole_range: VertexRange, pub owning_range: VertexRange, pub extra_descendant_mirrored_vertices: HashSet<VertexIndex>, pub serial_module: SerialModule, pub children: Option<(DualModuleParallelUnitWeak<SerialModule>, DualModuleParallelUnitWeak<SerialModule>)>, pub parent: Option<DualModuleParallelUnitWeak<SerialModule>>, pub elevated_dual_nodes: PtrWeakHashSet<DualNodeWeak>, pub empty_sync_request: Vec<SyncRequest>, pub enable_parallel_execution: bool, pub has_active_node: bool,
}

Fields§

§unit_index: usize

the index

§partition_info: Arc<PartitionInfo>

partition information generated by the config

§partition_unit: PartitionUnitPtr

information shared with serial module

§is_active: bool

whether it’s active or not; some units are “placeholder” units that are not active until they actually fuse their children

§whole_range: VertexRange

the vertex range of this parallel unit consists of all the owning_range of its descendants

§owning_range: VertexRange

the vertices owned by this unit, note that owning_range is a subset of whole_range

§extra_descendant_mirrored_vertices: HashSet<VertexIndex>

the vertices that are mirrored outside of whole_range, in order to propagate a vertex’s sync event to every unit that mirrors it

§serial_module: SerialModule

the owned serial dual module

§children: Option<(DualModuleParallelUnitWeak<SerialModule>, DualModuleParallelUnitWeak<SerialModule>)>

left and right children dual modules

§parent: Option<DualModuleParallelUnitWeak<SerialModule>>

parent dual module

§elevated_dual_nodes: PtrWeakHashSet<DualNodeWeak>

elevated dual nodes: whose descendent not on the representative path of a dual node

§empty_sync_request: Vec<SyncRequest>

an empty sync requests queue just to implement the trait

§enable_parallel_execution: bool

run things in thread pool

§has_active_node: bool

whether any descendant unit has active dual node

Implementations§

Source§

impl<SerialModule: DualModuleImpl + Send + Sync> DualModuleParallelUnit<SerialModule>

Source

pub fn static_fuse(&mut self)

statically fuse the children of this unit

Source

pub fn fuse( &mut self, parent_interface: &DualModuleInterfacePtr, children_interfaces: (&DualModuleInterfacePtr, &DualModuleInterfacePtr), )

fuse the children of this unit and also fuse the interfaces of them

Source

pub fn iterative_bias_dual_node_index(&mut self, bias: NodeIndex)

Source

pub fn is_vertex_in_descendant(&self, vertex_index: VertexIndex) -> bool

if any descendant unit mirror or own the vertex

Source

pub fn elevated_dual_nodes_contains_any(&self, nodes: &[DualNodePtr]) -> bool

check if elevated_dual_nodes contains any dual node in the list

Trait Implementations§

Source§

impl<SerialModule: DualModuleImpl + Send + Sync> DualModuleImpl for DualModuleParallelUnit<SerialModule>

We cannot implement async function because a RwLockWriteGuard implements !Send

Source§

fn new_empty(_initializer: &SolverInitializer) -> Self

clear all growth and existing dual nodes

Source§

fn clear(&mut self)

clear all growth and existing dual nodes

Source§

fn add_dual_node(&mut self, dual_node_ptr: &DualNodePtr)

add a new dual node from dual module root

Source§

fn remove_blossom(&mut self, dual_node_ptr: DualNodePtr)

remove a blossom, note that this dual node ptr is already expanded from the root: normally you only need to remove this blossom; when force flag is set, remove blossom even if its dual variable is not 0: this action cannot be undone
Source§

fn set_grow_state( &mut self, dual_node_ptr: &DualNodePtr, grow_state: DualNodeGrowState, )

update grow state
Source§

fn compute_maximum_update_length_dual_node( &mut self, dual_node_ptr: &DualNodePtr, is_grow: bool, simultaneous_update: bool, ) -> MaxUpdateLength

An optional function that helps to break down the implementation of DualModuleImpl::compute_maximum_update_length check the maximum length to grow (shrink) specific dual node, if length is 0, give the reason of why it cannot further grow (shrink). if is_grow is false, return length <= 0, in any case |length| is maximized so that at least one edge becomes fully grown or fully not-grown. if simultaneous_update is true, also check for the peer node according to DualNode::grow_state.
Source§

fn compute_maximum_update_length(&mut self) -> GroupMaxUpdateLength

check the maximum length to grow (shrink) for all nodes, return a list of conflicting reason and a single number indicating the maximum length to grow: this number will be 0 if any conflicting reason presents
Source§

fn grow_dual_node(&mut self, dual_node_ptr: &DualNodePtr, length: Weight)

An optional function that can manipulate individual dual node, not necessarily supported by all implementations
Source§

fn grow(&mut self, length: Weight)

grow a specific length globally, length must be positive. note that reversing the process is possible, but not recommended: to do that, reverse the state of each dual node, Grow->Shrink, Shrink->Grow
Source§

fn load_edge_modifier(&mut self, edge_modifier: &[(EdgeIndex, Weight)])

optional support for edge modifier. for example, erasure errors temporarily set some edges to 0 weight. When it clears, those edges must be reverted back to the original weight
Source§

fn prepare_nodes_shrink( &mut self, nodes_circle: &[DualNodePtr], ) -> &mut Vec<SyncRequest>

prepare a list of nodes as shrinking state; useful in creating a blossom
Source§

fn prepare_all(&mut self) -> &mut Vec<SyncRequest>

prepare the growing or shrinking state of all nodes and return a list of sync requests in case of mirrored vertices are changed
Source§

fn execute_sync_event(&mut self, sync_event: &SyncRequest)

execute a synchronize event by updating the state of a vertex and also update the internal dual node accordingly
Source§

fn add_defect_node(&mut self, dual_node_ptr: &DualNodePtr)

helper function to specifically add a syndrome node
Source§

fn add_blossom(&mut self, dual_node_ptr: &DualNodePtr)

helper function to specifically add a blossom node
Source§

fn load_erasures(&mut self, erasures: &[EdgeIndex])

an erasure error means this edge is totally uncertain: p=0.5, so new weight = ln((1-p)/p) = 0
Source§

fn load_dynamic_weights(&mut self, dynamic_weights: &[(EdgeIndex, Weight)])

Source§

fn generate_profiler_report(&self) -> Value

performance profiler report
Source§

fn new_partitioned( _partitioned_initializer: &PartitionedSolverInitializer, ) -> Self
where Self: Sized,

create a partitioned dual module (hosting only a subgraph and subset of dual nodes) to be used in the parallel dual module
Source§

fn contains_dual_node(&self, _dual_node_ptr: &DualNodePtr) -> bool

judge whether the current module hosts the dual node
Source§

fn contains_dual_nodes_any(&self, dual_node_ptrs: &[DualNodePtr]) -> bool

judge whether the current module hosts any of these dual node
Source§

fn contains_vertex(&self, _vertex_index: VertexIndex) -> bool

judge whether the current module hosts a vertex
Source§

fn bias_dual_node_index(&mut self, _bias: NodeIndex)

bias the global dual node indices
Source§

impl<SerialModule: DualModuleImpl + FusionVisualizer + Send + Sync> FusionVisualizer for DualModuleParallelUnit<SerialModule>

Source§

fn snapshot(&self, abbrev: bool) -> Value

take a snapshot, set abbrev to true to save space

Auto Trait Implementations§

§

impl<SerialModule> Freeze for DualModuleParallelUnit<SerialModule>
where SerialModule: Freeze,

§

impl<SerialModule> !RefUnwindSafe for DualModuleParallelUnit<SerialModule>

§

impl<SerialModule> Send for DualModuleParallelUnit<SerialModule>

§

impl<SerialModule> Sync for DualModuleParallelUnit<SerialModule>

§

impl<SerialModule> Unpin for DualModuleParallelUnit<SerialModule>
where SerialModule: Unpin,

§

impl<SerialModule> !UnwindSafe for DualModuleParallelUnit<SerialModule>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

type Error = <U as TryFrom<T>>::Error

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

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