Search in sources :

Example 11 with TopologicalOrderIterator

use of org.jgrapht.traverse.TopologicalOrderIterator in project jop by jop-devel.

the class WCAInvoker method runAnalysis.

// /////////////////////////////////////////////////////////////////////////////
// Private methods
// /////////////////////////////////////////////////////////////////////////////
private Set<MethodInfo> runAnalysis(DirectedGraph<ExecutionContext, ContextEdge> reversed) {
    // Phew. The WCA only runs on acyclic callgraphs, we can therefore assume the
    // reversed graph to be a DAG
    TopologicalOrderIterator<ExecutionContext, ContextEdge> topOrder = new TopologicalOrderIterator<ExecutionContext, ContextEdge>(reversed);
    Set<MethodInfo> changed = new LinkedHashSet<MethodInfo>();
    while (topOrder.hasNext()) {
        ExecutionContext node = topOrder.next();
        // At times like this I really wish Java would have type aliases ..
        RecursiveWcetAnalysis<AnalysisContextLocal>.LocalWCETSolution sol = recursiveAnalysis.computeSolution(node.getMethodInfo(), new AnalysisContextLocal(cacheApproximation, node.getCallString()));
        wcaNodeFlow.put(node, sol.getNodeFlowVirtual());
        // TODO some logging would be nice, keep target-method WCET for comparison of speedup
        if (node.getMethodInfo().equals(wcetTool.getTargetMethod())) {
            lastWCET = sol.getCost().getCost();
            logger.info("WCET: " + lastWCET);
        }
        changed.add(node.getMethodInfo());
    }
    return changed;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExecutionContext(com.jopdesign.common.code.ExecutionContext) TopologicalOrderIterator(org.jgrapht.traverse.TopologicalOrderIterator) MethodInfo(com.jopdesign.common.MethodInfo) RecursiveWcetAnalysis(com.jopdesign.wcet.analysis.RecursiveWcetAnalysis) AnalysisContextLocal(com.jopdesign.wcet.analysis.AnalysisContextLocal) ContextEdge(com.jopdesign.common.code.CallGraph.ContextEdge)

Aggregations

TopologicalOrderIterator (org.jgrapht.traverse.TopologicalOrderIterator)11 ArrayList (java.util.ArrayList)5 DefaultEdge (org.jgrapht.graph.DefaultEdge)4 DirectedSubgraph (org.jgrapht.graph.DirectedSubgraph)4 MethodInfo (com.jopdesign.common.MethodInfo)2 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)2 ExecutionContext (com.jopdesign.common.code.ExecutionContext)2 IOException (java.io.IOException)2 LinkedHashSet (java.util.LinkedHashSet)2 DefaultDirectedGraph (org.jgrapht.graph.DefaultDirectedGraph)2 TridentContext (storm.trident.planner.processor.TridentContext)2 State (storm.trident.state.State)2 Factory (storm.trident.tuple.TridentTuple.Factory)2 ProjectionFactory (storm.trident.tuple.TridentTupleView.ProjectionFactory)2 RootFactory (storm.trident.tuple.TridentTupleView.RootFactory)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 SourceMapGeneratorV3 (com.google.debugging.sourcemap.SourceMapGeneratorV3)1 InvokeEdge (com.jopdesign.common.code.CallGraph.InvokeEdge)1 MethodNode (com.jopdesign.common.code.CallGraph.MethodNode)1 AppInfoError (com.jopdesign.common.misc.AppInfoError)1