DualModuleInterfacePtr

Type Alias DualModuleInterfacePtr 

Source
pub type DualModuleInterfacePtr = ArcManualSafeLock<DualModuleInterface>;

Aliased Type§

pub struct DualModuleInterfacePtr { /* private fields */ }

Implementations§

Source§

impl DualModuleInterfacePtr

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

Trait Implementations§

Source§

impl Debug for DualModuleInterfacePtr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FusionVisualizer for DualModuleInterfacePtr

Source§

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

take a snapshot, set abbrev to true to save space