at.dms.kjc.flatgraph
Class StaticStreamGraph

java.lang.Object
  extended by at.dms.kjc.flatgraph.StaticStreamGraph
Direct Known Subclasses:
ScheduledStaticStreamGraph

public class StaticStreamGraph
extends Object

A representation of a portion of a FlatGraph where all comunication is static rate. A StaticStreamGraph represents a subgraph of the application's StreamGraph where communication within the SSG is over static rate channels. The input/output (if either exists) of an SSG is dynamic, but the sources and sinks have their input/output rates zeroed, repectively. A SSG can be modified and replaced in the graph structure by calling setTopLevelSIR with the modified SSG. Modification must preserve the following: it must not change the number of inputs and outputs of the SSG. If a SSG has multiple inputs (resp. outputs), there must be a round-robin splitter (resp. joiner) with 0 edge weights creating a single root (resp. exit) for the SSG and connecting to the actual inputs (resp. outputs).


Field Summary
protected  LinkedList<FlatNode> flatNodes
           
protected  GraphFlattener graphFlattener
          the graph flattener used to convert SIR to FlatGraph
 int id
           
protected  FlatNode[] inputs
          arrays representing the inputs and output of this ssg from top to bottom (left to right)...
protected  HashMap<SIRFilter,SIRFilter> nexts
           
protected  List<StaticStreamGraph> nextSSGs
          SSGs that this SSG has edges to.
protected  FlatNode[] outputs
           
protected  HashMap<SIRFilter,SIRFilter> prevs
          These Hashmaps map flatnode -> flatnode.
protected  FlatNode topLevel
          the top level FlatNode Used in debugging from subclasses.
protected  SIRStream topLevelSIR
          the top level SIR node.
 
Constructor Summary
protected StaticStreamGraph()
           
  StaticStreamGraph(StreamGraph sg, FlatNode realTop)
          create a static stream graph with realTop as the first node that the implicit splitter points to
 
Method Summary
 void accept(StreamGraphVisitor s, HashSet<StaticStreamGraph> visited, boolean newHash)
          accept a stream graph visitor *
 void addNext(FlatNode node, FlatNode next)
          When constructing this SSG, add a new connection from node->next to the nexts hash map and add the
 void addPrev(FlatNode node, FlatNode source)
          When constructing this SSG, add a new connection from node->source to the prevs hash map and add node to the inputs array
 void check()
           
 void createSIRGraph()
          Given the current toplevel flatnode, create the SIR graph, also regenerating the flatgraph *
 int filterCount()
          get the number of filters of this SSG *
 List<FlatNode> getFlatNodes()
          return a list of the flatnodes of this SSG *
 GraphFlattener getGraphFlattener()
          return the graph flattener object that was used to flatten.
 int getInputNum(FlatNode node)
          given an input, source, for this SSG, get the input number, index to inputs[] and inputSSGEdges[]
 CType getInputType(FlatNode node)
          get the input type for a node of this SSG, we want to use this because we set the input type of the head of this SSG to null, even though it may receive data over the dynamic network
 HashSet<SIRFilter> getIOFilters()
          get all the SIRFilters that are either sinks or sources of this SSG.
 FlatNode getNext(FlatNode flatNode)
          given a dynamic sink for this SSG, get the node in the downstream SSG that it connects to
 int getOutputNum(FlatNode node)
          given an output (sink) for this SSG, get the output number, index to outputs[] and outputSSGEdges[]
 FlatNode[] getOutputs()
          get the dynamic outputs of this ssg *
 CType getOutputType(FlatNode node)
          get the output type for
 Map<FlatNode,StaticStreamGraph> getParentMap()
          returns a map of flatnodes to this SSG, so that others can remember the parent mapping of flat nodes.
 FlatNode getPrev(FlatNode flatNode)
          give a dynamic source for this SSG, get the node in the upstream SSG that it connects to
 StreamGraph getStreamGraph()
          get the parent stream graph of SSG *
 FlatNode getTopLevel()
          get the top level flatnode of this SSG*
 SIRStream getTopLevelSIR()
          get the toplevel SIR of this SSG *
 boolean hasOutput()
          does this ssg have dynamic output *
 boolean isInput(FlatNode node)
          is node a dynamic source for this SSG *
 boolean isOutput(FlatNode node)
          is node a dynamic sink for this SSG *
static void printCounts(HashMap counts)
           
 void reconnectOutputs()
          connect flatgraph with weight-1 edges to nodes in other ssg's flatgraphs based on this ssg's outputs.
 void setTopLevelSIR(SIRStream newTop)
          set a new TopLevelSIR stream and flatten it, can only be called before layout!
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

prevs

