use of com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod 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.wcet.ipet.IPETConfig.CacheCostCalculationMethod in project jop by jop-devel.
the class WCETAnalysis method runMetrics.
private void runMetrics(MethodInfo targetMethod) throws Exception {
/* generate reports later for simple_fit */
wcetTool.setGenerateWCETReport(false);
/* check whether the largest method fits into the cache */
List<MethodInfo> allMethods = wcetTool.getCallGraph().getReachableImplementations(targetMethod);
MethodInfo largestMethod = MethodCacheAnalysis.checkCache(wcetTool, allMethods);
int minWords = MiscUtils.bytesToWords(largestMethod.getCode().getNumberOfBytes());
reportMetric("min-cache-size", largestMethod.getFQMethodName(), minWords);
/* Compute cyclomatic complexity */
exec.info("Cyclomatic complexity: " + wcetTool.computeCyclomaticComplexity(targetMethod));
/* Fast, useful cache approximationx */
CacheCostCalculationMethod cacheApprox = CacheCostCalculationMethod.ALL_FIT_SIMPLE;
/* Perform a few standard analysis (MIN_CACHE_COSdT, ALWAYS_HIT, ALWAYS_MISS) without call strings */
long start, stop;
/* Tree based WCET analysis - has to be equal to ALWAYS_MISS if no flow facts are used */
{
start = System.nanoTime();
TreeAnalysis treeAna = new TreeAnalysis(wcetTool, false);
long treeWCET = treeAna.computeWCET(targetMethod);
stop = System.nanoTime();
reportMetric("progress-measure", treeAna.getMaxProgress(targetMethod));
reportSpecial("wcet.tree", WcetCost.totalCost(treeWCET), start, stop, 0.0);
}
RecursiveWcetAnalysis<AnalysisContextLocal> an = new RecursiveWcetAnalysis<AnalysisContextLocal>(wcetTool, ipetConfig, new LocalAnalysis(wcetTool, ipetConfig));
/* always miss */
start = System.nanoTime();
alwaysMissCost = an.computeCost(targetMethod, new AnalysisContextLocal(CacheCostCalculationMethod.ALWAYS_MISS));
stop = System.nanoTime();
reportSpecial("always-miss", alwaysMissCost, start, stop, LpSolveWrapper.getSolverTime());
/* always hit */
LpSolveWrapper.resetSolverTime();
start = System.nanoTime();
alwaysHitCost = an.computeCost(targetMethod, new AnalysisContextLocal(CacheCostCalculationMethod.ALWAYS_HIT));
stop = System.nanoTime();
reportSpecial("always-hit", alwaysHitCost, start, stop, LpSolveWrapper.getSolverTime());
/* simple approx */
wcetTool.setGenerateWCETReport(true);
start = System.nanoTime();
approxCost = an.computeCost(targetMethod, new AnalysisContextLocal(cacheApprox));
stop = System.nanoTime();
reportSpecial("recursive-report", approxCost, start, stop, LpSolveWrapper.getSolverTime());
wcetTool.setGenerateWCETReport(false);
}
use of com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod in project jop by jop-devel.
the class GreedyConfig method getCacheApproximation.
public CacheCostCalculationMethod getCacheApproximation() {
CacheCostCalculationMethod defaultValue = options.getOption(WCA_CACHE_APPROXIMATION);
if (defaultValue != null) {
return defaultValue;
}
AnalysisType analysisType = getCacheAnalysisType();
if (analysisType == AnalysisType.ALWAYS_HIT) {
return CacheCostCalculationMethod.ALWAYS_HIT;
}
if (analysisType == AnalysisType.ALWAYS_MISS) {
return CacheCostCalculationMethod.ALWAYS_MISS;
}
if (analysisType == AnalysisType.ALWAYS_MISS_OR_HIT) {
return CacheCostCalculationMethod.ALL_FIT_SIMPLE;
}
return CacheCostCalculationMethod.ALL_FIT_REGIONS;
}
use of com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod in project jop by jop-devel.
the class LocalAnalysis method recursiveCost.
public WcetCost recursiveCost(RecursiveAnalysis<AnalysisContextLocal, WcetCost> stagedAnalysis, ControlFlowGraph.InvokeNode n, AnalysisContextLocal ctx) {
CacheCostCalculationMethod cacheMode = ctx.getCacheApproxMode();
if (cacheMode.needsInterProcIPET()) {
throw new AssertionError("Error: Cache Mode " + cacheMode + " not supported using local IPET strategy - " + "it needs an interprocedural IPET analysis");
}
WCETTool project = stagedAnalysis.getWCETTool();
MethodInfo invoker = n.getBasicBlock().getMethodInfo();
MethodInfo invoked = n.getImplementingMethod();
WCETProcessorModel proc = project.getWCETProcessorModel();
MethodCacheAnalysis mca = new MethodCacheAnalysis(project);
long cacheCost;
AnalysisContextLocal recCtx = ctx.withCallString(ctx.getCallString().push(n, maxCallstringLength));
WcetCost recCost = stagedAnalysis.computeCost(invoked, recCtx);
long nonLocalExecCost = recCost.getCost() - recCost.getCacheCost();
long nonLocalCacheCost = recCost.getCacheCost();
long invokeReturnCost = mca.getInvokeReturnMissCost(n.getInvokeSite(), ctx.getCallString());
if (proc.getMethodCache().getNumBlocks() == 0 || cacheMode == CacheCostCalculationMethod.ALWAYS_HIT) {
cacheCost = 0;
} else if (project.getCallGraph().isLeafMethod(invoked)) {
cacheCost = invokeReturnCost + nonLocalCacheCost;
} else if (cacheMode == CacheCostCalculationMethod.ALL_FIT_SIMPLE && allFit(project, invoked, recCtx.getCallString())) {
long returnCost = mca.getMissOnceCost(invoker, false);
/* Maybe its better not to apply the all-fit heuristic ... */
long noAllFitCost = recCost.getCost() + invokeReturnCost;
/* Compute cost without method cache */
AnalysisContextLocal ahCtx = recCtx.withCacheApprox(CacheCostCalculationMethod.ALWAYS_HIT);
long alwaysHitCost = stagedAnalysis.computeCost(invoked, ahCtx).getCost();
/* Compute penalty for loading each method exactly once */
long allFitPenalty = mca.getMissOnceCummulativeCacheCost(invoked, assumeMissOnceOnInvoke);
long allFitCacheCost = allFitPenalty + returnCost;
/* Cost All-Fit: recursive + penalty for loading once + return to caller */
long allFitCost = alwaysHitCost + allFitCacheCost;
/* Choose the better approximation */
if (allFitCost <= noAllFitCost) {
cacheCost = allFitCacheCost;
nonLocalExecCost = alwaysHitCost;
} else {
cacheCost = invokeReturnCost + nonLocalCacheCost;
}
} else {
/* ALWAYS MISS or doesn't fit */
cacheCost = invokeReturnCost + nonLocalCacheCost;
}
WcetCost cost = new WcetCost();
cost.addNonLocalCost(nonLocalExecCost);
cost.addCacheCost(cacheCost);
logger.debug("Recursive WCET computation: " + invoked + ". invoke return cache cost: " + invokeReturnCost + ". non-local cache cost: " + nonLocalCacheCost + ". cummulative cache cost: " + cacheCost + " non local execution cost: " + nonLocalExecCost);
return cost;
}
use of com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod 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);
}
}
Aggregations