|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.score.pp.PPCfg
public final class PPCfg
A CFG representation designed specifically for Ball-Larus path profiling.
$Id: PPCfg.java,v 1.33 2007-10-29 13:38:14 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Field Summary | |
---|---|
static int |
BRANCH_METRIC
Represents the idea that the flow of a path is the number of times it was taken (or estimated to be taken) multiplied by the number of branches in the path. |
static boolean |
debuggingOutput
Specifies whether or not to output debug info to the console. |
static boolean |
failWithoutProfile
Specifies whether or not to fail if a profile information file is not found. |
static boolean |
generateGraphs
Specifies whether or not to generate .vcg files. |
static boolean |
generateIncrements
Specifies whether or not to generate an increment mapping file. |
static int |
GRAPH_MODE_ABSTRACT_INSTRUMENTATION
This option to generateGraph's mode parameter says to generate a graph that shows path profiling instrumentation on the edges. |
static int |
GRAPH_MODE_ABSTRACT_INSTRUMENTATION_WITH_RANGES
This option to generateGraph's mode parameter says to generate a graph that shows path profiling instrumentation on the edges and shows path register ranges on the blocks. |
static int |
GRAPH_MODE_BEFORE_PROFILING
This option to generateGraph's mode parameter says to generate a graph without profiling information. |
static int |
GRAPH_MODE_DEFINITE_FLOW_EDGES
This option to generateGraph's mode parameter says to generate a graph that labels each edge with its execution frequency and the amount of definite flow on all paths that include the edge. |
static int |
GRAPH_MODE_DEFINITE_FLOW_PAIR
This option to generateGraph's mode parameter says to generate a graph that labels each edge with its execution frequency and a definite flow pair (flow, numBranches) from that edge to the end of the CFG. |
static int |
GRAPH_MODE_EDGE_FREQUENCIES
This option to generateGraph's mode parameter says to generate a graph that labels each edge with its execution frequency. |
static int |
GRAPH_MODE_MST
This option to generateGraph's mode parameter says to generate a graph that labels each edge with its weight and colors edges in the max spanning tree. |
static int |
GRAPH_MODE_PATH_NUMBERING
This option to generateGraph's mode parameter says to generate a graph for an acyclic CFG that has Ball-Larus number on its edges. |
static int |
GRAPH_MODE_REAL_INSTRUMENTATION
This option to generateGraph's mode parameter says to generate a graph that shows path profiling instrumentation on the edges. |
static int |
GRAPH_MODE_SHOW_PATH
This option to generateGraph's mode parameter says to generate a graph that highlights a single path (specified with another argument to generateGraph). |
static int |
hashingThreshold
The hashing threshold. |
static int |
hashTableSize
The hash table size to use if hashing is used. |
static int |
pathAnalysisIndex
Specifies the profile index to perform path analysis on. |
static boolean |
pgp
Specifies whether or not the last profile read (or instrumented for) uses profile-guided profiling. |
static boolean |
pgpAlwaysRemoveColdEdges
When doing profile-guided profiling, specifies whether to remove cold edges in all routines or just the routines that can be made to go from hashing to arrays. |
static boolean |
pgpAvoidHopelessHashRoutines
When doing profile-guided profiling, specifies whether to instrument a routine if, even after cold and obvious edge removal, it still needs hashing. |
static double |
pgpColdRoutineThreshold
When doing profile-guided profiling, specifies the threshold (as a proportion of total program flow) that a routine's flow must be below to be considered cold. |
static double |
pgpDesiredAdf
When doing profile-guided profiling, the desired amount of attribution of definite flow (as a proportion of total program flow) for the entire program. |
static boolean |
pgpDisableAggressivePushing
When doing profile-guided profiling, specifies whether to disable the aggressive instrumentation pushing that practical path profiling uses. |
static boolean |
pgpEdgeOrder
When doing profile-guided profiling, specifies whether to use the edge profile to order the traversal of edges in the path profiling algorithm that numbers paths. |
static boolean |
pgpEventCounting
When doing profile-guided profiling, specifies whether to use the edge profile to pick the maximum spanning tree used for Ball's event counting algorithm. |
static double |
pgpFlexibleColdFactor
When doing profile-guided profiling, specifies the amount by which to multiply the global edge criterion if our routine still needs hashing. |
static double |
pgpGlobalColdEdgeThreshold
When doing profile-guided profiling, the threshold (as a proportion of total program flow) that an edge's flow must be below to be considered cold. |
static double |
pgpLocalColdEdgeThreshold
When doing profile-guided profiling, the threshold (as a proportion of the flow through the edge's source) that an edge's flow must be below to be considered cold. |
static double |
pgpLoopDisconnectThreshold
When doing profile-guided profiling, if a loop's average iteration count is greater than this value, it should be disconnected. |
static double |
pgpRoutineAdfThreshold
When doing profile-guided profiling, we only instrument routines with less than this attribution of definite flow. |
static int |
RAW_METRIC
Represents the idea that the flow of a path is the number of times it was taken (or estimated to be taken). |
static boolean |
simplerUnrollingHeuristic
Specifies whether the simple or complex unrolling heuristic should be used for profile-guided unrolling. |
static boolean |
truncateLoopEntrances
Specifies whether or not to truncate loop entrances. |
Constructor Summary | |
---|---|
PPCfg(Scribble scribble,
PPCfg pgpEdgeProfileCfg)
Create a CFG used for path profiling from Scale's CFG representation. |
Method Summary | |
---|---|
void |
addEdge(PPEdge edge)
Add an edge to the graph. |
static void |
addProfilingInSpecialOrder(int profileOptions)
Called by Suite.addProfiling() in an order determined by profile-guided profiling. |
PPBlock |
beginBlock()
Return the first block in the CFG. |
static void |
cleanup()
|
int |
compareTo(PPCfg o2)
Compare two CFGs by flow. |
static void |
doAnalysis()
Perform analysis on edge and path profiles through all CFGs. |
HashMap<PPEdge,scale.score.pp.PPCfg.Instr> |
doAnalysis(boolean analysisOnly,
boolean removeColdEdges)
The first half of the Ball-Larus path profiling algorithm: Make the CFG acyclic, and determine the increments that go on the edges. |
void |
doInstrumentation(VariableDecl pathRegister,
VariableDecl counterArray,
VariableDecl tempVar,
VariableDecl profileInfoVar,
IntegerType pfit64,
RoutineDecl hashRoutineDecl)
The second half of the Ball-Larus path profiling algorithm: Restore the CFG's back edges, place instrumentation on the edges, and insert that instrumentation. |
static boolean |
doNotInstrument(Scribble cfg)
Return true if the specified CFG is a member of an unmodifiable set of Scribble CFGs that should not be instrumented. |
PPBlock |
endBlock()
Return the last block in the CFG. |
PPEdge |
findEdge(PPBlock source,
PPBlock target,
int type)
Return the edge whose attributes are given. |
boolean |
generateGraph(java.lang.String partialName,
int mode,
HashMap<PPEdge,? extends java.lang.Object> instrumentationMap)
Generate a VCG graph of this CFG to a file. |
boolean |
generateGraph(java.lang.String partialName,
int mode,
HashMap<PPEdge,? extends java.lang.Object> instrumentationMap,
long pathNumber,
HashMap<java.lang.Object,HashMap<scale.score.pp.PPCfg.FBPair,java.lang.Long>> valueMap,
java.util.Collection<? extends java.lang.Object> specialBlocksOrEdges,
int flowMetric)
Generate a VCG graph of this CFG to a file. |
void |
generateGraph(java.lang.String partialName,
java.io.PrintStream ps,
int mode,
HashMap<PPEdge,? extends java.lang.Object> instrumentationMap,
long pathNumber,
HashMap<java.lang.Object,HashMap<scale.score.pp.PPCfg.FBPair,java.lang.Long>> valueMap,
java.util.Collection<? extends java.lang.Object> specialBlocksOrEdges,
int flowMetric)
Generate a VCG graph of this CFG. |
double |
getAvgTripCount(LoopHeaderChord loopHeader)
Get the average trip count for a loop. |
long |
getBlockFreq(Chord first)
Get the frequency of a basic block. |
long |
getBlockFreq(PPBlock block)
Get the frequency of a basic block. |
static boolean |
getDebuggingOutput()
Get whether or not to output debugging text to the console. |
PPEdge |
getEdge(PPBlock source,
PPBlock target,
int type)
Return the edge whose attributes are given. |
static boolean |
getFailWithoutProfile()
Get whether or not to fail if the profile information file not found. |
static int |
getPathAnalysisIndex()
Get the index of the profile on which path analysis should be performed (or -1 if none). |
int |
getPathTableSize()
Get the size of the path table. |
static boolean |
getPgp()
Get whether or not to perform profile-guided profiling instead of regular path profiling. |
static HashMap<PPEdge,scale.score.pp.PPCfg.Instr> |
getPgpAbstractInstrMap(PPCfg cfg)
|
PPBlock |
getPgpBlock(PPBlock block)
Get an equivalent block in the CFG that has the edge profile. |
PPBlock |
getPgpBlockInverse(PPBlock pgpBlock,
boolean ignoreNotInCfg)
Given a block from the CFG with the edge profile, return the block in this CFG. |
static PPCfg |
getPgpCfg(PPCfg cfg)
|
java.lang.String |
getRoutineName()
Get the routine name. |
static boolean |
getSimplerUnrollingHeuristic()
Get whether we should use the simple or complex unrolling heuristic for profile-guided unrolling. |
static long |
getTotalProgFlow()
Get the total frequency of all loop headers in the program. |
boolean |
hasEdge(PPBlock source,
PPBlock target,
int type)
Return true if the edge, whose attributes are given, exists. |
void |
inlineCall(PPCfg calleeCfg,
Chord callStmt,
Chord newIn,
HashMap<Chord,Chord> nm)
Add the call block with the callee CFG's contents, and remove the call block. |
boolean |
isCyclic()
Get whether or not the graph is cyclic. |
boolean |
isPgp()
Return true if this CFG is for profile-guided profiling. |
void |
makeCyclicPreservingEdgeProfile()
Make the graph cyclic, and preserve its edge profile. |
static void |
printPathLengthHistogram(HashSet<scale.score.pp.PPCfg.Path> paths,
boolean useLatestCfgs,
boolean assumeAllArrays)
|
void |
removeAndUpdate(PPCfg calleePPCfg,
Chord callStmt,
HashMap<Chord,Chord> nm)
|
void |
removeBlock(Chord first)
|
void |
removeBlock(PPBlock block)
|
static void |
setOutputPath(java.lang.String path)
Set the path to the directory that the generated files will be written to. |
void |
setPathFreqMap(HashMap<java.lang.Long,java.lang.Long> pathFreqMap)
Set the path frequency map. |
PPBlock |
splitBlock(Chord first,
Chord newFirstChord,
boolean allowFakeSplit)
Split a basic block in two. |
PPBlock |
splitBlock(PPBlock block,
Chord newFirstChord,
boolean allowFakeSplit)
Split a basic block in two. |
java.lang.String |
toString()
|
boolean |
useHashing()
Return true if and only if we will use hashing to count path numbers. |
void |
validateCFG()
Validate the CFG. |
Methods inherited from class scale.common.Root |
---|
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayColorHint, getDisplayLabel, getDisplayName, getDisplayShapeHint, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, toStringSpecial, trace, trace, trace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int GRAPH_MODE_BEFORE_PROFILING
public static final int GRAPH_MODE_PATH_NUMBERING
public static final int GRAPH_MODE_ABSTRACT_INSTRUMENTATION
public static final int GRAPH_MODE_ABSTRACT_INSTRUMENTATION_WITH_RANGES
public static final int GRAPH_MODE_REAL_INSTRUMENTATION
public static final int GRAPH_MODE_SHOW_PATH
public static final int GRAPH_MODE_EDGE_FREQUENCIES
public static final int GRAPH_MODE_DEFINITE_FLOW_EDGES
public static final int GRAPH_MODE_DEFINITE_FLOW_PAIR
public static final int GRAPH_MODE_MST
public static final int RAW_METRIC
public static final int BRANCH_METRIC
public static boolean generateGraphs
public static boolean generateIncrements
public static boolean debuggingOutput
public static boolean failWithoutProfile
public static boolean truncateLoopEntrances
public static boolean simplerUnrollingHeuristic
public static boolean pgp
public static boolean pgpEventCounting
public static boolean pgpEdgeOrder
public static boolean pgpDisableAggressivePushing
public static boolean pgpAvoidHopelessHashRoutines
public static boolean pgpAlwaysRemoveColdEdges
public static int hashingThreshold
public static int hashTableSize
public static int pathAnalysisIndex
public static double pgpColdRoutineThreshold
public static double pgpDesiredAdf
public static double pgpRoutineAdfThreshold
public static double pgpLocalColdEdgeThreshold
public static double pgpGlobalColdEdgeThreshold
public static double pgpLoopDisconnectThreshold
public static double pgpFlexibleColdFactor
Constructor Detail |
---|
public PPCfg(Scribble scribble, PPCfg pgpEdgeProfileCfg)
scribble
- is Scale's CFG representation.pgpEdgeProfileCfg
- is the CFG with the edge profile if
profile-guided profiling is being used or null .Method Detail |
---|
public PPEdge getEdge(PPBlock source, PPBlock target, int type)
public PPEdge findEdge(PPBlock source, PPBlock target, int type)
null
.
public boolean hasEdge(PPBlock source, PPBlock target, int type)
public java.lang.String toString()
toString
in class Root
public int compareTo(PPCfg o2)
compareTo
in interface java.lang.Comparable<PPCfg>
public void addEdge(PPEdge edge)
public PPBlock splitBlock(Chord first, Chord newFirstChord, boolean allowFakeSplit)
first
- is the first Chord in the blocknewFirstChord
- is the first chord of the second basic blockallowFakeSplit
- true if the new first chord need not be in
the basic block
public PPBlock splitBlock(PPBlock block, Chord newFirstChord, boolean allowFakeSplit)
block
- the basic block to split.newFirstChord
- the first chord of the second basic blockallowFakeSplit
- true if the new first chord need not be in
the basic block
public void removeAndUpdate(PPCfg calleePPCfg, Chord callStmt, HashMap<Chord,Chord> nm)
public void removeBlock(Chord first)
public void removeBlock(PPBlock block)
public void inlineCall(PPCfg calleeCfg, Chord callStmt, Chord newIn, HashMap<Chord,Chord> nm)
calleeCfg
- is the callee's CFGcallStmt
- is the call that was replacednewIn
- is the set of new CFG nodesnm
- is a map from old chords to new chordspublic PPBlock beginBlock()
public PPBlock endBlock()
public final boolean useHashing()
public int getPathTableSize()
public void setPathFreqMap(HashMap<java.lang.Long,java.lang.Long> pathFreqMap)
pathFreqMap
- is a map from path numbers to path frequencies.public long getBlockFreq(Chord first)
public long getBlockFreq(PPBlock block)
public double getAvgTripCount(LoopHeaderChord loopHeader)
loopHeader
- is the block that is the header of a loop.public static long getTotalProgFlow()
public void makeCyclicPreservingEdgeProfile()
public boolean isCyclic()
public void validateCFG()
public java.lang.String getRoutineName()
public static void setOutputPath(java.lang.String path)
public boolean generateGraph(java.lang.String partialName, int mode, HashMap<PPEdge,? extends java.lang.Object> instrumentationMap, long pathNumber, HashMap<java.lang.Object,HashMap<scale.score.pp.PPCfg.FBPair,java.lang.Long>> valueMap, java.util.Collection<? extends java.lang.Object> specialBlocksOrEdges, int flowMetric)
mode
- The graph mode to use when generate the graph. See
the GRAPH_MODE_ constants.instrumentationMap
- is a map from PPEdge or PPBlock to List of
Chord. This param is used only if mode ==
GRAPH_MODE_INSTRUMENTATION.pathNumber
- is the path number for a path that we want
highlighted. This param is used only if mode ==
GRAPH_MODE_SHOW_PATH.valueMap
- is a map from edges and/or blocks to values of
some sort. This param is used only if mode ==
GRAPH_MODE_DEFINITE_FLOW or GRAPH_MODE_MST.specialBlocksOrEdges
- is a collection of blocks and/or
edges that will be colored red (blocks) or green (edges).flowMetric
- is the flow metric to use for definite flow if
mode == GRAPH_MODE_DEFINITE_FLOW.
public boolean generateGraph(java.lang.String partialName, int mode, HashMap<PPEdge,? extends java.lang.Object> instrumentationMap)
mode
- The graph mode to use when generate the graph. See
the GRAPH_MODE_ constants.instrumentationMap
- is a map from PPEdge or PPBlock to List of
Chord. This param is used only if mode ==
GRAPH_MODE_INSTRUMENTATION.
public void generateGraph(java.lang.String partialName, java.io.PrintStream ps, int mode, HashMap<PPEdge,? extends java.lang.Object> instrumentationMap, long pathNumber, HashMap<java.lang.Object,HashMap<scale.score.pp.PPCfg.FBPair,java.lang.Long>> valueMap, java.util.Collection<? extends java.lang.Object> specialBlocksOrEdges, int flowMetric)
ps
- The PrintStream to write to.mode
- The graph mode to use when generate the graph. See
the GRAPH_MODE_ constants.instrumentationMap
- is a map from PPEdge or PPBlock to List of
Chord. This param is used only if mode ==
GRAPH_MODE_INSTRUMENTATION.pathNumber
- is the path number for a path that we want
highlighted. This param is used only if mode ==
GRAPH_MODE_SHOW_PATH.valueMap
- is a map from edges and/or blocks to values of
some sort. This param is used only if mode ==
GRAPH_MODE_DEFINITE_FLOW or GRAPH_MODE_MST.specialBlocksOrEdges
- is a collection of blocks and/or
edges that will be colored red (blocks) or green (edges).flowMetric
- is the flow metric to use for definite flow if
mode == GRAPH_MODE_DEFINITE_FLOW.public boolean isPgp()
public PPBlock getPgpBlock(PPBlock block)
public PPBlock getPgpBlockInverse(PPBlock pgpBlock, boolean ignoreNotInCfg)
public HashMap<PPEdge,scale.score.pp.PPCfg.Instr> doAnalysis(boolean analysisOnly, boolean removeColdEdges)
analysisOnly
- true if path profiling will be used for
analyzing a profile, rather than for instrumentation.
public void doInstrumentation(VariableDecl pathRegister, VariableDecl counterArray, VariableDecl tempVar, VariableDecl profileInfoVar, IntegerType pfit64, RoutineDecl hashRoutineDecl)
pathRegister
- is the variable declaration for the path register.counterArray
- is the variable declaration for the address
of the array of counters.tempVar
- is the variable declaration for the temporary
variable we used for path profiling.profileInfoVar
- is the variable declaration for the profile
information.pfit64
- is the 64-bit integer type in Scribble.hashRoutineDecl
- is the declaration for __pf_hash_path().public static boolean getDebuggingOutput()
public static boolean getFailWithoutProfile()
public static int getPathAnalysisIndex()
public static boolean getSimplerUnrollingHeuristic()
public static boolean getPgp()
public static PPCfg getPgpCfg(PPCfg cfg)
public static HashMap<PPEdge,scale.score.pp.PPCfg.Instr> getPgpAbstractInstrMap(PPCfg cfg)
public static boolean doNotInstrument(Scribble cfg)
public static void doAnalysis()
public static void addProfilingInSpecialOrder(int profileOptions)
profileOptions
- specifies which profiling instrumentation to insertpublic static void printPathLengthHistogram(HashSet<scale.score.pp.PPCfg.Path> paths, boolean useLatestCfgs, boolean assumeAllArrays)
public static void cleanup()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |