Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
language:langs:dflow [2020/08/03 06:27]
rajit
language:langs:dflow [2021/06/02 12:04]
rajit [Examples]
Line 22: Line 22:
   * Initial tokens: these are specified directly in the syntax   * Initial tokens: these are specified directly in the syntax
   * Copy: implicit, with the same channel is used for multiple inputs   * Copy: implicit, with the same channel is used for multiple inputs
 +  * Sources and sinks have short-hand syntax.
  
 ===== Function ===== ===== Function =====
Line 42: Line 43:
 </code> </code>
 The ''*'' indicates a token sink. The ''*'' indicates a token sink.
 +
 +Splits with more than two outputs use the same syntax. The control token is assumed to take on an integer value specifying which output channel is used.
 +<code>
 +dataflow {
 +  {c} I -> O0, O1, O2, ..., On
 +}
 +</code>
  
 ===== Controlled merge ===== ===== Controlled merge =====
Line 51: Line 59:
 } }
 </code> </code>
-In this example, if a 0 is received on ''c'', then the data token on ''I0'' is sent to the output ''O''.+In this example, if a 0 is received on ''c'', then the data token on ''I0'' is sent to the output ''O''Multi-way merges use a syntax analogous to splits: 
 +<code> 
 +dataflow { 
 +  {c} I0, I1, ..., Ik -> O 
 +
 +</code>
  
 ===== Implicit copy and explicit buffers ===== ===== Implicit copy and explicit buffers =====
Line 99: Line 112:
 </code> </code>
 Note that this introduces an arbiter.  Note that this introduces an arbiter. 
 +
 +Often it is helpful to know what decision was made by the arbiter. To support this, we permit an optional second channel on the right hand side of the dataflow expression as follows:
 +<code>
 +dataflow {
 + {|} I0, I1 -> O, c
 +}
 +</code>
 +For each output generated, the control channel ''c'' will produce a 0 or 1 token depending on the choice made by the arbiter.
 +
 +===== Sink =====
 +
 +A dataflow sink simply receives and discards a token from a channel. Sinks are not needed in general, since the channel that corresponds to the sink can be optimized away by an implementation. However, sinks can be useful when a particular process is re-used in a context when one of its outputs is not used. The syntax is the following:
 +<code>
 +dataflow {
 +   c -> *
 +}
 +</code>
 +The values received on ''c'' are discarded by the sink.
  
 ====== Examples ====== ====== Examples ======
Line 126: Line 157:
 } }
 </code> </code>
 +
 +====== Clusters and Ordering ======
 +
 +It can be convenient to group dataflow elements into clusters. The syntax for grouping dataflow elements is:
 +
 +<code>
 +dataflow {
 +   ...
 +   dataflow_cluster {
 +      a + b -> c;
 +      a - b -> d
 +   }
 +   ...
 +}
 +</code>
 +
 +