use of com.jopdesign.common.code.Segment in project jop by jop-devel.
the class GlobalAnalysis method computeWCET.
/**
* Compute WCET using global IPET, and either ALWAYS_MISS or GLOBAL_ALL_FIT
*/
public WcetCost computeWCET(MethodInfo m, AnalysisContextLocal ctx) throws Exception {
CacheCostCalculationMethod cacheMode = ctx.getCacheApproxMode();
String key = "global" + "_" + cacheMode;
Segment segment = Segment.methodSegment(m, ctx.getCallString(), project, project.getAppInfo().getCallstringLength(), project);
return computeWCET(key, segment, cacheMode);
}
use of com.jopdesign.common.code.Segment in project jop by jop-devel.
the class WCETAnalysis method exploreCacheAnalysis.
/**
* @param mca
* @param iter
* @throws InvalidFlowFactException
*/
@SuppressWarnings("unused")
private void exploreCacheAnalysis() throws InvalidFlowFactException {
// Segment Cache Analysis: Experiments
MethodCacheAnalysis mca = new MethodCacheAnalysis(wcetTool);
/* iterate top down the scope graph (currently: the call graph) */
TopologicalOrderIterator<ExecutionContext, ContextEdge> iter = wcetTool.getCallGraph().reverseTopologicalOrder();
LpSolveWrapper.resetSolverTime();
long blocks = 0;
long start = System.nanoTime();
while (iter.hasNext()) {
ExecutionContext scope = iter.next();
Segment segment = Segment.methodSegment(scope.getMethodInfo(), scope.getCallString(), wcetTool, wcetTool.getCallstringLength(), wcetTool);
int availBlocks = wcetTool.getWCETProcessorModel().getMethodCache().getNumBlocks();
long total, distinctApprox = -1, distinct = -1;
blocks = total = mca.countDistinctBlocksUsed(segment);
if (total > availBlocks || true) {
try {
blocks = distinctApprox = mca.countDistinctBlocksAccessed(segment, false);
if (blocks > availBlocks && blocks < availBlocks * 2 || true) {
blocks = distinct = mca.countDistinctBlocksAccessed(segment, true);
}
} catch (LpSolveException e) {
System.err.println((distinctApprox >= 0 ? "I" : "Relaxed ") + "LP Problem too difficult, giving up: " + e);
}
}
System.out.println(String.format("block-count < %2d [%2d,%2d,%2d] for %-30s @ %s", blocks, total, distinctApprox, distinct, scope.getMethodInfo().getFQMethodName(), scope.getCallString().toStringVerbose(false)));
}
long stop = System.nanoTime();
reportSpecial("block-count", WcetCost.totalCost(blocks), start, stop, LpSolveWrapper.getSolverTime());
System.out.println("solver-time: " + LpSolveWrapper.getSolverTime());
}
use of com.jopdesign.common.code.Segment in project jop by jop-devel.
the class WCETAnalysis method runBlockingTimeAnalysis.
private void runBlockingTimeAnalysis(MethodInfo targetMethod) throws InvalidFlowFactException, LpSolveException, UnsupportedCacheModelException {
GlobalAnalysis an = new GlobalAnalysis(wcetTool, ipetConfig);
CacheCostCalculationMethod requestedCacheApprox = IPETConfig.getRequestedCacheApprox(config);
/* Find all synchronized segments */
Segment target = Segment.methodSegment(targetMethod, CallString.EMPTY, wcetTool, wcetTool.getCallstringLength(), wcetTool);
ArrayList<SynchronizedBlockResult> sBlocks = new ArrayList<SynchronizedBlockResult>();
for (ContextCFG ccfg : target.getCallGraphNodes()) {
for (CFGNode cfgNode : ccfg.getCfg().vertexSet()) {
if (cfgNode.getBasicBlock() == null)
continue;
for (InstructionHandle ih : cfgNode.getBasicBlock().getInstructions()) {
if (ih.getInstruction() instanceof MONITORENTER) {
/* compute synchronized block WCET */
Segment synchronizedSegment = Segment.synchronizedSegment(ccfg, cfgNode, ih, wcetTool, wcetTool.getCallstringLength(), wcetTool);
wcet = an.computeWCET(targetMethod.getShortName(), synchronizedSegment, requestedCacheApprox);
sBlocks.add(new SynchronizedBlockResult(sBlocks.size(), synchronizedSegment, cfgNode, ih, wcet));
}
}
}
}
/* check nested synchronized blocks */
for (SynchronizedBlockResult sBlock : sBlocks) {
for (SynchronizedBlockResult otherBlock : sBlocks) {
if (sBlock == otherBlock)
continue;
for (SuperGraphEdge entryEdge : otherBlock.synchronizedSegment.getEntryEdges()) {
if (sBlock.synchronizedSegment.includesEdge(entryEdge)) {
sBlock.nested.add(otherBlock);
break;
}
}
}
}
System.out.println("=== Synchronized Blocks ===");
for (SynchronizedBlockResult sBlock : sBlocks) {
sBlock.dump(System.out);
}
}
use of com.jopdesign.common.code.Segment in project jop by jop-devel.
the class WCETAnalysis method runGlobal.
private void runGlobal(MethodInfo targetMethod) throws InvalidFlowFactException, LpSolveException, UnsupportedCacheModelException {
CacheCostCalculationMethod requestedCacheApprox = IPETConfig.getRequestedCacheApprox(config);
GlobalAnalysis an = new GlobalAnalysis(wcetTool, ipetConfig);
Segment target = Segment.methodSegment(targetMethod, CallString.EMPTY, wcetTool, wcetTool.getCallstringLength(), wcetTool);
/* Run global analysis */
// for(CacheCostCalculationMethod cacheApprox : CacheCostCalculationMethod.values()) {
LpSolveWrapper.resetSolverTime();
long start = System.nanoTime();
wcet = an.computeWCET(targetMethod.getShortName(), target, requestedCacheApprox);
long stop = System.nanoTime();
report(wcet, start, stop, LpSolveWrapper.getSolverTime());
}
use of com.jopdesign.common.code.Segment in project jop by jop-devel.
the class ObjectCacheAnalysis method findPersistenceSegmentCover.
/** Find a segment cover (i.e., a set of segments covering all execution paths)
* where each segment in the set is persistent (a cache persistence region (CPR))
*
* <h2>The simplest algorithm for a segment S (for acyclic callgraphs)</h2>
* <ul><li/>Check whether S itself is CPR; if so, return S
* <li/>Otherwise, create subsegments S' for each invoked method,
* <li/>and single node segments for each access
* </ul>
* @param segment the parent segment
* @param checks the strategy to use to determine whether a segment is a persistence region
* @param avoidOverlap whether overlapping segments should be avoided
* @param alwaysMissNodes additional node set considered to be always miss
* @return
* @throws LpSolveException
* @throws InvalidFlowFactException
*/
protected Collection<Segment> findPersistenceSegmentCover(Segment segment, EnumSet<PersistenceCheck> checks, boolean avoidOverlap, Set<SuperGraphNode> alwaysMissNodes) throws InvalidFlowFactException, LpSolveException {
List<Segment> cover = new ArrayList<Segment>();
/* We currently only support entries to one CFG */
Set<ContextCFG> entryMethods = new HashSet<ContextCFG>();
for (SuperGraphEdge entryEdge : segment.getEntryEdges()) {
entryMethods.add(entryEdge.getTarget().getContextCFG());
}
ContextCFG entryMethod;
if (entryMethods.size() != 1) {
throw new AssertionError("findPersistenceSegmentCover: only supporting segments with unique entry method");
} else {
entryMethod = entryMethods.iterator().next();
}
if (this.isPersistenceRegion(segment, checks)) {
cover.add(segment);
} else {
/* method sub segments */
for (Pair<SuperInvokeEdge, SuperReturnEdge> invocation : segment.getCallSitesFrom(entryMethod)) {
ContextCFG callee = invocation.first().getCallee();
// System.err.println("Recursively analyzing: "+callee);
Segment subSegment = Segment.methodSegment(callee, segment.getSuperGraph());
cover.addAll(findPersistenceSegmentCover(subSegment, checks, avoidOverlap, alwaysMissNodes));
}
/* always miss nodes (not covered) */
alwaysMissNodes.addAll(segment.getNodes(entryMethod));
}
return cover;
}
Aggregations