at.dms.kjc.flatgraph
Class GraphFlattener

java.lang.Object
  extended by at.dms.util.Utils
      extended by at.dms.kjc.flatgraph.GraphFlattener
All Implemented Interfaces:
DeepCloneable, Serializable

public class GraphFlattener
extends Utils

This class will create a graph of FlatNode that represents the underlying SIR graph of the application. It is basically the SIR graph without containers.

The constructed graph of FlatNodes, the Flat graph, will have one node for each SIROperator in the SIR graph (except when --sync is enabled), but there will exist no containers, FlatNodes directly connect to/from their downstream/upstream nodes.

Each SIROperator will be converted to a FlatNode: SIRFilter into a FlatNode with at most one input/one output, SIRSplitter into a multiple output/one input, SIRJoiner into multiple input/one output.

If --sync is enabled, it will attempt to coalesce multiple splitters or joiners into a single FlatNode.

Author:
mgordon
See Also:
Serialized Form

Field Summary
static LinkedList<FlatNode> needsToBeSched
          Used by --sync (synch removal) to reschedule the flat graph
 FlatNode top
          the toplevel, entry, FlatNode of the constructed Flat graph
 
Fields inherited from class at.dms.util.Utils
EMPTY_LIST, getForLoopCallers
 
Constructor Summary
GraphFlattener(SIROperator toplevel)
          Create a graph of FlatNodes that represents the SIR graph of the application rooted at toplevel.
 
Method Summary
static boolean countMe(SIRFilter filter)
          Return true if this filter should be mapped to a tile, meaning it is not a predefined filter.
 FlatNode getFlatNode(SIROperator key)
          Given an SIROperator, key, return the FlatNode that was created to represent key, or null if one was not created.
static CType getJoinerType(FlatNode joiner)
          Return the data type of items that flow through joiner.
static int getMult(FlatNode node, boolean init, HashMap<FlatNode,Integer> initExecutionCounts, HashMap<FlatNode,Integer> steadyExecutionCounts)
          Return the multiplicity of node in the schedule determined by init.
 int getNumTiles()
          Returns the number of tiles that would be needed to execute this graph.
static CType getOutputType(FlatNode node)
          Return the output type of the FlatNode node.
 
Methods inherited from class at.dms.util.Utils
asPercent, cellMathEquivalent, cMathEquivalent, cppMathEquivalent, deepClone, deepCloneInto, equalArrays, fail, getEnvironmentVariable, getExpression, hasPeeks, initArray, initArray, initLiteralArray, intArrayToList, isMathMethod, isUniform, kopi_assert, kopi_assert, makeCountdownForLoop, makeDotFileName, makeForLoop, makeForLoop, makeForLoop, makeForLoopFieldIndex, makeForLoopLocalIndex, nextPow2, passThruParens, peelMarkers, popBeforePeek, readFile, removeUnusedPops, replaceAll, setupDotFileName, simplifyMathMethod, splitQualifiedName, splitQualifiedName, toArray, toIntArray, toVector, voidToInt, writeFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

top

public FlatNode top
the toplevel, entry, FlatNode of the constructed Flat graph


needsToBeSched

public static LinkedList<FlatNode> needsToBeSched
Used by --sync (synch removal) to reschedule the flat graph

Constructor Detail

GraphFlattener

public GraphFlattener(SIROperator toplevel)
Create a graph of FlatNodes that represents the SIR graph of the application rooted at toplevel. If --sync is enabled, then try to coalesce multiple splitters or joiners into a single FlatNode.

Parameters:
toplevel - The toplevel SIR container of the application.
Method Detail

getNumTiles

public int getNumTiles()
Returns the number of tiles that would be needed to execute this graph. That is, just counts the filters, plus any joiners whose output is not connected to another joiner. This is used only for the SpaceDynamic and the original at.dms.kjc.raw backends.

Returns:
The number of tiles needed to map this graph to raw.

getFlatNode

public FlatNode getFlatNode(SIROperator key)
Given an SIROperator, key, return the FlatNode that was created to represent key, or null if one was not created.

Parameters:
key -
Returns:
the FlatNode that was created to represent key, or null if one was not created.

getOutputType

public static CType getOutputType(FlatNode node)
Return the output type of the FlatNode node.

Parameters:
node - The FlatNode in question.
Returns:
node's output type.

countMe

public static boolean countMe(SIRFilter filter)
Return true if this filter should be mapped to a tile, meaning it is not a predefined filter.

Parameters:
filter - The SIRFilter is question.
Returns:
true if this filter should be mapped to a tile, meaning it is not a predefined filter.

getJoinerType

public static CType getJoinerType(FlatNode joiner)
Return the data type of items that flow through joiner.

Parameters:
joiner - The joiner
Returns:
The CType of items that flow through joiner.

getMult

public static int getMult(FlatNode node,
                          boolean init,
                          HashMap<FlatNode,Integer> initExecutionCounts,
                          HashMap<FlatNode,Integer> steadyExecutionCounts)
Return the multiplicity of node in the schedule determined by init. If node does not appear in the schedule, return 0;

Parameters:
node -
init - If true use initExecutionCounts, else use steadyExecutionCounts
initExecutionCounts - HashMap of FlatNode->Integer for init multiplicities
steadyExecutionCounts - HashMap of FlatNode->Integer for steadyx multiplicities
Returns:
The multiplicity of node in init if init == true or steady of init == false, or -1 if the corresponding HashMap is null, or 0 if the node does not appear in the schedule for the stage.