Search in sources :

Example 1 with RecursiveWcetAnalysis

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

the class MethodBuilder method visitSummaryNode.

public void visitSummaryNode(ControlFlowGraph.SummaryNode n) {
    RecursiveWcetAnalysis<AnalysisContextLocal> an = new RecursiveWcetAnalysis<AnalysisContextLocal>(jTrans.getProject(), new LocalAnalysis());
    WcetCost cost = an.runWCETComputation("SUBGRAPH" + n.getId(), n.getSubGraph(), new AnalysisContextLocal(CacheCostCalculationMethod.ALWAYS_MISS)).getTotalCost();
    SubAutomaton sumLoc = createBasicBlock(n.getId(), cost.getCost());
    this.nodeTemplates.put(n, sumLoc);
}
Also used : WcetCost(com.jopdesign.wcet.analysis.WcetCost) RecursiveWcetAnalysis(com.jopdesign.wcet.analysis.RecursiveWcetAnalysis) LocalAnalysis(com.jopdesign.wcet.analysis.LocalAnalysis) AnalysisContextLocal(com.jopdesign.wcet.analysis.AnalysisContextLocal)

Example 2 with RecursiveWcetAnalysis

use of com.jopdesign.wcet.analysis.RecursiveWcetAnalysis 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);
}
Also used : CacheCostCalculationMethod(com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod) MethodInfo(com.jopdesign.common.MethodInfo) RecursiveWcetAnalysis(com.jopdesign.wcet.analysis.RecursiveWcetAnalysis) LocalAnalysis(com.jopdesign.wcet.analysis.LocalAnalysis) AnalysisContextLocal(com.jopdesign.wcet.analysis.AnalysisContextLocal) TreeAnalysis(com.jopdesign.wcet.analysis.TreeAnalysis)

Example 3 with RecursiveWcetAnalysis

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

the class WCAInvoker method runAnalysis.

///////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////
private Set<MethodInfo> runAnalysis(DirectedGraph<ExecutionContext, ContextEdge> reversed) {
    // Phew. The WCA only runs on acyclic callgraphs, we can therefore assume the
    // reversed graph to be a DAG
    TopologicalOrderIterator<ExecutionContext, ContextEdge> topOrder = new TopologicalOrderIterator<ExecutionContext, ContextEdge>(reversed);
    Set<MethodInfo> changed = new LinkedHashSet<MethodInfo>();
    while (topOrder.hasNext()) {
        ExecutionContext node = topOrder.next();
        // At times like this I really wish Java would have type aliases ..
        RecursiveWcetAnalysis<AnalysisContextLocal>.LocalWCETSolution<AnalysisContextLocal> sol = recursiveAnalysis.computeSolution(node.getMethodInfo(), new AnalysisContextLocal(cacheApproximation, node.getCallString()));
        wcaNodeFlow.put(node, sol.getNodeFlowVirtual());
        // TODO some logging would be nice, keep target-method WCET for comparison of speedup
        if (node.getMethodInfo().equals(wcetTool.getTargetMethod())) {
            lastWCET = sol.getCost().getCost();
            logger.info("WCET: " + lastWCET);
        }
        changed.add(node.getMethodInfo());
    }
    return changed;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExecutionContext(com.jopdesign.common.code.ExecutionContext) TopologicalOrderIterator(org.jgrapht.traverse.TopologicalOrderIterator) MethodInfo(com.jopdesign.common.MethodInfo) AnalysisContextLocal(com.jopdesign.wcet.analysis.AnalysisContextLocal) RecursiveWcetAnalysis(com.jopdesign.wcet.analysis.RecursiveWcetAnalysis) ContextEdge(com.jopdesign.common.code.CallGraph.ContextEdge)

Aggregations

AnalysisContextLocal (com.jopdesign.wcet.analysis.AnalysisContextLocal)3 RecursiveWcetAnalysis (com.jopdesign.wcet.analysis.RecursiveWcetAnalysis)3 MethodInfo (com.jopdesign.common.MethodInfo)2 LocalAnalysis (com.jopdesign.wcet.analysis.LocalAnalysis)2 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)1 ExecutionContext (com.jopdesign.common.code.ExecutionContext)1 TreeAnalysis (com.jopdesign.wcet.analysis.TreeAnalysis)1 WcetCost (com.jopdesign.wcet.analysis.WcetCost)1 CacheCostCalculationMethod (com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod)1 LinkedHashSet (java.util.LinkedHashSet)1 TopologicalOrderIterator (org.jgrapht.traverse.TopologicalOrderIterator)1