Skip to content

Conversation

zeinabPourgheisari
Copy link
Collaborator

The previous fast token delivery crashed when running into loops with multiple exits (see example CFG below).
This happened because gates (Mu gates in this case) stored only one block as their condition block, which fails when multiple blocks are needed as conditions.

linear_search_CFG

To fix this, two new attributes were added to Gate:

  • a boolean expression for the condition
  • a list of cofactors, representing the variables used in the condition expression.

For each Mu gate, the loop exit condition is computed by OR-ing the exit conditions of all exiting blocks. The condition of the Mu is then set as the negation of this exit condition (i.e., the loop iteration condition).
For Gamma gates, the condition remains the same as before, taken from the condition block.

In FtdImplementation.cpp, whenever the condition value of a gate/loop is needed:

  • If there is a single cofactor, the same process as before is used,
  • If there are multiple cofactors, a Binary Decision Diagram (BDD) is built, translated into a circuit, and used as the condition value.

In addition, in boolVariableToCircuit function, conditions generated for gates with multiple exiting blocks do not require channelification.

muxConditionBlock = userBlock;
break;
}
// TODO: extend for multi-loop exit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you push the code of this?

@AyaElAkhras
Copy link
Member

Could you also push the changes that we discussed to unify the if-else here

if (Block *loopExit = loop->getExitingBlock(); loopExit) {
?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants