Search in sources :

Example 6 with Segment

use of com.jopdesign.common.code.Segment in project jop by jop-devel.

the class GlobalAnalysis method computeWCET.

/**
     * Compute WCET using global IPET, and either ALWAYS_MISS or GLOBAL_ALL_FIT
     */
public WcetCost computeWCET(MethodInfo m, AnalysisContextLocal ctx) throws Exception {
    CacheCostCalculationMethod cacheMode = ctx.getCacheApproxMode();
    String key = "global" + "_" + cacheMode;
    Segment segment = Segment.methodSegment(m, ctx.getCallString(), project, project.getAppInfo().getCallstringLength(), project);
    return computeWCET(key, segment, cacheMode);
}
Also used : CacheCostCalculationMethod(com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod) Segment(com.jopdesign.common.code.Segment)

Example 7 with Segment

use of com.jopdesign.common.code.Segment in project jop by jop-devel.

the class WCETAnalysis method exploreCacheAnalysis.

/**
	 * @param mca
	 * @param iter
	 * @throws InvalidFlowFactException
	 */
@SuppressWarnings("unused")
private void exploreCacheAnalysis() throws InvalidFlowFactException {
    // Segment Cache Analysis: Experiments
    MethodCacheAnalysis mca = new MethodCacheAnalysis(wcetTool);
    /* iterate top down the scope graph (currently: the call graph) */
    TopologicalOrderIterator<ExecutionContext, ContextEdge> iter = wcetTool.getCallGraph().reverseTopologicalOrder();
    LpSolveWrapper.resetSolverTime();
    long blocks = 0;
    long start = System.nanoTime();
    while (iter.hasNext()) {
        ExecutionContext scope = iter.next();
        Segment segment = Segment.methodSegment(scope.getMethodInfo(), scope.getCallString(), wcetTool, wcetTool.getCallstringLength(), wcetTool);
        int availBlocks = wcetTool.getWCETProcessorModel().getMethodCache().getNumBlocks();
        long total, distinctApprox = -1, distinct = -1;
        blocks = total = mca.countDistinctBlocksUsed(segment);
        if (total > availBlocks || true) {
            try {
                blocks = distinctApprox = mca.countDistinctBlocksAccessed(segment, false);
                if (blocks > availBlocks && blocks < availBlocks * 2 || true) {
                    blocks = distinct = mca.countDistinctBlocksAccessed(segment, true);
                }
            } catch (LpSolveException e) {
                System.err.println((distinctApprox >= 0 ? "I" : "Relaxed ") + "LP Problem too difficult, giving up: " + e);
            }
        }
        System.out.println(String.format("block-count < %2d [%2d,%2d,%2d] for %-30s @ %s", blocks, total, distinctApprox, distinct, scope.getMethodInfo().getFQMethodName(), scope.getCallString().toStringVerbose(false)));
    }
    long stop = System.nanoTime();
    reportSpecial("block-count", WcetCost.totalCost(blocks), start, stop, LpSolveWrapper.getSolverTime());
    System.out.println("solver-time: " + LpSolveWrapper.getSolverTime());
}
Also used : ExecutionContext(com.jopdesign.common.code.ExecutionContext) MethodCacheAnalysis(com.jopdesign.wcet.analysis.cache.MethodCacheAnalysis) LpSolveException(lpsolve.LpSolveException) ContextEdge(com.jopdesign.common.code.CallGraph.ContextEdge) Segment(com.jopdesign.common.code.Segment)

Example 8 with Segment

use of com.jopdesign.common.code.Segment in project jop by jop-devel.

the class WCETAnalysis method runBlockingTimeAnalysis.

