use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.
the class ObjectCacheAnalysis method extractCost.
/**
*
* @param segment the segment analyzed
* @param lpCost the lp objective value
* @param flowMap the lp assignment for variables
* @param accessCostInfo information on object cache cost edges
* @param costModel the object cache cost model
* @param refMissEdges the object cache cost edges for references
* @param blockMissEdges the object cache cost edges for blocks
* @return
*/
private ObjectCache.ObjectCacheCost extractCost(Segment segment, long lpCost, Map<SuperGraphEdge, Long> flowMap, AccessCostInfo accessCostInfo, ObjectCacheCostModel costModel, Set<SuperGraphEdge> refMissEdges, Set<SuperGraphEdge> blockMissEdges) {
long missCount = 0;
/* miss count */
long totalMissCost = 0;
/* has to be equal to (cost - bypass cost) */
long bypassAccesses = 0;
/* bypassed fields accesses */
long fieldAccesses = 0;
/* cached fields accessed */
long totalBypassCost = 0;
for (SuperGraphEdge edge : segment.getEdges()) {
long edgeFreq = flowMap.get(edge);
SuperGraphNode node = edge.getTarget();
/* Compute cost for basic block */
BasicBlock bb = node.getCFGNode().getBasicBlock();
if (bb == null)
continue;
long missCost = accessCostInfo.getMissCost(node) * edgeFreq;
totalMissCost += missCost;
totalBypassCost += accessCostInfo.getBypassCost(node) * edgeFreq;
/* Calculate number of unpredictable always-miss accesses, and record them */
long alwaysMissCost = costModel.getReplaceLineCost() + costModel.getLoadCacheBlockCost();
if (alwaysMissCost > 0) {
missCount += missCost / alwaysMissCost;
}
/* count normal and bypass accesses in the basic block */
for (InstructionHandle ih : bb.getInstructions()) {
String handleType = getHandleType(project, node.getCfg(), ih);
if (handleType == null)
continue;
/* No getfield/handle access */
if (!isFieldCached(project, node.getCfg(), ih, maxCachedFieldIndex)) {
bypassAccesses += edgeFreq;
} else {
fieldAccesses += edgeFreq;
}
}
}
/* For each miss edge, there is an associated cost; moreover
* fill-word & single-field: missCount = sum of miss block variables
* fill-line: missCount = sum of miss object reference variables
*/
long totalRefMisses = 0;
for (SuperGraphEdge refMissEdge : refMissEdges) {
totalRefMisses += flowMap.get(refMissEdge);
}
totalMissCost += costModel.getReplaceLineCost() * totalRefMisses;
long totalBlockMisses = 0;
for (SuperGraphEdge blockMissEdge : blockMissEdges) {
totalBlockMisses += flowMap.get(blockMissEdge);
}
totalMissCost += costModel.getLoadCacheBlockCost() * totalBlockMisses;
missCount += totalBlockMisses;
if (totalMissCost + totalBypassCost != lpCost) {
WCETTool.logger.warn(String.format("Error in calculating missCost in all fit-area (misscount = %d): %d but should be %d (%d - %d)", missCount, totalMissCost, lpCost - totalBypassCost, lpCost, totalBypassCost));
}
ObjectCache.ObjectCacheCost ocCost = new ObjectCache.ObjectCacheCost(missCount, totalMissCost, bypassAccesses, totalBypassCost, fieldAccesses);
return ocCost;
}
use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.
the class WCETNodeLabeller method addNodeLabel.
@Override
protected void addNodeLabel(BasicBlockNode n, StringBuilder nodeInfo) {
BasicBlock codeBlock = n.getBasicBlock();
nodeInfo.append(project.getWCETProcessorModel().basicBlockWCET(new ExecutionContext(codeBlock.getMethodInfo()), codeBlock) + " Cyc, ");
}
use of com.jopdesign.common.code.BasicBlock in project jop by jop-devel.
the class ConstantCache method build.
public ConstantCache build() {
List<MethodInfo> methods = project.getCallGraph().getReachableImplementations(project.getTargetMethod());
for (int i = methods.size() - 1; i >= 0; i--) {
MethodInfo mi = methods.get(i);
ControlFlowGraph cfg = project.getFlowGraph(mi);
for (CFGNode n : cfg.vertexSet()) {
BasicBlock bb = n.getBasicBlock();
if (bb == null)
continue;
for (InstructionHandle ii : bb.getInstructions()) {
extractConstantAddresses(cfg, ii);
}
}
}
return this;
}
Aggregations