protected HashMap<SIRFilter,SIRFilter> prevs
These Hashmaps map flatnode -> flatnode.
prevs maps an input node of this SSG to the corresponding output node of a upstream SSG
nexts maps an output node of this SSG to the corresponding input node of a downstream SSG
Note: only used in building graph. no longer valid after setTopLevelSIR. The sizes are used as a sanity check that operations on the ssh have not changed number of incoming or outgoing edges, but contents should not be referenced after initial graph build.


nexts

protected HashMap<SIRFilter,SIRFilter> nexts

nextSSGs

protected List<StaticStreamGraph> nextSSGs
SSGs that this SSG has edges to. Assumed immutible after SSG construction


inputs

protected FlatNode[] inputs
arrays representing the inputs and output of this ssg from top to bottom (left to right)...
Note: very delicate if graph structure changes: remember to call updateIOArrays: done from setTopLevelSIR.


outputs

protected FlatNode[] outputs

topLevelSIR

protected SIRStream topLevelSIR
the top level SIR node. Used in debugging and scheduling from subclasses.


topLevel

protected FlatNode topLevel
the top level FlatNode Used in debugging from subclasses.


graphFlattener

protected GraphFlattener graphFlattener
the graph flattener used to convert SIR to FlatGraph


flatNodes

protected LinkedList<FlatNode> flatNodes

id

public int id
Constructor Detail

StaticStreamGraph

protected StaticStreamGraph()

StaticStreamGraph

public StaticStreamGraph(StreamGraph sg,
                         FlatNode realTop)
create a static stream graph with realTop as the first node that the implicit splitter points to

Parameters:
StreamGraph - sg: the StreamGraph that the created StaticStreamGraph will be part of.
realTop: - the top node for the StaticStreamGraph (there is an internal fake top node)
Method Detail

getOutputNum

public int getOutputNum(FlatNode node)
given an output (sink) for this SSG, get the output number, index to outputs[] and outputSSGEdges[]


getInputNum

public int getInputNum(FlatNode node)
given an input, source, for this SSG, get the input number, index to inputs[] and inputSSGEdges[]


getIOFilters

public HashSet<SIRFilter> getIOFilters()
get all the SIRFilters that are either sinks or sources of this SSG.


setTopLevelSIR

public void setTopLevelSIR(SIRStream newTop)
set a new TopLevelSIR stream and flatten it, can only be called before layout!


createSIRGraph

public void createSIRGraph()
Given the current toplevel flatnode, create the SIR graph, also regenerating the flatgraph *


getGraphFlattener

public GraphFlattener getGraphFlattener()
return the graph flattener object that was used to flatten.


getParentMap

public Map<FlatNode,StaticStreamGraph> getParentMap()
returns a map of flatnodes to this SSG, so that others can remember the parent mapping of flat nodes.


addPrev

public void addPrev(FlatNode node,
                    FlatNode source)
When constructing this SSG, add a new connection from node->source to the prevs hash map and add node to the inputs array


addNext

public void addNext(FlatNode node,
                    FlatNode next)
When constructing this SSG, add a new connection from node->next to the nexts hash map and add the
node
to the outputs array.


hasOutput

public boolean hasOutput()
does this ssg have dynamic output *


isInput

public boolean isInput(FlatNode node)
is node a dynamic source for this SSG *


isOutput

public boolean isOutput(FlatNode node)
is node a dynamic sink for this SSG *


getOutputs

public FlatNode[] getOutputs()
get the dynamic outputs of this ssg *


getNext

public FlatNode getNext(FlatNode flatNode)
given a dynamic sink for this SSG, get the node in the downstream SSG that it connects to


getPrev

public FlatNode getPrev(FlatNode flatNode)
give a dynamic source for this SSG, get the node in the upstream SSG that it connects to


getFlatNodes

public List<FlatNode> getFlatNodes()
return a list of the flatnodes of this SSG *


getTopLevel

public FlatNode getTopLevel()
get the top level flatnode of this SSG*


getTopLevelSIR

public SIRStream getTopLevelSIR()
get the toplevel SIR of this SSG *


toString

public String toString()
Overrides:
toString in class Object

check

public void check()

printCounts

public static void printCounts(HashMap counts)

getStreamGraph

public StreamGraph getStreamGraph()
get the parent stream graph of SSG *


getInputType

public CType getInputType(FlatNode node)
get the input type for a node of this SSG, we want to use this because we set the input type of the head of this SSG to null, even though it may receive data over the dynamic network


getOutputType

public CType getOutputType(FlatNode node)
get the output type for
node
of this SSG *


filterCount

public int filterCount()
get the number of filters of this SSG *


accept

public void accept(StreamGraphVisitor s,
                   HashSet<StaticStreamGraph> visited,
                   boolean newHash)
accept a stream graph visitor *


reconnectOutputs

public void reconnectOutputs()
connect flatgraph with weight-1 edges to nodes in other ssg's flatgraphs based on this ssg's outputs. Restore types in filters being connected. Restore dynamic rate info.