coreblocks icon indicating copy to clipboard operation
coreblocks copied to clipboard

[RFC] Non blocking if

Open lekcyjna123 opened this issue 1 year ago • 5 comments

I create this issue, to allow for brainstorm how to implement non blocking if in transactron. Lets take:

with Transaction().body(m):
   with m.If(m, cond):
      method(m)

In current implementation we always block method if transaction is called regardless of cond. We would like to not block method is cond is false.

The easy implementation idea is to calculate runnable signal for each pair of (transaction, method) using:

runnable = enable.implies(ready)

Where enable is signal pointing if transaction want to run method and ready say us if method is ready.

Above idea works as long as:

  • cond is independent from method output or
  • method from which it is a result is independent from scheduling result/input data

Lets say:

with Transaction().body(m):
   cond=method1(m, in_data1)
   with m.If(m, cond):
      method2(m)

Now we can consider two cases:

  • if in_data1 influence cond then cond depends from scheduling result (as long as it is not single-caller method), so there is a combinational cycle, because scheduling result (so cond) influence scheduling of method2.
  • if in_data1 is the same regardless of input there is no problem

To summarise. We have to decide how to handle if-s which depends from methods whose output depends on input. Some propositions:

  • disallow non blocking if-s in situations where condition depends from scheduler. This solution is somehow similar to old handling of readiness of methods. We allowed ready signal to depends on input data only if method was single-caller
  • Maybe we can start scheduling from methods whose output influence scheduling? In other words do scheduling in steps. Does this introduce possibility of deadlocks? Can we reuse schedule_before for that?

All other propositions are welcome.

lekcyjna123 avatar Oct 24 '23 17:10 lekcyjna123