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;
}
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;
}
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;
}
Aggregations