ArcRwLock

Struct ArcRwLock 

Source
pub struct ArcRwLock<T> { /* private fields */ }

Implementations§

Source§

impl ArcRwLock<DualNode>

Source

pub fn update(&self) -> &Self

when fused, dual node may be outdated; refresh here

Source

pub fn updated_index(&self) -> NodeIndex

Source

pub fn get_ancestor_blossom(&self) -> DualNodePtr

get parent blossom recursively

Source

pub fn get_secondary_ancestor_blossom(&self) -> DualNodePtr

get the parent blossom before the most parent one, useful when expanding a blossom

Source

pub fn get_all_vertices(&self) -> Vec<VertexIndex>

find all vertices that belongs to the dual node, i.e. any vertices inside a blossom

Source

pub fn get_representative_vertex(&self) -> VertexIndex

find a representative vertex

Source§

impl ArcRwLock<DualModuleInterface>

Source

pub fn new_empty() -> Self

create an empty interface

Source

pub fn new_load( syndrome_pattern: &SyndromePattern, dual_module_impl: &mut impl DualModuleImpl, ) -> Self

a dual module interface MUST be created given a concrete implementation of the dual module

Source

pub fn load( &self, syndrome_pattern: &SyndromePattern, dual_module_impl: &mut impl DualModuleImpl, )

Source

pub fn clear(&self)

a constant clear function, without dropping anything; this is for consideration of reducing the garbage collection time in the parallel solver, by distributing the clear cost into each thread but not the single main thread.

Source

pub fn flatten_nodes(&self, flattened_nodes: &mut Vec<Option<DualNodePtr>>)

DFS flatten the nodes

Source

pub fn create_defect_node( &self, vertex_idx: VertexIndex, dual_module_impl: &mut impl DualModuleImpl, ) -> DualNodePtr

Source

pub fn check_ptr_belonging(&self, dual_node_ptr: &DualNodePtr) -> bool

check whether a pointer belongs to this node, it will acquire a reader lock on dual_node_ptr

Source

pub fn create_blossom( &self, nodes_circle: Vec<DualNodePtr>, touching_children: Vec<(DualNodeWeak, DualNodeWeak)>, dual_module_impl: &mut impl DualModuleImpl, ) -> DualNodePtr

create a dual node corresponding to a blossom, automatically set the grow state of internal nodes; the nodes circle MUST starts with a growing node and ends with a shrinking node

Source

pub fn expand_blossom( &self, blossom_node_ptr: DualNodePtr, dual_module_impl: &mut impl DualModuleImpl, )

expand a blossom: note that different from Blossom V library, we do not maintain tree structure after a blossom is expanded; this is because we’re growing all trees together, and due to the natural of quantum codes, this operation is not likely to cause bottleneck as long as physical error rate is well below the threshold. All internal nodes will have a DualNodeGrowState::Grow state afterwards.

Source

pub fn set_grow_state( &self, dual_node_ptr: &DualNodePtr, grow_state: DualNodeGrowState, dual_module_impl: &mut impl DualModuleImpl, )

a helper function to update grow state

Source

pub fn grow(&self, length: Weight, dual_module_impl: &mut impl DualModuleImpl)

grow the dual module and update [DualModuleInterface::sum_]

Source

pub fn notify_grown(&self, length: Weight)

if a dual module spontaneously grow some value (e.g. with primal offloading), this function should be called

Source

pub fn grow_iterative( &self, length: Weight, dual_module_impl: &mut impl DualModuleImpl, )

grow a specific length globally but iteratively: will try to keep growing that much

Source

pub fn slow_fuse(&self, left: &Self, right: &Self)

fuse two interfaces by copying the nodes in other into myself

Source

pub fn fuse(&self, left: &Self, right: &Self)

fuse two interfaces by (virtually) copying the nodes in other into myself, with O(1) time complexity

Source

pub fn sanity_check(&self) -> Result<Vec<Option<DualNodePtr>>, String>

do a sanity check of if all the nodes are in consistent state

Source

pub fn sum_dual_variables(&self) -> Weight

Source§

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

Source

pub fn new_wrapper( serial_module: SerialModule, unit_index: usize, partition_info: Arc<PartitionInfo>, partition_unit: PartitionUnitPtr, enable_parallel_execution: bool, ) -> Self

create a simple wrapper over a serial dual module

Source§

impl<T> ArcRwLock<T>

Source

pub fn downgrade(&self) -> WeakRwLock<T>

Source§

impl ArcRwLock<PrimalModuleParallelUnit>

Source

pub fn new_wrapper( serial_module: PrimalModuleSerialPtr, unit_index: usize, partition_info: Arc<PartitionInfo>, ) -> Self

create a simple wrapper over a serial dual module

Source§

impl ArcRwLock<PrimalNodeInternal>

Source

pub fn update(&self) -> &Self

