CS333 Lab C-3:
Dataflow Communication

Goals of this lab:

Introduction:

Dataflow is both a programming concept and implementation technique. A dataflow program can be represented as a directed graph, where an edge between two vertices represents the flow of data tokens between those vertices along the direction of the edge. Each vertex in the graph represents a dataflow element that can fire when there is data waiting at each of its inputs. When an element fires, it consumes one input token waiting at each input edge and may produce one or more output tokens to be sent along the output edges to other elements. Useful dataflow programs can be constructed from simple elements that perform calculations and comparisons. Dataflow programs allow for maximum concurrency because tokens flowing along different parts of the dataflow graph may proceed safely in parallel.

The dataflow technique is amenable to visual programming because dataflow graphs are easily visualized. In addition, standard procedural programs can be compiled into dataflow graphs. Often this is done in order to determine where one might be able to expoit concurrency. In fact, special-purpose multiprocessors have been built to execute dataflow graphs that are compiled from procedural languages.

In this project, you will construct several types of dataflow elements and then put them together (visually) to construct distributed dataflow programs. Each element will have three functions that it will perform repeatedly.

  1. match -- manage input queues; when there is a data token at each input, call fire
  2. fire -- consume one data token at each input and call produce with those arguments
  3. produce -- perform the calculation and generate data tokens at the outputs
Match and fire can be generic. Produce will vary according to the particular calculation being performed by the dataflow element. You will use ordinary Playground data values as tokens. Concurrency, when possible, will be achieved by running dataflow elements on different workstations.

Directions:

Read over the entire assignment before starting.

  1. Design: Invent a design that can be used as a general framework for all of your dataflow elements. Your design should handle match, fire, and produce. Since each Playground data value will be treated as a separate token, you will need to use reaction functions at your inputs to be sure that you don't miss any input tokens. Keep in mind that it is possible for two inputs to arrive at one input before any arrive at another, so multiple input tokens may be waiting at a given input port. Your design should include queues of data tokens (type PGvariable*) waiting to be processed. You will need one queue per input port. Use a reaction function to perform the enqueue operation. An element should fire only when all of its input queues are non-empty. At that time, the head element of each queue should be dequeued and used in the calculation. Finally, new data tokens should be produced at the outputs, according to the results of the calculation.

  2. Build 10 different dataflow elements: Use your general design to build the following dataflow elements. Use EUPHORIA to test each one. Be sure to test with multiple waiting inputs. (Don't be scared by the number of elements. These elements are more alike than they are different. Use inheritance.)

    After you've created these, be sure to use "strip" the executables to take up less disk space. Even better, create a single executable that behaves like different kinds of dataflow elements based on command-line arguments or terminal input given when you start up the module.

    Hint: You may want to set up your dataflow elements so that constant values can be specified on startup. (For example, to create a box that increments or decrements.) This will avoid the problem of feeding in constants repeatedly to be matched with the variable data.

  3. Create some dataflow programs: Using dataflow elements you have constructed, use the PGcmgui to construct the following dataflow programs. Be aware that the PGcmgui uses module names to save configurations. Use EUPHORIA to generate the input and consume the output from each program.


To receive credit for this lab, you should:

  1. Clean up and print out your code. (Don't turn it in, but save it for your code/design review.)

  2. Turn in a Project Evaluation Form near the beginning of class on the day you want to do your demonstration and code/design review. You should be prepared to demonstrate your working application, explain your design and code, and answer questions.