public static final float PREFETCH_THRESHOLD_PROB = (float)0.30;
public static final float BRANCH_TRUE_EDGE_PROB = (float)0.5;
public static final float BRANCH_FALSE_EDGE_PROB = (float)0.5;
-
+
public PrefetchAnalysis(State state, CallGraph callgraph, TypeUtil typeutil) {
this.typeutil=typeutil;
this.state=state;
prefetch_hash = new Hashtable<FlatNode, Hashtable<PrefetchPair,Float>>();
pmap_hash = new Hashtable<FlatNode, Hashtable<FlatNode, PairMap>>();
DoPrefetch();
+ prefetch_hash = null;
+ pmap_hash = null;
}
/** This function returns true if a tempdescriptor object is found in the array of descriptors
if(newprefetchset.size() > 0) {
addFlatPrefetchNode(newprefetchset);
}
+ newprefetchset = null;
+ pset1_hash = null;
}
}
prefetch_hash.put(fn, nodehash);
tovisit.remove(fn);
}
+
+ nodehash = null;
+
/* Visit and process nodes */
tovisit = fm.getNodeSet();
while(!tovisit.isEmpty()) {
child_prefetch_set_copy = (Hashtable<PrefetchPair,Float>) prefetch_hash.get(child_node).clone();
}
processFlatCondBranch(curr, child_prefetch_set_copy, i, branch_prefetch_set, parentpmap);
+ parentpmap = null;
}
+ branch_prefetch_set = null;
break;
case FKind.FlatOpNode:
processFlatOpNode(curr, child_prefetch_set_copy, parentpmap);
System.out.println("NO SUCH FLATNODE");
break;
}
+
+ /* Free Heap Memory */
+ child_prefetch_set_copy = null;
+ parentpmap = null;
}
/**This function compares all the prefetch pairs in a Prefetch set hashtable and
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+
+ /* Free Heap Memory */
+ currcopy = null;
+ tocompare = null;
+ pm = null;
}
/** This function processes the prefetch set of a FlatElementNode
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+
+ /* Free heap memory */
+ currcopy = null;
+ tocompare = null;
+ pm = null;
}
/** This function processes the prefetch set of a FlatSetFieldNode
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** This function processes the prefetch set of a FlatSetElementNode
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** This function applies rules and does analysis for a FlatOpNode
}
child_prefetch_set_copy.remove(newpp);
}
+ newdesc = null;
+ newpp = null;
/* For cases like x=y with child prefetch set r[i].x, r[x].p, r[p+x].q*/
} else if(isTempDescFound(copyofchildpp, currfopn.getDest())) {
ArrayList<Descriptor> newdesc = new ArrayList<Descriptor>();
}
child_prefetch_set_copy.remove(newpp);
}
+ newdesc = null;
+ newpp = null;
}else {
continue;
}
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** This function processes a FlatLiteralNode where cases such as
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** This function processes a FlatMethod where the method propagates
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+ tocompare = null;
+ pm = null;
}
/** This Function processes the FlatCalls
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** This function handles the processes the FlatNode of type FlatCondBranch
prefetch_hash.put(curr,branch_prefetch_set);
}
}
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** If FlatNode is not concerned with the prefetch set of its Child then propagate
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** This functions processes for FlatNewNode
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** This functions processes for FlatTagDeclaration
/* Overwrite the new prefetch set to the global hash table */
prefetch_hash.put(curr,tocompare);
}
+
+ /* Free heap memory */
+ tocompare = null;
+ pm = null;
}
/** This function prints the Prefetch pairs of a given flatnode */
}
}
+ /* Free Heap Memory */
+ pset1_init = null;
+ newtovisit = null;
+
+ /* Delete redundant and subset prefetch pairs */
delSubsetPPairs();
/* Start with a top down sorted order of nodes */
ppairs.remove(pp);
}
}
+
+ /* Free heap memory */
+ pplist = null;
+ pplength = null;
+ ppisMod = null;
}
}
newprefetchset.put(fn, s);
}
}
+
+ /* Free heap memory */
+ pset1 = null;
+ pset2 = null;
+ newpset = null;
+ prefetchset = null;
}
private void addFlatPrefetchNode(Hashtable<FlatNode, HashSet<PrefetchPair>> newprefetchset) {
current_node=current_node.getNext(0);
} else throw new Error();
}
-
output.println("}\n\n");
}
int i,j;
if (state.PREFETCH) {
- Iterator it = fpn.hspp.iterator();
output.println("/* prefetch */");
output.println("; /* empty statement to avoid compiler error */");
-
- /* TODO Add support for arrays, Currently handles only field pointers*/
- /* The while loop below removes all prefetch tuples with arrays from the set of prefetches */
- /*
- while(it.hasNext()) {
- PrefetchPair pp = (PrefetchPair) it.next();
- for(i = 0; i < pp.desc.size(); i++) {
- if(pp.getDescAt(i) instanceof IndexDescriptor) {
- fpn.hspp.remove((PrefetchPair) pp);
- it = fpn.hspp.iterator();
- break;
- }
- }
- }
- */
- //it = fpn.hspp.iterator();
+ Iterator it = fpn.hspp.iterator();
String oidlist = new String();
while(it.hasNext()) {
PrefetchPair pp = (PrefetchPair) it.next();
count+", fieldarry_"+count+");");
count++;
}
+
+ /* Free heap memory */
+ fieldoffset = null;
+ endoffset = null;
+ oids = null;
}
public void generateInsideTransCode(FlatMethod fm, LocalityBinding lb,PrintWriter output,PrefetchPair pp,Vector oids, Vector fieldoffset,Vector endoffset, int tuplecount){
- int i;
+ int i,j;
short offsetcount = 0;
Object newdesc = pp.desc.get(0);
generateTemp(fm, pp.base, lb) + "[" + tstlbl + "] : NULL)");
oids.add(oid);
}
+
for(i = 1; i < pp.desc.size(); i++) {
TypeDescriptor newtd;
String newfieldoffset;
if(desc instanceof FieldDescriptor) {
Object prevdesc = pp.getDescAt(i-1);
if(prevdesc instanceof IndexDescriptor){
- if((i-1) == 0)
+ if((i-1) == 0) {
newtd = pp.base.getType();
- //FIXME currently handles one dimensional arrays
- newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType();
+ } else {
+ //FIXME currently handles one dimensional arrays
+ newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType();
+ }
} else {
newtd = ((FieldDescriptor)pp.getDescAt(i-1)).getType();
}
fieldoffset.add(newfieldoffset);
} else {
String tstlbl = new String();
- for(i=0; i<((IndexDescriptor)desc).tddesc.size(); i++) {
- tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(i), lb) + "+";
+ for(j = 0; j < ((IndexDescriptor)desc).tddesc.size(); j++) {
+ tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(j), lb) + "+";
}
tstlbl += ((IndexDescriptor)desc).offset.toString();
newfieldoffset = new String("(short)("+tstlbl+")");
}
public void generateOutsideTransCode(FlatMethod fm, LocalityBinding lb,PrefetchPair pp, Vector oids, Vector fieldoffset, Vector endoffset, int tuplecount) {
- int i;
+ int i,j;
short offsetcount = 0;
String oid = new String(" (unsigned int) (" + generateTemp(fm, pp.base, lb)+ ")");
} else {
Object prevdesc = pp.getDescAt(i-1);
if(prevdesc instanceof IndexDescriptor){
- //FIXME currently handles one dimensional arrays
- newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType();
+ if((i-1) == 0) {
+ newtd = pp.base.getType();
+ } else {
+ //FIXME currently handles one dimensional arrays
+ newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType();
+ }
} else {
newtd = ((FieldDescriptor)pp.getDescAt(i-1)).getType();
}
((FieldDescriptor)desc).getSafeSymbol()+ "))");
} else {
String tstlbl = new String();
- for(i=0; i<((IndexDescriptor)desc).tddesc.size(); i++) {
- tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(i), lb) + "+";
+ for(j = 0; j < ((IndexDescriptor)desc).tddesc.size(); j++) {
+ tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(j), lb) + "+";
}
tstlbl += ((IndexDescriptor)desc).offset.toString();
newfieldoffset = new String("(short)("+tstlbl+")");
}
public void generateLocalTransCode(FlatMethod fm, LocalityBinding lb,PrefetchPair pp,Vector oids, Vector fieldoffset,Vector endoffset, int tuplecount) {
- int i, j;
+ int i, j, k;
short offsetcount = 0;
Vector prefix = new Vector();
tstlbl += fd.getSafeSymbol() + ": NULL";
oid += tstlbl+ " )";
oids.add(oid);
- for(j=i+1; j < pp.desc.size(); j++) {
+ for(j = i+1; j < pp.desc.size(); j++) {
TypeDescriptor newtd;
String newfieldoffset;
Object desc = pp.getDescAt(j);
((FieldDescriptor)desc).getSafeSymbol()+ "))");
} else {
String indexlbl = new String();
- for(i=0; i<((IndexDescriptor)desc).tddesc.size(); i++) {
- indexlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(i), lb) + "+";
+ for(k = 0; k < ((IndexDescriptor)desc).tddesc.size(); k++) {
+ indexlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(k), lb) + "+";
}
indexlbl += ((IndexDescriptor)desc).offset.toString();
newfieldoffset = new String("(short)("+indexlbl+")");
tstlbl += prefix.get(j) + "[";
}
indexstring += "[";
- for(j=0; j<id.tddesc.size(); j++) {
+ for(j = 0; j < id.tddesc.size(); j++) {
tstlbl += generateTemp(fm, id.getTempDescAt(j), lb) + "+";
indexstring += generateTemp(fm,id.getTempDescAt(j), lb) + "+";
}