Search in sources :

Example 1 with IPETSolver

use of com.jopdesign.wcet.ipet.IPETSolver in project jop by jop-devel.

the class RecursiveAnalysis method runLocalComputation.

/**
 * Compute the cost of the given control flow graph, using a local ILP
 *
 * @param name name for the ILP problem
 * @param cfg  the control flow graph
 * @param ctx  the context to use
 * @return the cost for the given CFG
 */
public long runLocalComputation(String name, ControlFlowGraph cfg, Context ctx, CostProvider<CFGNode> costProvider, Map<IPETBuilder.ExecutionEdge, Long> edgeFlowOut) {
    IPETSolver problem = IPETUtils.buildLocalILPModel(project, name, ctx.getCallString(), cfg, costProvider, ipetConfig);
    /* solve ILP */
    /* extract node flow, local cost, cache cost, cummulative cost */
    long maxCost = 0;
    try {
        maxCost = Math.round(problem.solve(edgeFlowOut));
    } catch (Exception e) {
        throw new Error("Failed to solve LP problem: " + e, e);
    }
    return maxCost;
}
Also used : IPETSolver(com.jopdesign.wcet.ipet.IPETSolver)

Example 2 with IPETSolver

use of com.jopdesign.wcet.ipet.IPETSolver in project jop by jop-devel.

the class GlobalAnalysis method buildIpetProblem.

/**
 * Create an interprocedural max-cost max-flow problem for the given segment<br/>
 * Notes:<ul>
 * <li/> super graph edges always have the callstring of the invoking method
 * </ul>
 *
 * @param wcetTool    A reference to the WCETTool
 * @param problemName A unique identifier for the problem (for reporting)
 * @param segment     The segment to build the ILP for
 * @param ipetConfig  Cost of nodes (or {@code null} if no cost is associated with nodes)
 * @return The max-cost maxflow problem
 * @throws InvalidFlowFactException
 */
public static IPETSolver<SuperGraphEdge> buildIpetProblem(WCETTool wcetTool, String problemName, Segment segment, IPETConfig ipetConfig) throws InvalidFlowFactException {
    IPETSolver<SuperGraphEdge> ipetSolver = new IPETSolver<SuperGraphEdge>(problemName, ipetConfig);
    /* DEBUGGING: Render segment */
    // try {
    // segment.exportDOT(wcetTool.getProjectConfig().getOutFile(problemName+".dot"));
    // } catch (IOException e) {
    // e.printStackTrace();
    // }
    /* In- and Outflow */
    ipetSolver.addConstraint(IPETUtils.constantFlow(segment.getEntryEdges(), 1));
    ipetSolver.addConstraint(IPETUtils.constantFlow(segment.getExitEdges(), 1));
    /* Structural flow constraints */
    for (SuperGraphNode node : segment.getNodes()) {
        ipetSolver.addConstraint(IPETUtils.flowPreservation(segment.incomingEdgesOf(node), segment.outgoingEdgesOf(node)));
    }
    /* Supergraph constraints */
    for (Pair<SuperInvokeEdge, SuperReturnEdge> superEdgePair : segment.getCallSites()) {
        Iterable<SuperGraphEdge> es1 = Iterators.<SuperGraphEdge>singleton(superEdgePair.first());
        Iterable<SuperGraphEdge> es2 = Iterators.<SuperGraphEdge>singleton(superEdgePair.second());
        ipetSolver.addConstraint(IPETUtils.flowPreservation(es1, es2));
    }
    /* Program Flow Constraints */
    for (LinearConstraint<SuperGraphEdge> flowFact : getFlowFacts(wcetTool, segment)) {
        ipetSolver.addConstraint(flowFact);
    }
    return ipetSolver;
}
Also used : SuperGraphEdge(com.jopdesign.common.code.SuperGraph.SuperGraphEdge) IPETSolver(com.jopdesign.wcet.ipet.IPETSolver) SuperReturnEdge(com.jopdesign.common.code.SuperGraph.SuperReturnEdge) SuperGraphNode(com.jopdesign.common.code.SuperGraph.SuperGraphNode) SuperInvokeEdge(com.jopdesign.common.code.SuperGraph.SuperInvokeEdge)

Aggregations

IPETSolver (com.jopdesign.wcet.ipet.IPETSolver)2 SuperGraphEdge (com.jopdesign.common.code.SuperGraph.SuperGraphEdge)1 SuperGraphNode (com.jopdesign.common.code.SuperGraph.SuperGraphNode)1 SuperInvokeEdge (com.jopdesign.common.code.SuperGraph.SuperInvokeEdge)1 SuperReturnEdge (com.jopdesign.common.code.SuperGraph.SuperReturnEdge)1