Skip to content

Commit

Permalink
Merge 5be81d0 into 0388d54
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhartman authored Aug 16, 2023
2 parents 0388d54 + 5be81d0 commit 02608e0
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions crates/accelerate/src/sabre_swap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,29 @@ fn populate_extended_set(
let mut decremented: HashMap<usize, u32> = HashMap::new();
let mut i = 0;
while i < to_visit.len() && extended_set.len() < EXTENDED_SET_SIZE {
for edge in dag.dag.edges_directed(to_visit[i], Direction::Outgoing) {
let successor_node = edge.target();
let successor_index = successor_node.index();
*decremented.entry(successor_index).or_insert(0) += 1;
required_predecessors[successor_index] -= 1;
if required_predecessors[successor_index] == 0 {
if !dag.node_blocks.contains_key(&successor_index) {
if let [a, b] = dag.dag[successor_node].1[..] {
extended_set.insert(successor_node, &[a, b]);
// Visit runs of non-2Q gates fully before moving on to children
// of 2Q gates. This way, traversal order is a BFS of 2Q gates rather
// than of all gates.
let mut visit_now = vec![to_visit[i]];
let mut j = 0;
while let Some(node) = visit_now.get(j) {
for edge in dag.dag.edges_directed(*node, Direction::Outgoing) {
let successor_node = edge.target();
let successor_index = successor_node.index();
*decremented.entry(successor_index).or_insert(0) += 1;
required_predecessors[successor_index] -= 1;
if required_predecessors[successor_index] == 0 {
if !dag.node_blocks.contains_key(&successor_index) {
if let [a, b] = dag.dag[successor_node].1[..] {
extended_set.insert(successor_node, &[a, b]);
to_visit.push(successor_node);
continue;
}
}
visit_now.push(successor_node);
}
to_visit.push(successor_node);
}
j += 1;
}
i += 1;
}
Expand Down

0 comments on commit 02608e0

Please sign in to comment.