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);
}
}
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;
}
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;
}
Aggregations