use of com.jopdesign.wcet.ipet.LinearConstraint in project jop by jop-devel.
the class GlobalAnalysis method getLoopBounds.
/**
* <p>Get all loop bounds for the given segment.</p>
* <p>For each loop bound B for loop H relative to marker M:</p>
* <p>sum(M) * B <= sum(continue-edges-of(H))</p>
*
* @param segment
* @return
* @throws InvalidFlowFactException
*/
private static Iterable<LinearConstraint<SuperGraphEdge>> getLoopBounds(WCETTool wcetTool, Segment segment) throws InvalidFlowFactException {
List<LinearConstraint<SuperGraphEdge>> constraints = new ArrayList<LinearConstraint<SuperGraphEdge>>();
// For all CFG instances
for (ContextCFG ccfg : segment.getCallGraphNodes()) {
ControlFlowGraph cfg = ccfg.getCfg();
// for all loops in the method
LoopColoring<CFGNode, ControlFlowGraph.CFGEdge> loops = cfg.getLoopColoring();
for (CFGNode hol : loops.getHeadOfLoops()) {
LoopBound loopBound = wcetTool.getLoopBound(hol, ccfg.getContext().getCallString());
if (loopBound == null) {
throw new AppInfoError("No loop bound record for head of loop: " + hol + " : " + cfg.buildLoopBoundMap());
}
addLoopConstraints(constraints, segment, ccfg, hol, loops, loopBound);
}
}
return constraints;
}
use of com.jopdesign.wcet.ipet.LinearConstraint in project jop by jop-devel.
the class GlobalAnalysis method addLoopConstraints.
/**
* Add loop contraints
* @param constraints the new constraints are added to this collection
* @param segment
* @param ccfg
* @param headOfLoop
* @param loops
* @param loopBound
* @throws InvalidFlowFactException
*/
private static void addLoopConstraints(List<LinearConstraint<SuperGraphEdge>> constraints, Segment segment, ContextCFG ccfg, CFGNode headOfLoop, LoopColoring<CFGNode, CFGEdge> loops, LoopBound loopBound) throws InvalidFlowFactException {
/* marker loop constraints */
for (Entry<SymbolicMarker, LoopBoundExpr> markerBound : loopBound.getLoopBounds()) {
/* loop constraint */
LinearConstraint<SuperGraphEdge> loopConstraint = new LinearConstraint<SuperGraphEdge>(ConstraintType.GreaterEqual);
/* rhs = sum(continue-edges(loop)) */
Iterable<SuperGraphEdge> continueEdges = segment.liftCFGEdges(ccfg, loops.getBackEdgesTo(headOfLoop));
loopConstraint.addRHS(continueEdges);
/* Multiplicities */
ExecutionContext executionContext = new ExecutionContext(ccfg.getCfg().getMethodInfo(), ccfg.getCallString());
long lhsMultiplicity = markerBound.getValue().upperBound(executionContext);
SymbolicMarker marker = markerBound.getKey();
if (marker.getMarkerType() == SymbolicMarkerType.OUTER_LOOP_MARKER) {
CFGNode outerLoopHol;
outerLoopHol = loops.getLoopAncestor(headOfLoop, marker.getOuterLoopDistance());
if (outerLoopHol == null) {
throw new InvalidFlowFactException("Bad outer loop annotation");
}
Iterable<SuperGraphEdge> exitEdges = segment.liftCFGEdges(ccfg, loops.getExitEdgesOf(outerLoopHol));
for (SuperGraphEdge exitEdge : exitEdges) {
loopConstraint.addLHS(exitEdge, lhsMultiplicity);
}
} else {
assert (marker.getMarkerType() == SymbolicMarkerType.METHOD_MARKER);
throw new AssertionError("ILPModelBuilder: method markers not yet supported, sorry");
}
constraints.add(loopConstraint);
}
}
use of com.jopdesign.wcet.ipet.LinearConstraint in project jop by jop-devel.
the class GlobalAnalysis method getInfeasibleEdgeConstraints.
/**
* For each infeasible edge, assert that the edge has flow 0
* @param wcetTool
* @param segment
* @return
*/
private static Iterable<LinearConstraint<SuperGraphEdge>> getInfeasibleEdgeConstraints(WCETTool wcetTool, Segment segment) {
List<LinearConstraint<SuperGraphEdge>> constraints = new ArrayList<LinearConstraint<SuperGraphEdge>>();
// -- edge = 0
for (ContextCFG ccfg : segment.getCallGraphNodes()) {
for (CFGEdge edge : wcetTool.getInfeasibleEdges(ccfg.getCfg(), ccfg.getCallString())) {
LinearConstraint<SuperGraphEdge> infeasibleConstraint = new LinearConstraint<SuperGraphEdge>(ConstraintType.Equal);
infeasibleConstraint.addLHS(segment.liftCFGEdges(ccfg, Iterators.singleton(edge)));
infeasibleConstraint.addRHS(0);
constraints.add(infeasibleConstraint);
}
}
return constraints;
}
Aggregations