pub struct ArcRwLock<T> { /* private fields */ }Implementations§
Source§impl ArcRwLock<DualNode>
impl ArcRwLock<DualNode>
pub fn updated_index(&self) -> NodeIndex
Sourcepub fn get_ancestor_blossom(&self) -> DualNodePtr
pub fn get_ancestor_blossom(&self) -> DualNodePtr
get parent blossom recursively
Sourcepub fn get_secondary_ancestor_blossom(&self) -> DualNodePtr
pub fn get_secondary_ancestor_blossom(&self) -> DualNodePtr
get the parent blossom before the most parent one, useful when expanding a blossom
Sourcepub fn get_all_vertices(&self) -> Vec<VertexIndex> ⓘ
pub fn get_all_vertices(&self) -> Vec<VertexIndex> ⓘ
find all vertices that belongs to the dual node, i.e. any vertices inside a blossom
Sourcepub fn get_representative_vertex(&self) -> VertexIndex
pub fn get_representative_vertex(&self) -> VertexIndex
find a representative vertex
Source§impl ArcRwLock<DualModuleInterface>
impl ArcRwLock<DualModuleInterface>
Sourcepub fn new_load(
syndrome_pattern: &SyndromePattern,
dual_module_impl: &mut impl DualModuleImpl,
) -> Self
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
pub fn load( &self, syndrome_pattern: &SyndromePattern, dual_module_impl: &mut impl DualModuleImpl, )
Sourcepub fn clear(&self)
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.
Sourcepub fn flatten_nodes(&self, flattened_nodes: &mut Vec<Option<DualNodePtr>>)
pub fn flatten_nodes(&self, flattened_nodes: &mut Vec<Option<DualNodePtr>>)
DFS flatten the nodes
pub fn create_defect_node( &self, vertex_idx: VertexIndex, dual_module_impl: &mut impl DualModuleImpl, ) -> DualNodePtr
Sourcepub fn check_ptr_belonging(&self, dual_node_ptr: &DualNodePtr) -> bool
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
Sourcepub fn create_blossom(
&self,
nodes_circle: Vec<DualNodePtr>,
touching_children: Vec<(DualNodeWeak, DualNodeWeak)>,
dual_module_impl: &mut impl DualModuleImpl,
) -> DualNodePtr
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
Sourcepub fn expand_blossom(
&self,
blossom_node_ptr: DualNodePtr,
dual_module_impl: &mut impl DualModuleImpl,
)
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.
Sourcepub fn set_grow_state(
&self,
dual_node_ptr: &DualNodePtr,
grow_state: DualNodeGrowState,
dual_module_impl: &mut impl DualModuleImpl,
)
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
Sourcepub fn grow(&self, length: Weight, dual_module_impl: &mut impl DualModuleImpl)
pub fn grow(&self, length: Weight, dual_module_impl: &mut impl DualModuleImpl)
grow the dual module and update [DualModuleInterface::sum_]
Sourcepub fn notify_grown(&self, length: Weight)
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
Sourcepub fn grow_iterative(
&self,
length: Weight,
dual_module_impl: &mut impl DualModuleImpl,
)
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
Sourcepub fn slow_fuse(&self, left: &Self, right: &Self)
pub fn slow_fuse(&self, left: &Self, right: &Self)
fuse two interfaces by copying the nodes in other into myself
Sourcepub fn fuse(&self, left: &Self, right: &Self)
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
Sourcepub fn sanity_check(&self) -> Result<Vec<Option<DualNodePtr>>, String>
pub fn sanity_check(&self) -> Result<Vec<Option<DualNodePtr>>, String>
do a sanity check of if all the nodes are in consistent state
pub fn sum_dual_variables(&self) -> Weight
Source§impl<SerialModule: DualModuleImpl + Send + Sync> ArcRwLock<DualModuleParallelUnit<SerialModule>>
impl<SerialModule: DualModuleImpl + Send + Sync> ArcRwLock<DualModuleParallelUnit<SerialModule>>
Sourcepub fn new_wrapper(
serial_module: SerialModule,
unit_index: usize,
partition_info: Arc<PartitionInfo>,
partition_unit: PartitionUnitPtr,
enable_parallel_execution: bool,
) -> Self
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 ArcRwLock<PrimalModuleParallelUnit>
impl ArcRwLock<PrimalModuleParallelUnit>
Sourcepub fn new_wrapper(
serial_module: PrimalModuleSerialPtr,
unit_index: usize,
partition_info: Arc<PartitionInfo>,
) -> Self
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<PrimalModuleSerial>
impl ArcRwLock<PrimalModuleSerial>
pub fn get_primal_node_internal_ptr_option( &self, dual_node_ptr: &DualNodePtr, ) -> Option<PrimalNodeInternalPtr>
pub fn get_primal_node_internal_ptr( &self, dual_node_ptr: &DualNodePtr, ) -> PrimalNodeInternalPtr
Sourcepub fn get_outer_node(
&self,
primal_node_internal_ptr: PrimalNodeInternalPtr,
) -> PrimalNodeInternalPtr
pub fn get_outer_node( &self, primal_node_internal_ptr: PrimalNodeInternalPtr, ) -> PrimalNodeInternalPtr
get the outer node in the most up-to-date cache
Sourcepub fn find_lowest_common_ancestor(
&self,
primal_node_internal_ptr_1: PrimalNodeInternalPtr,
primal_node_internal_ptr_2: PrimalNodeInternalPtr,
) -> (PrimalNodeInternalPtr, Vec<PrimalNodeInternalPtr>, Vec<PrimalNodeInternalPtr>)
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
Sourcepub fn match_subtree<D: DualModuleImpl>(
tree_node_internal_ptr: PrimalNodeInternalPtr,
interface_ptr: &DualModuleInterfacePtr,
dual_module: &mut D,
)
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
Sourcepub 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,
)
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
Sourcepub 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,
)
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
Sourcepub fn flatten_nodes(
&self,
flattened_nodes: &mut Vec<Option<PrimalNodeInternalPtr>>,
)
pub fn flatten_nodes( &self, flattened_nodes: &mut Vec<Option<PrimalNodeInternalPtr>>, )
DFS flatten the nodes
Sourcepub fn slow_fuse(&self, left: &Self, right: &Self)
pub fn slow_fuse(&self, left: &Self, right: &Self)
fuse two modules by copying the nodes in other into myself
Sourcepub fn fuse(&self, left: &Self, right: &Self)
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
Sourcepub fn sanity_check(&self) -> Result<Vec<Option<PrimalNodeInternalPtr>>, String>
pub fn sanity_check(&self) -> Result<Vec<Option<PrimalNodeInternalPtr>>, String>
do a sanity check of it’s tree structure and internal state
Sourcepub fn collapse_tree<D: DualModuleImpl>(
&self,
primal_node_internal_ptr: PrimalNodeInternalPtr,
interface_ptr: &DualModuleInterfacePtr,
dual_module: &mut D,
)
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>
impl ArcRwLock<PrimalNodeInternal>
Sourcepub fn flatten_tree(&self, flattened_nodes: &mut Vec<PrimalNodeInternalPtr>)
pub fn flatten_tree(&self, flattened_nodes: &mut Vec<PrimalNodeInternalPtr>)
DFS flatten the children of a tree
Trait Implementations§
Source§impl<T> RwLockPtr<T> for ArcRwLock<T>
impl<T> RwLockPtr<T> for ArcRwLock<T>
fn new_ptr(ptr: Arc<RwLock<T>>) -> Self
fn new_value(obj: T) -> Self
fn ptr(&self) -> &Arc<RwLock<T>>
fn ptr_mut(&mut self) -> &mut Arc<RwLock<T>>
fn read_recursive(&self) -> RwLockReadGuard<'_, RawRwLock, ObjType>
fn write(&self) -> RwLockWriteGuard<'_, RawRwLock, ObjType>
fn ptr_eq(&self, other: &Self) -> bool
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>
impl<T> Sync for ArcRwLock<T>
impl<T> Unpin for ArcRwLock<T>
impl<T> !UnwindSafe for ArcRwLock<T>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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>
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>
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