use of com.jopdesign.wcet.jop.CacheModel in project jop by jop-devel.
the class GlobalAnalysis method computeWCET.
/**
* Compute WCET for a segment, using global IPET, and cache analysis results
* @throws InvalidFlowFactException
* @throws LpSolveException
* @throws UnsupportedCacheModelException
*/
public WcetCost computeWCET(String key, Segment segment, CacheCostCalculationMethod cacheMode) throws InvalidFlowFactException, LpSolveException, UnsupportedCacheModelException {
/* create an IPET problem for the segment */
String problemId = formatProblemName(key, segment.getEntryCFGs().toString());
IPETSolver<SuperGraphEdge> ipetSolver = buildIpetProblem(project, problemId, segment, ipetConfig);
/* compute cost */
setExecutionCost(segment, ipetSolver);
/* Add constraints for caches */
HashMap<String, Set<SuperGraphEdge>> costMissEdges = new HashMap<String, Set<SuperGraphEdge>>();
for (CacheModel cacheModel : project.getWCETProcessorModel().getCaches()) {
CacheAnalysis cpa = CacheAnalysis.getCacheAnalysisFor(cacheModel, project);
Set<SuperGraphEdge> edges = cpa.addCacheCost(segment, ipetSolver, cacheMode);
costMissEdges.put(cacheModel.toString(), edges);
}
/* Add constraints for object cache */
// ObjectRefAnalysis objectCacheAnalysis = new ObjectRefAnalysis(project, false, 4, 8, 4);
/* Return variables */
Map<SuperGraphEdge, Long> flowMap = new HashMap<SuperGraphEdge, Long>();
/* Solve */
long _start = System.currentTimeMillis();
double relaxedCost = 0;
try {
relaxedCost = ipetSolver.solve(null, false);
} catch (LpSolveException ex) {
WCETTool.logger.error("Solving the relaxed problem failed - bug in lp solving lib?");
}
long _time_rlp = System.currentTimeMillis() - _start;
double ilpCost = ipetSolver.solve(flowMap);
long _time_ilp = System.currentTimeMillis() - _start;
WCETTool.logger.info(String.format("LP (%d ms) %d | %d ILP (%d ms)", _time_rlp, Math.round(relaxedCost), Math.round(ilpCost), _time_ilp));
/* Cost extraction */
WcetCost cost;
/* extract cost and generate a profile in 'profiles' */
cost = exportCostProfile(flowMap, costMissEdges, ipetSolver, problemId);
/* Sanity Check, and Return */
if (Double.isInfinite(ilpCost)) {
throw new AssertionError("[GlobalAnalysis] Unbounded (infinite lp cost)");
}
long objValue = (long) (ilpCost + 0.5);
if (cost.getCost() != objValue) {
throw new AssertionError("[GlobalAnalysis] Inconsistency: lpValue vs. extracted value: " + objValue + " / " + cost.getCost());
}
return cost;
}
Aggregations