scale.score.pp
Class PPCfg

java.lang.Object
  extended by scale.common.Root
      extended by scale.score.pp.PPCfg
All Implemented Interfaces:
java.lang.Comparable<PPCfg>, AnnotationInterface, DisplayNode

public final class PPCfg
extends Root
implements java.lang.Comparable<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

GRAPH_MODE_BEFORE_PROFILING

public static final int GRAPH_MODE_BEFORE_PROFILING
This option to generateGraph's mode parameter says to generate a graph without profiling information.

See Also:
Constant Field Values

GRAPH_MODE_PATH_NUMBERING

public static final 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.

See Also:
Constant Field Values

GRAPH_MODE_ABSTRACT_INSTRUMENTATION

public static final 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.

See Also:
Constant Field Values

GRAPH_MODE_ABSTRACT_INSTRUMENTATION_WITH_RANGES

public static final 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.

See Also:
Constant Field Values

GRAPH_MODE_REAL_INSTRUMENTATION

public static final 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.

See Also:
Constant Field Values

GRAPH_MODE_SHOW_PATH

public static final 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). The CFG should be acyclic and have Ball-Larus numbering on the edges (i.e., same format as GRAPH_MODE_PATH_NUMBERING).

See Also:
Constant Field Values

GRAPH_MODE_EDGE_FREQUENCIES

public static final 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. The CFG should be acyclic and have Ball-Larus numbering on the edges (i.e., same format as GRAPH_MODE_PATH_NUMBERING), and edge frequencies must have been computed.

See Also:
Constant Field Values

GRAPH_MODE_DEFINITE_FLOW_EDGES

public static final 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. The CFG should be acyclic and have Ball-Larus numbering on the edges (i.e., same format as GRAPH_MODE_PATH_NUMBERING), and edge frequencies must have been computed.

See Also:
Constant Field Values

GRAPH_MODE_DEFINITE_FLOW_PAIR

public static final 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. The CFG should be acyclic and have Ball-Larus numbering on the edges (i.e., same format as GRAPH_MODE_PATH_NUMBERING), and edge frequencies must have been computed.

See Also:
Constant Field Values

GRAPH_MODE_MST

public static final 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.

See Also:
Constant Field Values

RAW_METRIC

public static final 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).

See Also:
Constant Field Values

BRANCH_METRIC

public static final 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.

See Also:
Constant Field Values

generateGraphs

public static boolean generateGraphs
Specifies whether or not to generate .vcg files.


generateIncrements

public static boolean generateIncrements
Specifies whether or not to generate an increment mapping file.


debuggingOutput

public static boolean debuggingOutput
Specifies whether or not to output debug info to the console.


failWithoutProfile

public static boolean failWithoutProfile
Specifies whether or not to fail if a profile information file is not found.


truncateLoopEntrances

public static boolean truncateLoopEntrances
Specifies whether or not to truncate loop entrances.


simplerUnrollingHeuristic

public static boolean simplerUnrollingHeuristic
Specifies whether the simple or complex unrolling heuristic should be used for profile-guided unrolling.


pgp

public static boolean pgp
Specifies whether or not the last profile read (or instrumented for) uses profile-guided profiling.


pgpEventCounting

public 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.


pgpEdgeOrder

public 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.


pgpDisableAggressivePushing

public static boolean pgpDisableAggressivePushing
When doing profile-guided profiling, specifies whether to disable the aggressive instrumentation pushing that practical path profiling uses.


pgpAvoidHopelessHashRoutines

public 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.


pgpAlwaysRemoveColdEdges

public 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.


hashingThreshold

public static int hashingThreshold
The hashing threshold. If the number of paths is less than the hashing threshold, hashing is not used. Otherwise, hashing is used.


hashTableSize

public static int hashTableSize
The hash table size to use if hashing is used. In reality, the hash table will be 1 element larger than this size because the last slot is used for "lost" paths.


pathAnalysisIndex

