public class LoopTools
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addLoopName(Program program)
Adds a unique loop name to each for loop.
|
static java.util.LinkedList<Loop> |
calculateInnerLoopNest(Loop enclosing_loop)
Calculate the nest of loops enclosed within the given loop
|
static java.util.LinkedList<Loop> |
calculateLoopNest(Loop loop)
Calculate the loop nest of this loop
|
static boolean |
checkDataDependenceEligibility(Loop loop)
Checks the eligibility of a certain loop for data dependence testing
Eligibility checks can be added or removed to increase the scope of
dependence testing
|
static java.util.Set<Expression> |
collectScalarDependences(Loop l)
Returns symbols that may cause data dependences with the specified loop.
|
static boolean |
containsBreakStatement(Loop loop)
Check if the loop contains only a break statement modifier
|
static boolean |
containsControlFlowModifier(Loop loop)
Check whether the loop contains control constructs that cause it to
terminate before the loop condition is reached.
|
static boolean |
containsControlFlowModifierOtherThanBreakStmt(Loop loop) |
static boolean |
containsFunctionCall(Loop loop)
Checks if loop body contains a function call
|
static boolean |
containsLoop(Loop loop)
Check if loop body contains another loop
|
static boolean |
containsOnlyParallelizableCall(Loop loop)
Check if the loop contains a function call that can be
tested for data dependences/that can be eventually parallelized
|
static java.util.List<Loop> |
extractOutermostDependenceTestEligibleLoops(Traversable t) |
static java.util.LinkedList<Loop> |
getCommonNest(Loop loop1,
Loop loop2)
Get common enclosing loops for loop1 and loop2
|
static Expression |
getIncrementExpression(Loop loop)
Get the expression that represents the actual increment value for the
loop.
|
static Expression |
getIndexVariable(Loop loop)
Get loop index variable, if loop is canonical
|
static Symbol |
getLoopIndexSymbol(Loop loop)
Get symbol of loop index, index variable is identified from step
expression for loop
|
static java.lang.String |
getLoopName(Statement loop)
Returns the loop name inserted by Cetus.
|
static Expression |
getLowerBoundExpression(Loop loop)
Returns a simplified lower bound expression for the loop
|
static Loop |
getOutermostLoop(Loop loop)
Get the outermost loop for the nest that surrounds the input loop
|
static long |
getReuseDistance(Loop loop,
ArrayAccess e1,
ArrayAccess e2)
A simple implementation based on the Euclidean GCD algorithm to
calculate the distance in terms of loop iterations between
subscripts of dependent arrays.
|
static Expression |
getUpperBoundExpression(Loop loop)
Returns a simplified upper bound expression for the loop
|
static boolean |
isCanonical(Loop loop)
Check if loop is canonical, FORTRAN DO Loop format
|
static boolean |
isIncrementConstant(Loop loop)
Get loop increment expression and check if it is an integer constant
|
static boolean |
isIncrementEligible(Loop loop)
Returns true if the loop increment is an integer constant value.
|
static boolean |
isIndexInvariant(Loop loop,
Identifier id)
Check if the index variable is defined within the loop body
|
static boolean |
isInnermostLoop(Loop loop)
Checks whether this loop contains any inner loops
|
static boolean |
isLoopInvariant(Loop loop,
Expression e)
Check if the given expression is loop invariant
|
static boolean |
isLowerBoundConstant(Loop loop)
Check if the lower bound expression is an integer constant
|
static boolean |
isOutermostLoop(Loop loop)
Checks whether this loop is enclosed by any outer loops
|
static boolean |
isPerfectNest(Loop loop)
Check if this loop and inner loops form a perfect nest
|
static boolean |
isPrivate(Symbol s,
Loop l)
Check if the input symbol is marked as private to the loop by the
Privatization pass.
|
static boolean |
isReduction(Symbol s,
Loop l)
Check if the input symbol is marked as reduction for the loop by the
Reduction pass.
|
static boolean |
isUpperBoundConstant(Loop loop)
Check if loop upper bound is an integer constant
|
static Expression |
replaceSymbolicLowerBound(Loop loop)
Replaces symbolic values in loop lower bound with information obtained
from range analysis.
|
static Expression |
replaceSymbolicLowerBound(Loop loop,
RangeDomain loop_rd)
Replaces symbolic values in loop lower bound with information obtained
from range analysis.
|
static Expression |
replaceSymbolicUpperBound(Loop loop)
Replaces symbolic values in loop upper bound with information obtained
from range analysis.
|
static Expression |
replaceSymbolicUpperBound(Loop loop,
RangeDomain loop_rd)
Replaces symbolic values in loop upper bound with information obtained
from range analysis.
|
static boolean |
scalarDependencePossible(Loop l)
Check for scalars that are not privatizable or reduction variables
|
static java.lang.String |
toControlString(Loop loop)
Returns the control structure of the specified loop in string.
|
public static Expression getIncrementExpression(Loop loop)
public static boolean isIncrementConstant(Loop loop)
public static Expression getIndexVariable(Loop loop)
public static Expression getLowerBoundExpression(Loop loop)
public static boolean isLowerBoundConstant(Loop loop)
loop
- public static Expression getUpperBoundExpression(Loop loop)
loop
- public static boolean isUpperBoundConstant(Loop loop)
public static java.util.LinkedList<Loop> calculateLoopNest(Loop loop)
public static java.util.LinkedList<Loop> getCommonNest(Loop loop1, Loop loop2)
public static boolean isCanonical(Loop loop)
public static boolean containsFunctionCall(Loop loop)
public static boolean containsOnlyParallelizableCall(Loop loop)
public static boolean isPerfectNest(Loop loop)
public static boolean containsLoop(Loop loop)
public static boolean isIndexInvariant(Loop loop, Identifier id)
public static boolean isLoopInvariant(Loop loop, Expression e)
public static java.util.Set<Expression> collectScalarDependences(Loop l)
l
- the loop to be analyzed.public static boolean scalarDependencePossible(Loop l)
public static boolean isInnermostLoop(Loop loop)
public static boolean isOutermostLoop(Loop loop)
public static Loop getOutermostLoop(Loop loop)
public static boolean containsControlFlowModifier(Loop loop)
public static boolean containsBreakStatement(Loop loop)
public static boolean containsControlFlowModifierOtherThanBreakStmt(Loop loop)
public static java.util.LinkedList<Loop> calculateInnerLoopNest(Loop enclosing_loop)
public static java.lang.String getLoopName(Statement loop)
loop
- the loop.public static void addLoopName(Program program)
program
- the input program.public static boolean isPrivate(Symbol s, Loop l)
s
- the symbol which needs to be checked as private to loop or notl
- the loop with respect to which private property needs to be
checkedpublic static boolean isReduction(Symbol s, Loop l)
s
- the symbol which needs to be checked as reduction variable or notl
- the loop with respect to which reduction property needs to be
checkedpublic static boolean checkDataDependenceEligibility(Loop loop)
loop
- public static boolean isIncrementEligible(Loop loop)
loop
- the loop whose increment needs to be checkedpublic static Symbol getLoopIndexSymbol(Loop loop)
public static Expression replaceSymbolicLowerBound(Loop loop, RangeDomain loop_rd)
loop
- the loop whose symbolic lower bound is to be replacedloop_rd
- the range domain representing ranges for all vars in the
loop statementpublic static Expression replaceSymbolicLowerBound(Loop loop)
loop
- the loop whose symbolic lower bound is to be replacedpublic static Expression replaceSymbolicUpperBound(Loop loop, RangeDomain loop_rd)
loop
- the loop whose symbolic upper bound is to be replacedloop_rd
- the range domain representing ranges for all vars in the
loop statementpublic static Expression replaceSymbolicUpperBound(Loop loop)
loop
- the loop whose symbolic upper bound is to be replacedpublic static java.util.List<Loop> extractOutermostDependenceTestEligibleLoops(Traversable t)
public static long getReuseDistance(Loop loop, ArrayAccess e1, ArrayAccess e2)
loop
- the loop w.r.t which distance needs to be calculatede1
- array access that is one end of the dependencee2
- array access that is at the other end of the dependencepublic static java.lang.String toControlString(Loop loop)
loop
- the given loop.