Search in sources :

Example 1 with MethodCache

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

the class MethodCacheAnalysis method updateNodes.

private void updateNodes(SimpleDirectedGraph<ExecutionContext, ContextEdge> closure, Set<ExecutionContext> nodes, boolean reuseResults) {
    for (ExecutionContext node : nodes) {
        if (node.getMethodInfo().isNative())
            continue;
        // We could make this more memory efficient, because in many cases we do not need a
        // separate set for each node, but this would be more complicated to calculate
        Set<MethodInfo> reachable = new LinkedHashSet<MethodInfo>();
        reachable.add(node.getMethodInfo());
        // we only need to add all children to the set, no need to go down the graph
        for (ContextEdge edge : closure.outgoingEdgesOf(node)) {
            ExecutionContext target = edge.getTarget();
            if (target.getMethodInfo().isNative())
                continue;
            if (reuseResults && !nodes.contains(target)) {
                reachable.addAll(reachableMethods.get(target));
            } else {
                reachable.add(target.getMethodInfo());
            }
        }
        reachableMethods.put(node, reachable);
    }
    MethodCache cache = jcopter.getMethodCache();
    // now we can sum up the cache blocks for all nodes in the graph
    for (ExecutionContext node : nodes) {
        if (node.getMethodInfo().isNative())
            continue;
        Set<MethodInfo> reachable = reachableMethods.get(node);
        int blocks = 0;
        for (MethodInfo method : reachable) {
            int size = MiscUtils.bytesToWords(getMethodSize(method));
            blocks += cache.requiredNumberOfBlocks(size);
        }
        cacheBlocks.put(node, blocks);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExecutionContext(com.jopdesign.common.code.ExecutionContext) MethodCache(com.jopdesign.wcet.jop.MethodCache) MethodInfo(com.jopdesign.common.MethodInfo) ContextEdge(com.jopdesign.common.code.CallGraph.ContextEdge)

Example 2 with MethodCache

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

the class MethodCacheAnalysis method checkCache.

/**
 * Check that cache is big enough to hold any method possibly invoked
 * Return largest method
 */
public static MethodInfo checkCache(WCETTool wcetTool, Iterable<MethodInfo> methods) throws AppInfoException {
    MethodCache methodCache = wcetTool.getWCETProcessorModel().getMethodCache();
    int maxWords = 0;
    MethodInfo largestMethod = null;
    // for (ClassInfo ci : project.getAppInfo().getClassInfos()) {
    for (MethodInfo mi : methods) {
        MethodCode code = mi.getCode();
        if (code == null)
            continue;
        // FIXME: using getNumberOfBytes(false) here to be compatible to old behaviour.
        // should probably be getNumberOfBytes()
        int size = code.getNumberOfBytes(false);
        int words = MiscUtils.bytesToWords(size);
        if (!methodCache.fitsInCache(words)) {
            throw new AppInfoException("Cache to small for target method: " + mi.getFQMethodName() + " / " + words + " words");
        }
        if (words >= maxWords) {
            largestMethod = mi;
            maxWords = words;
        }
    }
    return largestMethod;
}
Also used : MethodCache(com.jopdesign.wcet.jop.MethodCache) MethodInfo(com.jopdesign.common.MethodInfo) AppInfoException(com.jopdesign.common.misc.AppInfoException) MethodCode(com.jopdesign.common.MethodCode)

Example 3 with MethodCache

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

the class SystemBuilder method getCacheSimulation.

private CacheSimBuilder getCacheSimulation() {
    MethodCache cache = project.getWCETProcessorModel().getMethodCache();
    UppaalCacheApproximation cacheApprox = config.getCacheApproximation();
    CacheSimBuilder sim;
    if (cache.getName() == CacheImplementation.NO_METHOD_CACHE) {
        sim = new StaticCacheBuilder(false);
    } else if (cacheApprox == UppaalCacheApproximation.ALWAYS_MISS) {
        sim = new StaticCacheBuilder(true);
    } else {
        switch(cache.getName()) {
            case LRU_CACHE:
                sim = new LRUCacheBuilder((BlockCache) cache);
                break;
            case FIFO_CACHE:
                sim = new FIFOCacheBuilder((BlockCache) cache, config.emptyInitialCache);
                break;
            case LRU_VARBLOCK_CACHE:
                sim = new LRUVarBlockCacheBuilder(project, (VarBlockCache) cache, this.methodId.keySet());
                break;
            case FIFO_VARBLOCK_CACHE:
                sim = new FIFOVarBlockCacheBuilder(project, (VarBlockCache) cache, this.methodId.keySet(), config.emptyInitialCache);
                break;
            default:
                throw new AssertionError("Unsupport cache implementation: " + cache.getName());
        }
    }
    return sim;
}
Also used : FIFOCacheBuilder(com.jopdesign.wcet.uppaal.translator.cache.FIFOCacheBuilder) UppaalCacheApproximation(com.jopdesign.wcet.uppaal.UppAalConfig.UppaalCacheApproximation) StaticCacheBuilder(com.jopdesign.wcet.uppaal.translator.cache.StaticCacheBuilder) CacheSimBuilder(com.jopdesign.wcet.uppaal.translator.cache.CacheSimBuilder) MethodCache(com.jopdesign.wcet.jop.MethodCache) LRUCacheBuilder(com.jopdesign.wcet.uppaal.translator.cache.LRUCacheBuilder) LRUVarBlockCacheBuilder(com.jopdesign.wcet.uppaal.translator.cache.LRUVarBlockCacheBuilder) FIFOVarBlockCacheBuilder(com.jopdesign.wcet.uppaal.translator.cache.FIFOVarBlockCacheBuilder)

Aggregations

MethodCache (com.jopdesign.wcet.jop.MethodCache)3 MethodInfo (com.jopdesign.common.MethodInfo)2 MethodCode (com.jopdesign.common.MethodCode)1 ContextEdge (com.jopdesign.common.code.CallGraph.ContextEdge)1 ExecutionContext (com.jopdesign.common.code.ExecutionContext)1 AppInfoException (com.jopdesign.common.misc.AppInfoException)1 UppaalCacheApproximation (com.jopdesign.wcet.uppaal.UppAalConfig.UppaalCacheApproximation)1 CacheSimBuilder (com.jopdesign.wcet.uppaal.translator.cache.CacheSimBuilder)1 FIFOCacheBuilder (com.jopdesign.wcet.uppaal.translator.cache.FIFOCacheBuilder)1 FIFOVarBlockCacheBuilder (com.jopdesign.wcet.uppaal.translator.cache.FIFOVarBlockCacheBuilder)1 LRUCacheBuilder (com.jopdesign.wcet.uppaal.translator.cache.LRUCacheBuilder)1 LRUVarBlockCacheBuilder (com.jopdesign.wcet.uppaal.translator.cache.LRUVarBlockCacheBuilder)1 StaticCacheBuilder (com.jopdesign.wcet.uppaal.translator.cache.StaticCacheBuilder)1 LinkedHashSet (java.util.LinkedHashSet)1