public static int pathAnalysisIndex
Specifies the profile index to perform path analysis on.


pgpColdRoutineThreshold

public 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.


pgpDesiredAdf

public 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.


pgpRoutineAdfThreshold

public static double pgpRoutineAdfThreshold
When doing profile-guided profiling, we only instrument routines with less than this attribution of definite flow.


pgpLocalColdEdgeThreshold

public 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.


pgpGlobalColdEdgeThreshold

public 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.


pgpLoopDisconnectThreshold

public static double pgpLoopDisconnectThreshold
When doing profile-guided profiling, if a loop's average iteration count is greater than this value, it should be disconnected.


pgpFlexibleColdFactor

public 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.

Constructor Detail

PPCfg

public PPCfg(Scribble scribble,
             PPCfg pgpEdgeProfileCfg)
Create a CFG used for path profiling from Scale's CFG representation.

Parameters:
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

getEdge

public PPEdge getEdge(PPBlock source,
                      PPBlock target,
                      int type)
Return the edge whose attributes are given. If the edge does not exist, create it.


findEdge

public PPEdge findEdge(PPBlock source,
                       PPBlock target,
                       int type)
Return the edge whose attributes are given. If the edge does not exist, return null.


hasEdge

public boolean hasEdge(PPBlock source,
                       PPBlock target,
                       int type)
Return true if the edge, whose attributes are given, exists.


toString

public java.lang.String toString()
Overrides:
toString in class Root

compareTo

public int compareTo(PPCfg o2)
Compare two CFGs by flow. Sort in ascending order.

Specified by:
compareTo in interface java.lang.Comparable<PPCfg>

addEdge

public void addEdge(PPEdge edge)
Add an edge to the graph. Duplicates are not allowed.


splitBlock

public PPBlock splitBlock(Chord first,
                          Chord newFirstChord,
                          boolean allowFakeSplit)
Split a basic block in two.

Parameters:
first - is the first Chord in the block
newFirstChord - is the first chord of the second basic block
allowFakeSplit - true if the new first chord need not be in the basic block
Returns:
the new block that begins with the new first chord

splitBlock

public PPBlock splitBlock(PPBlock block,
                          Chord newFirstChord,
                          boolean allowFakeSplit)
Split a basic block in two.

Parameters:
block - the basic block to split.
newFirstChord - the first chord of the second basic block
allowFakeSplit - true if the new first chord need not be in the basic block
Returns:
the new block that begins with the new first chord

removeAndUpdate

public void removeAndUpdate(PPCfg calleePPCfg,
                            Chord callStmt,
                            HashMap<Chord,Chord> nm)

removeBlock

public void removeBlock(Chord first)

removeBlock

public void removeBlock(PPBlock block)

inlineCall

public 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. Do not call this routine if nothing was inlined by the inlining code that operates on chords.

Parameters:
calleeCfg - is the callee's CFG
callStmt - is the call that was replaced
newIn - is the set of new CFG nodes
nm - is a map from old chords to new chords

beginBlock

public PPBlock beginBlock()
Return the first block in the CFG.


endBlock

public PPBlock endBlock()
Return the last block in the CFG.


useHashing

public final boolean useHashing()
Return true if and only if we will use hashing to count path numbers. If the number of paths is greater than or equal to a threshold, we use hashing. Otherwise, we do not.


getPathTableSize

public int getPathTableSize()
Get the size of the path table. If we are using hashing, return ONE MORE THAN a suitable hash table size (HASH_TABLE_SIZE + 1). (The extra slot is not used for hashing but rather for counting the "lost" paths taken.) Otherwise, return the number of paths.


setPathFreqMap

public void setPathFreqMap(HashMap<java.lang.Long,java.lang.Long> pathFreqMap)
Set the path frequency map. This also generates an edge profile from the path profile. If graph generation is turned on, many graphs are generated.

Parameters:
pathFreqMap - is a map from path numbers to path frequencies.

