Search in sources :

Example 1 with WCETProcessorModel

use of com.jopdesign.wcet.WCETProcessorModel in project jop by jop-devel.

the class MethodBuilder method visitInvokeNode.

public void visitInvokeNode(ControlFlowGraph.InvokeNode n) {
    ExecutionContext ctx = new ExecutionContext(n.getBasicBlock().getMethodInfo());
    MethodCacheAnalysis mca = new MethodCacheAnalysis(jTrans.getProject());
    WCETProcessorModel proc = jTrans.getProject().getWCETProcessorModel();
    SubAutomaton invokeAuto;
    long staticWCET = proc.basicBlockWCET(ctx, n.getBasicBlock());
    if (jTrans.getCacheSim().isAlwaysMiss()) {
        staticWCET += mca.getInvokeReturnMissCost(n.getInvokeSite(), CallString.EMPTY);
    }
    invokeAuto = invokeBuilder.translateInvoke(this, n, staticWCET);
    this.nodeTemplates.put(n, invokeAuto);
}
Also used : ExecutionContext(com.jopdesign.common.code.ExecutionContext) WCETProcessorModel(com.jopdesign.wcet.WCETProcessorModel) MethodCacheAnalysis(com.jopdesign.wcet.analysis.cache.MethodCacheAnalysis)

Example 2 with WCETProcessorModel

use of com.jopdesign.wcet.WCETProcessorModel in project jop by jop-devel.

the class InlineOptimizer method initialize.

@Override
public void initialize(AnalysisManager analyses, Collection<MethodInfo> roots) {
    if (!preciseCycleEstimate) {
        ExecutionContext dummy = new ExecutionContext(roots.iterator().next());
        WCETProcessorModel pm = analyses.getJCopter().getWCETProcessorModel();
        InstructionList il = new InstructionList();
        // TODO very messy approximation of exec time
        storeCycles = (int) pm.getExecutionTime(dummy, il.append(new ASTORE(10)));
        checkNPCycles = 0;
        checkNPCycles += (int) pm.getExecutionTime(dummy, il.append(new DUP()));
        checkNPCycles += (int) pm.getExecutionTime(dummy, il.append(new IFNONNULL(il.append(new ATHROW()))));
        deltaReturnCycles = (int) pm.getExecutionTime(dummy, il.append(new RETURN()));
        deltaReturnCycles -= (int) pm.getExecutionTime(dummy, il.append(new GOTO(il.getEnd())));
    }
    countInvokeSites = 0;
    countDevirtualized = 0;
}
Also used : RETURN(org.apache.bcel.generic.RETURN) GOTO(org.apache.bcel.generic.GOTO) ExecutionContext(com.jopdesign.common.code.ExecutionContext) ASTORE(org.apache.bcel.generic.ASTORE) WCETProcessorModel(com.jopdesign.wcet.WCETProcessorModel) InstructionList(org.apache.bcel.generic.InstructionList) ATHROW(org.apache.bcel.generic.ATHROW) IFNONNULL(org.apache.bcel.generic.IFNONNULL) DUP(org.apache.bcel.generic.DUP)

Example 3 with WCETProcessorModel

use of com.jopdesign.wcet.WCETProcessorModel 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;
}
Also used : CacheCostCalculationMethod(com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod) WCETProcessorModel(com.jopdesign.wcet.WCETProcessorModel) MethodCacheAnalysis(com.jopdesign.wcet.analysis.cache.MethodCacheAnalysis) MethodInfo(com.jopdesign.common.MethodInfo) WCETTool(com.jopdesign.wcet.WCETTool)

Aggregations

WCETProcessorModel (com.jopdesign.wcet.WCETProcessorModel)3 ExecutionContext (com.jopdesign.common.code.ExecutionContext)2 MethodCacheAnalysis (com.jopdesign.wcet.analysis.cache.MethodCacheAnalysis)2 MethodInfo (com.jopdesign.common.MethodInfo)1 WCETTool (com.jopdesign.wcet.WCETTool)1 CacheCostCalculationMethod (com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod)1 ASTORE (org.apache.bcel.generic.ASTORE)1 ATHROW (org.apache.bcel.generic.ATHROW)1 DUP (org.apache.bcel.generic.DUP)1 GOTO (org.apache.bcel.generic.GOTO)1 IFNONNULL (org.apache.bcel.generic.IFNONNULL)1 InstructionList (org.apache.bcel.generic.InstructionList)1 RETURN (org.apache.bcel.generic.RETURN)1