use of com.jopdesign.wcet.WCETTool in project jop by jop-devel.
the class JCopter method main.
public static void main(String[] args) {
// setup some defaults
AppSetup setup = new AppSetup();
setup.setUsageInfo("jcopter", "A WCET driven Java bytecode optimizer.");
setup.setVersionInfo(VERSION);
// We do not load a config file automatically, user has to specify it explicitly to avoid
// unintentional misconfiguration
// setup.setConfigFilename(CONFIG_FILE_NAME);
DFATool dfaTool = new DFATool();
WCETTool wcetTool = new WCETTool();
JCopter jcopter = new JCopter();
wcetTool.setAvailableOptions(false, true, false, false);
setup.registerTool("dfa", dfaTool, true, false);
setup.registerTool("wca", wcetTool);
setup.registerTool("jcopter", jcopter);
setup.addSourceLineOptions(true);
setup.initAndLoad(args, true, true, true);
if (setup.useTool("dfa")) {
wcetTool.setDfaTool(dfaTool);
jcopter.setDfaTool(dfaTool);
}
jcopter.setWcetTool(wcetTool);
wcetTool.getEventHandler().setIgnoreMissingLoopBounds(!jcopter.useWCA());
// run optimizations
jcopter.optimize();
// write results
setup.writeClasses();
}
use of com.jopdesign.wcet.WCETTool 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;
}
Aggregations