when fused, primal node may be outdated; refresh here

Source§

impl ArcRwLock<PrimalModuleSerial>

Source

pub fn get_primal_node_internal_ptr_option( &self, dual_node_ptr: &DualNodePtr, ) -> Option<PrimalNodeInternalPtr>

Source

pub fn get_primal_node_internal_ptr( &self, dual_node_ptr: &DualNodePtr, ) -> PrimalNodeInternalPtr

Source

pub fn get_outer_node( &self, primal_node_internal_ptr: PrimalNodeInternalPtr, ) -> PrimalNodeInternalPtr

get the outer node in the most up-to-date cache

Source

pub fn find_lowest_common_ancestor( &self, primal_node_internal_ptr_1: PrimalNodeInternalPtr, primal_node_internal_ptr_2: PrimalNodeInternalPtr, ) -> (PrimalNodeInternalPtr, Vec<PrimalNodeInternalPtr>, Vec<PrimalNodeInternalPtr>)

find the lowest common ancestor (LCA) of two nodes in the alternating tree, return (LCA, path_1, path_2) where path includes leaf but exclude the LCA

Source

pub fn match_subtree<D: DualModuleImpl>( tree_node_internal_ptr: PrimalNodeInternalPtr, interface_ptr: &DualModuleInterfacePtr, dual_module: &mut D, )

for any - node, match the children by matching them with + node

Source

pub fn augment_tree_given_matched<D: DualModuleImpl>( tree_node_internal_ptr: PrimalNodeInternalPtr, match_node_internal_ptr: PrimalNodeInternalPtr, tree_touching_ptr: DualNodeWeak, interface_ptr: &DualModuleInterfacePtr, dual_module: &mut D, )

for any + node, match it with another node will augment the whole tree, breaking out into several matched pairs; tree_grandson_ptr is the grandson of tree_node_internal_ptr that touches match_node_internal_ptr

Source

pub fn augment_tree_given_virtual_vertex<D: DualModuleImpl>( &self, tree_node_internal_ptr: PrimalNodeInternalPtr, virtual_vertex_index: VertexIndex, tree_touching_ptr: DualNodeWeak, interface_ptr: &DualModuleInterfacePtr, dual_module: &mut D, )

for any + node, match it with virtual boundary will augment the whole tree, breaking out into several matched pairs

Source

pub fn flatten_nodes( &self, flattened_nodes: &mut Vec<Option<PrimalNodeInternalPtr>>, )

DFS flatten the nodes

Source

pub fn slow_fuse(&self, left: &Self, right: &Self)

fuse two modules by copying the nodes in other into myself

Source

pub fn fuse(&self, left: &Self, right: &Self)

fuse two modules by (virtually) copying the nodes in other into myself, with O(1) time complexity

Source

pub fn sanity_check(&self) -> Result<Vec<Option<PrimalNodeInternalPtr>>, String>

do a sanity check of it’s tree structure and internal state

Source

pub fn collapse_tree<D: DualModuleImpl>( &self, primal_node_internal_ptr: PrimalNodeInternalPtr, interface_ptr: &DualModuleInterfacePtr, dual_module: &mut D, )

collapse a tree into a single blossom, just like what union-find decoder does. No MWPM guarantee once this is called.

Source§

impl ArcRwLock<PrimalNodeInternal>

Source

pub fn flatten_tree(&self, flattened_nodes: &mut Vec<PrimalNodeInternalPtr>)

DFS flatten the children of a tree

Trait Implementations§

Source§

impl<T> Clone for ArcRwLock<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Deref for ArcRwLock<T>

Source§

type Target = RwLock<RawRwLock, T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> PartialEq for ArcRwLock<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> RwLockPtr<T> for ArcRwLock<T>

Source§

fn new_ptr(ptr: Arc<RwLock<T>>) -> Self

Source§

fn new_value(obj: T) -> Self

Source§

fn ptr(&self) -> &Arc<RwLock<T>>

Source§

fn ptr_mut(&mut self) -> &mut Arc<RwLock<T>>

Source§

fn read_recursive(&self) -> RwLockReadGuard<'_, RawRwLock, ObjType>

Source§

fn write(&self) -> RwLockWriteGuard<'_, RawRwLock, ObjType>

Source§

fn ptr_eq(&self, other: &Self) -> bool

Source§

impl<T> Eq for ArcRwLock<T>

Auto Trait Implementations§

§

impl<T> Freeze for ArcRwLock<T>

§

impl<T> !RefUnwindSafe for ArcRwLock<T>

§

impl<T> Send for ArcRwLock<T>
where T: Send + Sync,

§

impl<T> Sync for ArcRwLock<T>
where T: Send + Sync,

§

impl<T> Unpin for ArcRwLock<T>

§

impl<T> !UnwindSafe for ArcRwLock<T>

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

§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. 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