getBlockFreq

public long getBlockFreq(Chord first)
Get the frequency of a basic block.


getBlockFreq

public long getBlockFreq(PPBlock block)
Get the frequency of a basic block.


getAvgTripCount

public double getAvgTripCount(LoopHeaderChord loopHeader)
Get the average trip count for a loop.

Parameters:
loopHeader - is the block that is the header of a loop.

getTotalProgFlow

public static long getTotalProgFlow()
Get the total frequency of all loop headers in the program.


makeCyclicPreservingEdgeProfile

public void makeCyclicPreservingEdgeProfile()
Make the graph cyclic, and preserve its edge profile. Because of lost paths and truncated edges, the edge profile may not be perfectly valid (i.e., flow in may not always equal flow out).


isCyclic

public boolean isCyclic()
Get whether or not the graph is cyclic.


validateCFG

public void validateCFG()
Validate the CFG. Throw an error if the CFG is invalid.


getRoutineName

public java.lang.String getRoutineName()
Get the routine name.


setOutputPath

public static void setOutputPath(java.lang.String path)
Set the path to the directory that the generated files will be written to.


generateGraph

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)
Generate a VCG graph of this CFG to a file.

Parameters:
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.
Returns:
true if the file does not already exist, false otherwise.

generateGraph

public 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. See the other generateGraph() method for more info.

Parameters:
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.
Returns:
true if the file does not already exist, false otherwise.

generateGraph

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)
Generate a VCG graph of this CFG.

Parameters:
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.

isPgp

public boolean isPgp()
Return true if this CFG is for profile-guided profiling.


getPgpBlock

public PPBlock getPgpBlock(PPBlock block)
Get an equivalent block in the CFG that has the edge profile.


getPgpBlockInverse

public PPBlock getPgpBlockInverse(PPBlock pgpBlock,
                                  boolean ignoreNotInCfg)
Given a block from the CFG with the edge profile, return the block in this CFG.


doAnalysis

public 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.

Parameters:
analysisOnly - true if path profiling will be used for analyzing a profile, rather than for instrumentation.
Returns:
a map from edges to abstract instrumentation (only if analysisOnly is false).

doInstrumentation

public 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. The modifications to the CFG are persistent.

Parameters:
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().

getDebuggingOutput

public static boolean getDebuggingOutput()
Get whether or not to output debugging text to the console.


getFailWithoutProfile

public static boolean getFailWithoutProfile()
Get whether or not to fail if the profile information file not found.


getPathAnalysisIndex

public static int getPathAnalysisIndex()
Get the index of the profile on which path analysis should be performed (or -1 if none).


getSimplerUnrollingHeuristic

public static boolean getSimplerUnrollingHeuristic()
Get whether we should use the simple or complex unrolling heuristic for profile-guided unrolling.


getPgp

public static boolean getPgp()
Get whether or not to perform profile-guided profiling instead of regular path profiling.


getPgpCfg

public static PPCfg getPgpCfg(PPCfg cfg)

getPgpAbstractInstrMap

public static HashMap<PPEdge,scale.score.pp.PPCfg.Instr> getPgpAbstractInstrMap(PPCfg cfg)

doNotInstrument

public 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.


doAnalysis

public static void doAnalysis()
Perform analysis on edge and path profiles through all CFGs.


addProfilingInSpecialOrder

public static void addProfilingInSpecialOrder(int profileOptions)
Called by Suite.addProfiling() in an order determined by profile-guided profiling. This allows us to not instrument certain routines if we get enough ADF from instrumenting some routines which must include the module containing "main".

Parameters:
profileOptions - specifies which profiling instrumentation to insert

printPathLengthHistogram

public static void printPathLengthHistogram(HashSet<scale.score.pp.PPCfg.Path> paths,
                                            boolean useLatestCfgs,
                                            boolean assumeAllArrays)

cleanup

public static void cleanup()