objectionary / ideas

Here we keep ideas for future research in EO programming language and Polystat static analyzer
https://www.eolang.org
7 stars 0 forks source link

dataflow machine simulator #44

Closed yegor256 closed 9 months ago

yegor256 commented 1 year ago

Dataflow architecture is a computer architecture that directly contrasts the traditional von Neumann architecture or control flow architecture. The latter executes instructions sequentially, while the former doesn't have a program counter. A dataflow architecture represents a program as a dataflow graph (DFG), where nodes are "operators" and directed edges between them are the "channels" through which immutable data values travel. An operator is evaluated when data are present on all input channels. The completion of evaluation makes the resulting data available to the operators at the ends of output channels. Thus, the order of operator evaluation is unpredictable, i.e., behavior is nondeterministic.

In order to study the behavior of a DFG we can create a simulator of a dataflow machine. It should be a command line tool. I should be able to specify the DFG (in JS-like language) in a file and then run it:

$ cat foo.dfg
function v1(input) { return { z : input.x + input.y }; }
function v2(input) { console.log(input.a); return { }; }
"42" -> v1.x
"77" -> v1.y
v1.z -> v2.a

The output should look like this:

$ simulator foo.dfg
v1.x : "42"
v1.y : "77"
run(v1)
v2.a : "119"

Simply put, the output should show step by step which data show up on each edge.

yegor256 commented 1 year ago

a prototype is here: https://github.com/yegor256/damsi