at.dms.kjc.sir.statespace
Class LinearAnalyzer

java.lang.Object
  extended by at.dms.kjc.sir.EmptyStreamVisitor
      extended by at.dms.kjc.sir.statespace.LinearAnalyzer
All Implemented Interfaces:
StreamVisitor

public class LinearAnalyzer
extends EmptyStreamVisitor

The LinearAnalyzer visits all of the filters and structures in a StreamIt program. It determines which filters calculate linear functions of their inputs, and for those that do, it keeps a mapping from the filter name to the filter's matrix representation.
$Id: LinearAnalyzer.java,v 1.19 2006/09/25 13:54:46 dimock Exp $


Constructor Summary
LinearAnalyzer(boolean refactorLinearChildren)
           
 
Method Summary
 void addLinearRepresentation(SIRStream key, LinearFilterRepresentation rep)
          Adds a mapping from SIRStream to LinearFilterRep.
 void addNonLinear(SIRStream str)
          Adds a note that str is non-linear.
static LinearAnalyzer findLinearFilters(SIRStream str, boolean debug, boolean refactorLinearChildren)
          Main entry point -- searches the passed stream for linear filters and calculates their associated matrices.
static LinearAnalyzer findLinearFilters(SIRStream str, boolean debug, LinearAnalyzer lfa)
          Same as above, but specifies an existing
 Iterator<SIRStream> getFilterIterator()
          Gets an iterator over all of the linear representations that this LinearAnalyzer knows about.
 LinearFilterRepresentation getLinearRepresentation(SIRStream stream)
          Returns the mapping from stream to linear representation that we have.
 boolean hasLinearRepresentation(SIRStream stream)
          Returns true if the specified filter has a linear representation that we have found.
 boolean isNonLinear(SIRStream key)
          Checks if stream is non-linear
 void postVisitFeedbackLoop(SIRFeedbackLoop self, SIRFeedbackLoopIter iter)
           
 void postVisitPipeline(SIRPipeline self, SIRPipelineIter iter)
          We visit a pipeline after all sub-streams have been visited.
 void postVisitSplitJoin(SIRSplitJoin self, SIRSplitJoinIter iter)
          Visits a split join after all of its childern have been visited.
 void removeLinearRepresentation(SIRStream stream)
          Removes the specified SIRStream from the linear represention mapping.
 void visitFilter(SIRFilter self, SIRFilterIter iter)
          More or less get a callback for each stream.
 
Methods inherited from class at.dms.kjc.sir.EmptyStreamVisitor
postVisitStream, preVisitFeedbackLoop, preVisitPipeline, preVisitSplitJoin, preVisitStream, visitPhasedFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearAnalyzer

public LinearAnalyzer(boolean refactorLinearChildren)
Method Detail

hasLinearRepresentation

public boolean hasLinearRepresentation(SIRStream stream)
Returns true if the specified filter has a linear representation that we have found.


getLinearRepresentation

public LinearFilterRepresentation getLinearRepresentation(SIRStream stream)
Returns the mapping from stream to linear representation that we have. Returns null if we do not have a mapping.


removeLinearRepresentation

public void removeLinearRepresentation(SIRStream stream)
Removes the specified SIRStream from the linear represention mapping.


addLinearRepresentation

public void addLinearRepresentation(SIRStream key,
                                    LinearFilterRepresentation rep)
Adds a mapping from SIRStream to LinearFilterRep.


getFilterIterator

public Iterator<SIRStream> getFilterIterator()
Gets an iterator over all of the linear representations that this LinearAnalyzer knows about.


addNonLinear

public void addNonLinear(SIRStream str)
Adds a note that str is non-linear.


isNonLinear

public boolean isNonLinear(SIRStream key)
Checks if stream is non-linear


findLinearFilters

public static LinearAnalyzer findLinearFilters(SIRStream str,
                                               boolean debug,
                                               boolean refactorLinearChildren)
Main entry point -- searches the passed stream for linear filters and calculates their associated matrices. Uses a fresh linear analyzer.
If the debug flag is set, then we print a lot of debugging information.
refactorLinearChildren indicates whether or not we should refactor linear children into a separate pipeline, if some of their siblings are not linear.


findLinearFilters

public static LinearAnalyzer findLinearFilters(SIRStream str,
                                               boolean debug,
                                               LinearAnalyzer lfa)
Same as above, but specifies an existing
lfa
to use instead of creating a fresh one.


visitFilter

public void visitFilter(SIRFilter self,
                        SIRFilterIter iter)
More or less get a callback for each stream. -- see EmptyStreamVisitor.

Specified by:
visitFilter in interface StreamVisitor
Overrides:
visitFilter in class EmptyStreamVisitor

postVisitFeedbackLoop

public void postVisitFeedbackLoop(SIRFeedbackLoop self,
                                  SIRFeedbackLoopIter iter)
Specified by:
postVisitFeedbackLoop in interface StreamVisitor
Overrides:
postVisitFeedbackLoop in class EmptyStreamVisitor

postVisitPipeline

public void postVisitPipeline(SIRPipeline self,
                              SIRPipelineIter iter)
We visit a pipeline after all sub-streams have been visited. We combine any adjacent linear children into their own wrapper pipeline and also determine a linear form for them.

Specified by:
postVisitPipeline in interface StreamVisitor
Overrides:
postVisitPipeline in class EmptyStreamVisitor

postVisitSplitJoin

public void postVisitSplitJoin(SIRSplitJoin self,
                               SIRSplitJoinIter iter)
Visits a split join after all of its childern have been visited. If we have linear representations for all the children, then we can combine the entire split join construct into a single linear representation.

Specified by:
postVisitSplitJoin in interface StreamVisitor
Overrides:
postVisitSplitJoin in class EmptyStreamVisitor