Search in sources :

Example 1 with AnalysisContextLocal

use of com.jopdesign.wcet.analysis.AnalysisContextLocal 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 AnalysisContextLocal

use of com.jopdesign.wcet.analysis.AnalysisContextLocal 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 AnalysisContextLocal

use of com.jopdesign.wcet.analysis.AnalysisContextLocal 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)

Example 4 with AnalysisContextLocal

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

the class WCAInvoker method initAnalysis.

public void initAnalysis(boolean useMethodCacheStrategy) {
    IPETConfig ipetConfig = new IPETConfig(wcetTool.getConfig());
    RecursiveStrategy<AnalysisContextLocal, WcetCost> strategy;
    if (useMethodCacheStrategy) {
        strategy = analyses.getMethodCacheAnalysis().createRecursiveStrategy(wcetTool, ipetConfig, cacheApproximation);
    } else {
        if (cacheApproximation.needsInterProcIPET()) {
            strategy = new GlobalAnalysis.GlobalIPETStrategy(ipetConfig);
        } else {
            strategy = new LocalAnalysis(wcetTool, ipetConfig);
        }
    }
    recursiveAnalysis = new RecursiveWcetAnalysis<AnalysisContextLocal>(wcetTool, ipetConfig, strategy);
    // Perform initial analysis
    runAnalysis(wcetTool.getCallGraph().getReversedGraph());
    updateWCEP();
}
Also used : WcetCost(com.jopdesign.wcet.analysis.WcetCost) GlobalAnalysis(com.jopdesign.wcet.analysis.GlobalAnalysis) IPETConfig(com.jopdesign.wcet.ipet.IPETConfig) AnalysisContextLocal(com.jopdesign.wcet.analysis.AnalysisContextLocal) LocalAnalysis(com.jopdesign.wcet.analysis.LocalAnalysis)

Aggregations

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