Search in sources :

Example 11 with Segment

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

the class ObjectCacheAnalysis method addMissOnceCost.

/**
	 * Add miss once cost: for each method cache persistence segment, add maximum miss cost to the segment entries
	 * @param segment
	 * @param ipetSolver
	 * @param checks
	 * @throws LpSolveException 
	 * @throws InvalidFlowFactException 
	 */
@Override
public Set<SuperGraphEdge> addMissOnceCost(Segment segment, IPETSolver<SuperGraphEdge> ipetSolver, EnumSet<PersistenceCheck> checks) throws InvalidFlowFactException, LpSolveException {
    Set<SuperGraphEdge> missCostEdges = new HashSet<SuperGraphEdge>();
    Set<SuperGraphNode> alwaysMissNodes = new HashSet<SuperGraphNode>();
    Collection<Segment> cover = findPersistenceSegmentCover(segment, EnumSet.allOf(PersistenceCheck.class), false, alwaysMissNodes);
    int tag = 0;
    for (Segment persistenceSegment : cover) {
        tag++;
        /* Compute cost for persistence segment */
        HashSet<SymbolicAddress> usedSetOut = new HashSet<SymbolicAddress>();
        ObjectCacheCost cost = computeCacheCost(persistenceSegment, getUsedRefs(persistenceSegment), objectCache.getCostModel(), usedSetOut);
        WCETTool.logger.info("O$-addMissOnceCost: " + cost.toString());
        F1<SuperGraphEdge, Long> costModel = MiscUtils.const1(cost.getCost());
        Set<SuperGraphEdge> costEdges = addFixedCostEdges(persistenceSegment.getEntryEdges(), ipetSolver, costModel, KEY + "_miss_once", tag);
        missCostEdges.addAll(costEdges);
    }
    AccessCostInfo alwaysMissAccessInfo = extractAccessesAndCosts(alwaysMissNodes, null, objectCache.getCostModel());
    missCostEdges.addAll(addStaticCost(segment, alwaysMissAccessInfo, ipetSolver));
    return missCostEdges;
}
Also used : ObjectCacheCost(com.jopdesign.wcet.jop.ObjectCache.ObjectCacheCost) Segment(com.jopdesign.common.code.Segment) AccessCostInfo(com.jopdesign.wcet.analysis.cache.ObjectCacheAnalysis.AccessCostInfo) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) SuperGraphNode(com.jopdesign.common.code.SuperGraph.SuperGraphNode) SymbolicAddress(com.jopdesign.dfa.analyses.SymbolicAddress) HashSet(java.util.HashSet)

Example 12 with Segment

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

the class ObjectCacheAnalysis method addMissOnceConstraints.

/**
	 * Add miss once constraints for all subsegments in the persistence cover of the given segment
	 * @param segment
	 * @param ipetSolver
	 * @return
	 * @throws LpSolveException 
	 * @throws InvalidFlowFactException 
	 */
@Override
public Set<SuperGraphEdge> addMissOnceConstraints(Segment segment, IPETSolver<SuperGraphEdge> ipetSolver) throws InvalidFlowFactException, LpSolveException {
    Set<SuperGraphEdge> missEdges = new HashSet<SuperGraphEdge>();
    Set<SuperGraphNode> alwaysMissNodes = new HashSet<SuperGraphNode>();
    Collection<Segment> cover = findPersistenceSegmentCover(segment, EnumSet.allOf(PersistenceCheck.class), false, alwaysMissNodes);
    int segmentCounter = 0;
    for (Segment persistenceSegment : cover) {
        /* we need to distinguish edges which are shared between persistence segments */
        String key = KEY + "_" + (++segmentCounter);
        LocalPointsToResult usedRefs = getUsedRefs(persistenceSegment);
        /* Compute worst-case cost */
        HashSet<SymbolicAddress> usedObjectsSet = new HashSet<SymbolicAddress>();
        ObjectCacheIPETModel ocim = addObjectCacheCostEdges(persistenceSegment, usedRefs, objectCache.getCostModel(), ipetSolver);
        missEdges.addAll(ocim.staticCostEdges);
        missEdges.addAll(ocim.refMissEdges);
        missEdges.addAll(ocim.blockMissEdges);
    }
    AccessCostInfo alwaysMissAccessInfo = extractAccessesAndCosts(alwaysMissNodes, null, objectCache.getCostModel());
    missEdges.addAll(addStaticCost(segment, alwaysMissAccessInfo, ipetSolver));
    return missEdges;
}
Also used : CallString(com.jopdesign.common.code.CallString) Segment(com.jopdesign.common.code.Segment) AccessCostInfo(com.jopdesign.wcet.analysis.cache.ObjectCacheAnalysis.AccessCostInfo) SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) SuperGraphNode(com.jopdesign.common.code.SuperGraph.SuperGraphNode) SymbolicAddress(com.jopdesign.dfa.analyses.SymbolicAddress) HashSet(java.util.HashSet)

Example 13 with Segment

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

the class ObjectCacheAnalysis method countDistinctCachedTagsAccessed.

/**
	 * return number of distinct cached tags which might be accessed in the given scope
	 * <p>XXX: use segment instead of scope</p>
	 * @param scope
	 * @return the maximum number of distinct cached tags accessed
	 * @throws InvalidFlowFactException 
	 * @throws LpSolveException 
	 */
public long countDistinctCachedTagsAccessed(ExecutionContext scope) throws InvalidFlowFactException, LpSolveException {
    Long maxCachedTags = this.maxCachedTagsAccessed.get(scope);
    if (maxCachedTags != null)
        return maxCachedTags;
    LocalPointsToResult usedRefs = getUsedRefs(scope);
    /* Create an analysis segment */
    Segment segment = Segment.methodSegment(scope.getMethodInfo(), scope.getCallString(), project, project.getCallstringLength(), project);
    this.saturatedTypes.put(scope, getSaturatedTypes(segment, usedRefs));
    /* Compute worst-case number of objects/fields accessed */
    HashSet<SymbolicAddress> usedObjectsSet = new HashSet<SymbolicAddress>();
    ObjectCacheCostModel costModel;
    if (this.fieldAsTag) {
        costModel = ObjectCacheCostModel.COUNT_FIELD_TAGS;
    } else {
        costModel = ObjectCacheCostModel.COUNT_REF_TAGS;
    }
    maxCachedTags = computeCacheCost(segment, usedRefs, costModel, usedObjectsSet).getCost();
    this.tagSet.put(scope, usedObjectsSet);
    maxCachedTagsAccessed.put(scope, maxCachedTags);
    return maxCachedTags;
}
Also used : SymbolicAddress(com.jopdesign.dfa.analyses.SymbolicAddress) Segment(com.jopdesign.common.code.Segment) HashSet(java.util.HashSet)

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