Search in sources :

Example 1 with TreeAnalysis

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

Aggregations

MethodInfo (com.jopdesign.common.MethodInfo)1 AnalysisContextLocal (com.jopdesign.wcet.analysis.AnalysisContextLocal)1 LocalAnalysis (com.jopdesign.wcet.analysis.LocalAnalysis)1 RecursiveWcetAnalysis (com.jopdesign.wcet.analysis.RecursiveWcetAnalysis)1 TreeAnalysis (com.jopdesign.wcet.analysis.TreeAnalysis)1 CacheCostCalculationMethod (com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod)1