private void runBlockingTimeAnalysis(MethodInfo targetMethod) throws InvalidFlowFactException, LpSolveException, UnsupportedCacheModelException {
    GlobalAnalysis an = new GlobalAnalysis(wcetTool, ipetConfig);
    CacheCostCalculationMethod requestedCacheApprox = IPETConfig.getRequestedCacheApprox(config);
    /* Find all synchronized segments */
    Segment target = Segment.methodSegment(targetMethod, CallString.EMPTY, wcetTool, wcetTool.getCallstringLength(), wcetTool);
    ArrayList<SynchronizedBlockResult> sBlocks = new ArrayList<SynchronizedBlockResult>();
    for (ContextCFG ccfg : target.getCallGraphNodes()) {
        for (CFGNode cfgNode : ccfg.getCfg().vertexSet()) {
            if (cfgNode.getBasicBlock() == null)
                continue;
            for (InstructionHandle ih : cfgNode.getBasicBlock().getInstructions()) {
                if (ih.getInstruction() instanceof MONITORENTER) {
                    /* compute synchronized block WCET */
                    Segment synchronizedSegment = Segment.synchronizedSegment(ccfg, cfgNode, ih, wcetTool, wcetTool.getCallstringLength(), wcetTool);
                    wcet = an.computeWCET(targetMethod.getShortName(), synchronizedSegment, requestedCacheApprox);
                    sBlocks.add(new SynchronizedBlockResult(sBlocks.size(), synchronizedSegment, cfgNode, ih, wcet));
                }
            }
        }
    }
    /* check nested synchronized blocks */
    for (SynchronizedBlockResult sBlock : sBlocks) {
        for (SynchronizedBlockResult otherBlock : sBlocks) {
            if (sBlock == otherBlock)
                continue;
            for (SuperGraphEdge entryEdge : otherBlock.synchronizedSegment.getEntryEdges()) {
                if (sBlock.synchronizedSegment.includesEdge(entryEdge)) {
                    sBlock.nested.add(otherBlock);
                    break;
                }
            }
        }
    }
    System.out.println("=== Synchronized Blocks ===");
    for (SynchronizedBlockResult sBlock : sBlocks) {
        sBlock.dump(System.out);
    }
}
Also used : CacheCostCalculationMethod(com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod) CFGNode(com.jopdesign.common.code.ControlFlowGraph.CFGNode) GlobalAnalysis(com.jopdesign.wcet.analysis.GlobalAnalysis) ContextCFG(com.jopdesign.common.code.SuperGraph.ContextCFG) ArrayList(java.util.ArrayList) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) MONITORENTER(org.apache.bcel.generic.MONITORENTER) Segment(com.jopdesign.common.code.Segment) InstructionHandle(org.apache.bcel.generic.InstructionHandle)

Example 9 with Segment

use of com.jopdesign.common.code.Segment in project jop by jop-devel.

the class WCETAnalysis method runGlobal.

private void runGlobal(MethodInfo targetMethod) throws InvalidFlowFactException, LpSolveException, UnsupportedCacheModelException {
    CacheCostCalculationMethod requestedCacheApprox = IPETConfig.getRequestedCacheApprox(config);
    GlobalAnalysis an = new GlobalAnalysis(wcetTool, ipetConfig);
    Segment target = Segment.methodSegment(targetMethod, CallString.EMPTY, wcetTool, wcetTool.getCallstringLength(), wcetTool);
    /* Run global analysis */
    // for(CacheCostCalculationMethod cacheApprox : CacheCostCalculationMethod.values()) {
    LpSolveWrapper.resetSolverTime();
    long start = System.nanoTime();
    wcet = an.computeWCET(targetMethod.getShortName(), target, requestedCacheApprox);
    long stop = System.nanoTime();
    report(wcet, start, stop, LpSolveWrapper.getSolverTime());
}
Also used : CacheCostCalculationMethod(com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod) GlobalAnalysis(com.jopdesign.wcet.analysis.GlobalAnalysis) Segment(com.jopdesign.common.code.Segment)

Example 10 with Segment

use of com.jopdesign.common.code.Segment in project jop by jop-devel.

the class ObjectCacheAnalysis method findPersistenceSegmentCover.

/** Find a segment cover (i.e., a set of segments covering all execution paths)
	 *  where each segment in the set is persistent (a cache persistence region (CPR))
	 *  
	 *  <h2>The simplest algorithm for a segment S (for acyclic callgraphs)</h2>
	 *   <ul><li/>Check whether S itself is CPR; if so, return S
	 *       <li/>Otherwise, create subsegments S' for each invoked method,
	 *       <li/>and single node segments for each access
	 *   </ul>
	 * @param segment the parent segment
	 * @param checks the strategy to use to determine whether a segment is a persistence region
	 * @param avoidOverlap whether overlapping segments should be avoided
	 * @param alwaysMissNodes additional node set considered to be always miss
	 * @return
	 * @throws LpSolveException 
	 * @throws InvalidFlowFactException 
	 */
protected Collection<Segment> findPersistenceSegmentCover(Segment segment, EnumSet<PersistenceCheck> checks, boolean avoidOverlap, Set<SuperGraphNode> alwaysMissNodes) throws InvalidFlowFactException, LpSolveException {
    List<Segment> cover = new ArrayList<Segment>();
    /* We currently only support entries to one CFG */
    Set<ContextCFG> entryMethods = new HashSet<ContextCFG>();
    for (SuperGraphEdge entryEdge : segment.getEntryEdges()) {
        entryMethods.add(entryEdge.getTarget().getContextCFG());
    }
    ContextCFG entryMethod;
    if (entryMethods.size() != 1) {
        throw new AssertionError("findPersistenceSegmentCover: only supporting segments with unique entry method");
    } else {
        entryMethod = entryMethods.iterator().next();
    }
    if (this.isPersistenceRegion(segment, checks)) {
        cover.add(segment);
    } else {
        /* method sub segments */
        for (Pair<SuperInvokeEdge, SuperReturnEdge> invocation : segment.getCallSitesFrom(entryMethod)) {
            ContextCFG callee = invocation.first().getCallee();
            // System.err.println("Recursively analyzing: "+callee);
            Segment subSegment = Segment.methodSegment(callee, segment.getSuperGraph());
            cover.addAll(findPersistenceSegmentCover(subSegment, checks, avoidOverlap, alwaysMissNodes));
        }
        /* always miss nodes (not covered) */
        alwaysMissNodes.addAll(segment.getNodes(entryMethod));
    }
    return cover;
}
Also used : ContextCFG(com.jopdesign.common.code.SuperGraph.ContextCFG) ArrayList(java.util.ArrayList) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) SuperReturnEdge(com.jopdesign.common.code.SuperGraph.SuperReturnEdge) Segment(com.jopdesign.common.code.Segment) HashSet(java.util.HashSet) SuperInvokeEdge(com.jopdesign.common.code.SuperGraph.SuperInvokeEdge)

Aggregations

Segment (com.jopdesign.common.code.Segment)13 HashSet (java.util.HashSet)8 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)7 SymbolicAddress (com.jopdesign.dfa.analyses.SymbolicAddress)4 ContextCFG (com.jopdesign.common.code.SuperGraph.ContextCFG)3 CacheCostCalculationMethod (com.jopdesign.wcet.ipet.IPETConfig.CacheCostCalculationMethod)3 ArrayList (java.util.ArrayList)3 CallString (com.jopdesign.common.code.CallString)2 SuperGraphNode (com.jopdesign.common.code.SuperGraph.SuperGraphNode)2 SuperInvokeEdge (com.jopdesign.common.code.SuperGraph.SuperInvokeEdge)2 SuperReturnEdge (com.jopdesign.common.code.SuperGraph.SuperReturnEdge)2 GlobalAnalysis (com.jopdesign.wcet.analysis.GlobalAnalysis)2 AccessCostInfo (com.jopdesign.wcet.analysis.cache.ObjectCacheAnalysis.AccessCostInfo)2 HashMap (java.util.HashMap)2 MethodInfo (com.jopdesign.common.MethodInfo)1 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)1 CFGNode (com.jopdesign.common.code.ControlFlowGraph.CFGNode)1 ExecutionContext (com.jopdesign.common.code.ExecutionContext)1 MethodCacheAnalysis (com.jopdesign.wcet.analysis.cache.MethodCacheAnalysis)1 ObjectCacheCost (com.jopdesign.wcet.jop.ObjectCache.ObjectCacheCost)1