|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.dms.kjc.backendSupport.ComputeCodeStore<ComputeNodeType>
ComputeNodeType
- nasty recursive type, historical relic. TODO: get rid of.public class ComputeCodeStore<ComputeNodeType extends ComputeNode<?>>
A data structure for associating code with each compute node at each phase.
A Code Store implements a SIRCodeUnit so that you can add fields and methods as needed.
A ComputeCodeStore also has a main method (of type void->void). The main method has three
predefined parts:
addInitStatement(JStatement)
can be used to add a statement that
is performed before the steady state. This is normally called to add statments calling (or inlining)
a work method that needs to be run at initialization time to pre-load data needed for peeks.
addSteadyLoopStatement(JStatement)
can be used to add a statement that is performed
in the steady state loop.
addCleanupStatement(JStatement)
can be used to add a statement that is performed
after the steady state loop.
It may be useful to call addInitFunctionCall(JMethodDeclaration)
to add a call to some
method to the beginning of the main method. As the name implies, this is usually used to add calls
to the init() functions in filters.
Use constructors without the iterationBound parameter to run the steady state indefinitely (and thus
make addCleanupStatement(JStatement)
useless).
Use constructors with the iterationBound parameter to run the steady state for the number of times
determined at run time by the value of the iterationBound.
As lifted from MGordon's code there is a mutually-recursive type problem:
ComputeCodeStore and ComputeNode types are extended in parallel, and each refers to the other.
New constructors allow ComputeCodeStore to be constructed without reference to a ComputeNode.
Field Summary | |
---|---|
protected JBlock |
cleanupBlock
the block executed after the steadyLoop |
protected static boolean |
CODE
set to false if you do not want to generate the work functions calls or inline them useful for debugging |
protected JFieldDeclaration[] |
fields
The fields of the tile |
protected JBlock |
initBlock
the block that executes each slicenode's init schedule, as calculated currently |
protected JMethodDeclaration |
mainMethod
this method calls all the initialization routines and the steady state routines |
static String |
mainName
The name of the main function for each tile. |
protected JMethodDeclaration[] |
methods
the methods of this tile |
protected String |
myMainName
name that may be unique per processor. |
protected ComputeNodeType |
parent
The ComputeNode this compute code will be place on |
protected JBlock |
steadyLoop
block for the steady-state, as calculated currently |
Constructor Summary | |
---|---|
ComputeCodeStore()
Constructor: steady state loops indefinitely, no pointer back to compute node. |
|
ComputeCodeStore(ALocalVariable iterationBound)
Constructor: caller will add code to bound number of iterations, no pointer back to compute node. |
|
ComputeCodeStore(ComputeNodeType parent)
Constructor: steady state loops indefinitely, code store has pointer back to a compute node. |
|
ComputeCodeStore(ComputeNodeType parent,
ALocalVariable iterationBound)
Constructor: caller will add code to bound number of iterations, code store has pointer back to a compute node. |
Method Summary | |
---|---|
void |
addCleanupStatement(JStatement stmt)
Add a statement to the end of the cleanup code. |
void |
addField(JFieldDeclaration field)
Adds field field to this, if field is not already registered as a field of this. |
void |
addFields(JFieldDeclaration[] f)
Adds f to the fields of this. |
void |
addInitFunctionCall(JMethodDeclaration init)
Add the call the init function for a filter as the first statement in "main". |
void |
addInitStatement(JStatement stmt)
|
void |
addInitStatementFirst(JStatement stmt)
|
void |
addMethod(JMethodDeclaration method)
Bill's code adds method meth to this, if meth is not already registered as a method of this. |
void |
addMethods(JMethodDeclaration[] m)
Adds m to the methods of this. |
protected void |
addSteadyLoop()
Add a way of iterating steadyLoop to the main method. |
protected void |
addSteadyLoop(ALocalVariable iterationBound)
Add a way of iterating steadyLoop to the main method. |
void |
addSteadyLoopStatement(JStatement stmt)
|
JFieldDeclaration[] |
getFields()
Return the fields of this store. |
JMethodDeclaration |
getMainFunction()
Return the main function of this store that will execute the init, primepump, and loop the steady-schedule. |
JMethodDeclaration[] |
getMethods()
Return the methods of this store. |
String |
getMyMainName()
get name for MAIN method in this code store. |
boolean |
hasMethod(JMethodDeclaration meth)
|
void |
setFields(JFieldDeclaration[] f)
Set the fields of this to f. |
void |
setMethods(JMethodDeclaration[] m)
Set methods to m. |
protected void |
setMyMainName(String mainName)
Override to get different MAIN names on different ComputeNode's |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String mainName
setMyMainName(String)
which can use it or
ignore it in setting up a local name for the main loop in each ComputeCodeStore.
Assuming that there is only a single subclass of ComputeCodeStore in a given back end
you could attempt to override this local field by:
static { if ("".equals(mainName)) mainName = "__MAIN__";}But you would need to understand your class loader to know what the value would be if multiple subclasses of ComputeCodeStore are loaded in a back end. You are generally better off calling
setMyMainName(String)
in your constructor
and ignoring this field.
protected String myMainName
protected static final boolean CODE
protected JFieldDeclaration[] fields
protected JMethodDeclaration[] methods
protected JMethodDeclaration mainMethod
protected ComputeNodeType extends ComputeNode<?> parent
protected JBlock steadyLoop
protected JBlock initBlock
protected JBlock cleanupBlock
Constructor Detail |
---|
public ComputeCodeStore(ComputeNodeType parent)
parent
- a ComputeNode.public ComputeCodeStore(ComputeNodeType parent, ALocalVariable iterationBound)
parent
- a ComputeNode.iterationBound
- a variable that will be defined locally inpublic ComputeCodeStore(ALocalVariable iterationBound)
iterationBound
- a variable that will be defined locally by getMainFunction().addAllStatments(0,stmts);
public ComputeCodeStore()
Method Detail |
---|
protected void addSteadyLoop()
protected void addSteadyLoop(ALocalVariable iterationBound)
iterationBound
- the local variable that will hold the iteration count.protected void setMyMainName(String mainName)
public String getMyMainName()
public void addInitStatement(JStatement stmt)
stmt
- statement to add after any other statements in init code.public void addInitStatementFirst(JStatement stmt)
public void addCleanupStatement(JStatement stmt)
getMainFunction().addStatement(getCleanupBlock());after calling
stmt
- statement to add after any other statements in cleanup code.public void addSteadyLoopStatement(JStatement stmt)
stmt
- statement to add after any other statements in steady-state code.public void addMethod(JMethodDeclaration method)
addMethod
in interface SIRCodeUnit
method
- The method to add.public void setMethods(JMethodDeclaration[] m)
setMethods
in interface SIRCodeUnit
m
- The methods to install.public void addFields(JFieldDeclaration[] f)
addFields
in interface SIRCodeUnit
f
- The fields to add to the end.public void addField(JFieldDeclaration field)
addField
in interface SIRCodeUnit
field
- The field to attempt to add.public void addMethods(JMethodDeclaration[] m)
addMethods
in interface SIRCodeUnit
m
- The methods to attempt to add to the end of the methods.public boolean hasMethod(JMethodDeclaration meth)
meth
-
public JMethodDeclaration[] getMethods()
getMethods
in interface SIRCodeUnit
public JFieldDeclaration[] getFields()
getFields
in interface SIRCodeUnit
public void setFields(JFieldDeclaration[] f)
setFields
in interface SIRCodeUnit
f
- The fields to install.public JMethodDeclaration getMainFunction()
public void addInitFunctionCall(JMethodDeclaration init)
init
- the init function, a call to it will be added.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |