}
private boolean oldHashSet = false;
- private int oldHash = 0;
+ private int oldHash = 0;
public int hashCode() {
int currentHash = toMatch.hashCode() + toAdd.hashCode()*3;
oldHashSet = true;
} else {
if( oldHash != currentHash ) {
- System.out.println( "IF YOU SEE THIS A CANONICAL ChangeTuple CHANGED" );
+ System.out.println("IF YOU SEE THIS A CANONICAL ChangeTuple CHANGED");
Integer x = null;
x.toString();
}
}
private boolean oldHashSet = false;
- private int oldHash = 0;
+ private int oldHash = 0;
public int hashCode() {
int currentHash = changeTuples.hashCode();
oldHashSet = true;
} else {
if( oldHash != currentHash ) {
- System.out.println( "IF YOU SEE THIS A CANONICAL ChangeTupleSet CHANGED" );
+ System.out.println("IF YOU SEE THIS A CANONICAL ChangeTupleSet CHANGED");
Integer x = null;
x.toString();
}
// start by merging all node's parents' graphs
for( int i = 0; i < fn.numPrev(); ++i ) {
- FlatNode pn = fn.getPrev(i);
+ FlatNode pn = fn.getPrev(i);
if( mapFlatNodeToOwnershipGraph.containsKey(pn) ) {
OwnershipGraph ogParent = mapFlatNodeToOwnershipGraph.get(pn);
og.merge(ogParent);
assert mapFlatNodeToOwnershipGraph.containsKey(frn);
OwnershipGraph ogr = mapFlatNodeToOwnershipGraph.get(frn);
completeGraph.merge(ogr);
- }
+ }
return completeGraph;
}
}
}
- og = ogMergeOfAllPossibleCalleeResults;
+ og = ogMergeOfAllPossibleCalleeResults;
break;
case FKind.FlatReturnNode:
int freqCountReport = 1000;
int iterStartCapture = 20000;
int numIterToCapture = 400;
- void debugSnapshot( OwnershipGraph og, FlatNode fn ) {
+ void debugSnapshot(OwnershipGraph og, FlatNode fn) {
++debugCounter;
if( debugCounter > numStartCountReport &&
- debugCounter % freqCountReport == 0 ) {
- System.out.println( " @@@ debug counter = "+debugCounter );
+ debugCounter % freqCountReport == 0 ) {
+ System.out.println(" @@@ debug counter = "+debugCounter);
}
if( debugCounter > iterStartCapture ) {
- System.out.println( " @@@ capturing debug "+(debugCounter-iterStartCapture)+" @@@" );
+ System.out.println(" @@@ capturing debug "+(debugCounter-iterStartCapture)+" @@@");
String graphName = String.format("snap%04d",debugCounter-iterStartCapture);
if( fn != null ) {
graphName = graphName+fn;
}
try {
- og.writeGraph( graphName, true, true, false, false, false );
+ og.writeGraph(graphName, true, true, false, false, false);
} catch( Exception e ) {
- System.out.println( "Error writing debug capture." );
- System.exit( 0 );
+ System.out.println("Error writing debug capture.");
+ System.exit(0);
}
}
if( debugCounter == iterStartCapture + numIterToCapture ) {
- System.out.println( "Stopping analysis after debug captures." );
- System.exit( 0 );
+ System.out.println("Stopping analysis after debug captures.");
+ System.exit(0);
}
}
private AllocationSite getAllocationSiteFromFlatNewPRIVATE(FlatNew fn) {
if( !mapFlatNewToAllocationSite.containsKey(fn) ) {
- AllocationSite as = new AllocationSite(allocationDepth, fn );
+ AllocationSite as = new AllocationSite(allocationDepth, fn);
// the newest nodes are single objects
for( int i = 0; i < allocationDepth; ++i ) {
if( alpha == null ) {
if( isFlagged || isParameter ) {
alpha = new ReachabilitySet(
- new TokenTuple(id,
- !isSingleObject,
- TokenTuple.ARITY_ONE
- ).makeCanonical()
- ).makeCanonical();
+ new TokenTuple(id,
+ !isSingleObject,
+ TokenTuple.ARITY_ONE
+ ).makeCanonical()
+ ).makeCanonical();
} else {
alpha = new ReachabilitySet(
- new TokenTupleSet().makeCanonical()
- ).makeCanonical();
+ new TokenTupleSet().makeCanonical()
+ ).makeCanonical();
}
}
// THIS IS A HACK--NEED TO CHANGE GENERATATION OF BETA-NEW SO THIS DOESN'T
// HAPPEN OTHERWISE PROPAGATION FAILS
- if( edgeY.getBetaNew().equals( new ReachabilitySet().makeCanonical() ) ) {
- edgeY.setBetaNew( new ReachabilitySet( new TokenTupleSet().makeCanonical() ).makeCanonical() );
+ if( edgeY.getBetaNew().equals(new ReachabilitySet().makeCanonical() ) ) {
+ edgeY.setBetaNew(new ReachabilitySet(new TokenTupleSet().makeCanonical() ).makeCanonical() );
}
-
+
/*
- System.out.println( "---------------------------\n" +
- edgeY.getBetaNew() +
- "\nbeing pruned by\n" +
- hrnX.getAlpha() +
- "\nis\n" +
- edgeY.getBetaNew().pruneBy(hrnX.getAlpha())
- );
- */
+ System.out.println( "---------------------------\n" +
+ edgeY.getBetaNew() +
+ "\nbeing pruned by\n" +
+ hrnX.getAlpha() +
+ "\nis\n" +
+ edgeY.getBetaNew().pruneBy(hrnX.getAlpha())
+ );
+ */
// create the actual reference edge hrnX.f -> hrnY
ReferenceEdge edgeNew = new ReferenceEdge(hrnX,
ReachabilitySet beta = new ReachabilitySet(new TokenTuple(newID,
true,
TokenTuple.ARITY_ONE).makeCanonical()
- ).makeCanonical();
+ ).makeCanonical();
// heap regions for parameters are always multiple object (see above)
// and have a reference to themselves, because we can't know the
// after tokens have been aged, reset newest node's reachability
if( hrn0.isFlagged() ) {
hrn0.setAlpha(new ReachabilitySet(
- new TokenTupleSet(
- new TokenTuple(hrn0).makeCanonical()
- ).makeCanonical()
- ).makeCanonical()
+ new TokenTupleSet(
+ new TokenTuple(hrn0).makeCanonical()
+ ).makeCanonical()
+ ).makeCanonical()
);
} else {
hrn0.setAlpha(new ReachabilitySet(
- new TokenTupleSet().makeCanonical()
- ).makeCanonical()
+ new TokenTupleSet().makeCanonical()
+ ).makeCanonical()
);
}
}
TokenTuple bogusTokenPlus = new TokenTuple(bogusID, true, TokenTuple.ARITY_ONEORMORE).makeCanonical();
ReachabilitySet rsIdentity =
new ReachabilitySet(
- new TokenTupleSet(bogusToken).makeCanonical()
- ).makeCanonical();
+ new TokenTupleSet(bogusToken).makeCanonical()
+ ).makeCanonical();
paramIndex2rewriteH.put(bogusIndex, rsIdentity);
paramIndex2rewriteJ.put(bogusIndex, rsIdentity);
if( isStatic ) {
argTemp_i = fc.getArg(paramIndex);
} else {
- if( paramIndex.equals( 0 ) ) {
+ if( paramIndex.equals(0) ) {
argTemp_i = fc.getThis();
} else {
argTemp_i = fc.getArg(paramIndex - 1);
HeapRegionNode hrn = hrnItr.next();
rewriteCallerReachability(index,
- hrn,
- null,
- paramIndex2rewriteH.get(index),
- paramIndex2rewrite_d,
- paramIndex2rewriteD,
- paramIndex2paramToken.get(index),
- paramToken2paramIndex,
- paramTokenPlus2paramIndex,
- false,
- null);
+ hrn,
+ null,
+ paramIndex2rewriteH.get(index),
+ paramIndex2rewrite_d,
+ paramIndex2rewriteD,
+ paramIndex2paramToken.get(index),
+ paramToken2paramIndex,
+ paramTokenPlus2paramIndex,
+ false,
+ null);
nodesWithNewAlpha.add(hrn);
ReferenceEdge edgeReachable = edgeReachableItr.next();
rewriteCallerReachability(index,
- null,
- edgeReachable,
- paramIndex2rewriteJ.get(index),
- paramIndex2rewrite_d,
- paramIndex2rewriteD,
- paramIndex2paramToken.get(index),
- paramToken2paramIndex,
- paramTokenPlus2paramIndex,
- false,
- null);
+ null,
+ edgeReachable,
+ paramIndex2rewriteJ.get(index),
+ paramIndex2rewrite_d,
+ paramIndex2rewriteD,
+ paramIndex2paramToken.get(index),
+ paramToken2paramIndex,
+ paramTokenPlus2paramIndex,
+ false,
+ null);
edgesWithNewBeta.add(edgeReachable);
}
// update upstream edges
Hashtable<ReferenceEdge, ChangeTupleSet> edgeUpstreamPlannedChanges =
- new Hashtable<ReferenceEdge, ChangeTupleSet>();
+ new Hashtable<ReferenceEdge, ChangeTupleSet>();
Iterator<ReferenceEdge> edgeUpstreamItr = edgesUpstream.iterator();
while( edgeUpstreamItr.hasNext() ) {
ReferenceEdge edgeUpstream = edgeUpstreamItr.next();
rewriteCallerReachability(index,
- null,
- edgeUpstream,
- paramIndex2rewriteK.get(index),
- paramIndex2rewrite_d,
- paramIndex2rewriteD,
- paramIndex2paramToken.get(index),
- paramToken2paramIndex,
- paramTokenPlus2paramIndex,
- true,
- edgeUpstreamPlannedChanges);
+ null,
+ edgeUpstream,
+ paramIndex2rewriteK.get(index),
+ paramIndex2rewrite_d,
+ paramIndex2rewriteD,
+ paramIndex2paramToken.get(index),
+ paramToken2paramIndex,
+ paramTokenPlus2paramIndex,
+ true,
+ edgeUpstreamPlannedChanges);
edgesWithNewBeta.add(edgeUpstream);
}
// to a particular parameter, so use a bogus param index
// that pulls a self-rewrite out of H
rewriteCallerReachability(bogusIndex,
- hrnShadowSummary,
- null,
- hrnShadowSummary.getAlpha(),
- paramIndex2rewrite_d,
- paramIndex2rewriteD,
- bogusToken,
- paramToken2paramIndex,
- paramTokenPlus2paramIndex,
- false,
- null);
+ hrnShadowSummary,
+ null,
+ hrnShadowSummary.getAlpha(),
+ paramIndex2rewrite_d,
+ paramIndex2rewriteD,
+ bogusToken,
+ paramToken2paramIndex,
+ paramTokenPlus2paramIndex,
+ false,
+ null);
hrnShadowSummary.applyAlphaNew();
hrnIthShadow.setAlpha(toShadowTokens(ogCallee, hrnIthCallee.getAlpha() ) );
rewriteCallerReachability(bogusIndex,
- hrnIthShadow,
- null,
- hrnIthShadow.getAlpha(),
- paramIndex2rewrite_d,
- paramIndex2rewriteD,
- bogusToken,
- paramToken2paramIndex,
- paramTokenPlus2paramIndex,
- false,
- null);
+ hrnIthShadow,
+ null,
+ hrnIthShadow.getAlpha(),
+ paramIndex2rewrite_d,
+ paramIndex2rewriteD,
+ bogusToken,
+ paramToken2paramIndex,
+ paramTokenPlus2paramIndex,
+ false,
+ null);
hrnIthShadow.applyAlphaNew();
}
edgeCallee.getFieldDesc(),
false,
toShadowTokens(ogCallee,
- edgeCallee.getBeta() )
+ edgeCallee.getBeta() )
);
rewriteCallerReachability(bogusIndex,
- null,
- edgeNewInCallerTemplate,
- edgeNewInCallerTemplate.getBeta(),
- paramIndex2rewrite_d,
- paramIndex2rewriteD,
- bogusToken,
- paramToken2paramIndex,
- paramTokenPlus2paramIndex,
- false,
- null);
+ null,
+ edgeNewInCallerTemplate,
+ edgeNewInCallerTemplate.getBeta(),
+ paramIndex2rewrite_d,
+ paramIndex2rewriteD,
+ bogusToken,
+ paramToken2paramIndex,
+ paramTokenPlus2paramIndex,
+ false,
+ null);
edgeNewInCallerTemplate.applyBetaNew();
edgeCallee.getFieldDesc(),
false,
toShadowTokens(ogCallee,
- edgeCallee.getBeta() )
+ edgeCallee.getBeta() )
);
rewriteCallerReachability(bogusIndex,
- null,
- edgeNewInCallerTemplate,
- edgeNewInCallerTemplate.getBeta(),
- paramIndex2rewrite_d,
- paramIndex2rewriteD,
- bogusToken,
- paramToken2paramIndex,
- paramTokenPlus2paramIndex,
- false,
- null);
+ null,
+ edgeNewInCallerTemplate,
+ edgeNewInCallerTemplate.getBeta(),
+ paramIndex2rewrite_d,
+ paramIndex2rewriteD,
+ bogusToken,
+ paramToken2paramIndex,
+ paramTokenPlus2paramIndex,
+ false,
+ null);
edgeNewInCallerTemplate.applyBetaNew();
private void rewriteCallerReachability(Integer paramIndex,
- HeapRegionNode hrn,
- ReferenceEdge edge,
- ReachabilitySet rules,
- Hashtable<Integer, ReachabilitySet> paramIndex2rewrite_d,
- Hashtable<Integer, ReachabilitySet> paramIndex2rewriteD,
- TokenTuple p_i,
- Hashtable<TokenTuple, Integer> paramToken2paramIndex,
- Hashtable<TokenTuple, Integer> paramTokenPlus2paramIndex,
- boolean makeChangeSet,
- Hashtable<ReferenceEdge, ChangeTupleSet> edgePlannedChanges) {
- assert (hrn == null && edge != null) ||
- (hrn != null && edge == null);
+ HeapRegionNode hrn,
+ ReferenceEdge edge,
+ ReachabilitySet rules,
+ Hashtable<Integer, ReachabilitySet> paramIndex2rewrite_d,
+ Hashtable<Integer, ReachabilitySet> paramIndex2rewriteD,
+ TokenTuple p_i,
+ Hashtable<TokenTuple, Integer> paramToken2paramIndex,
+ Hashtable<TokenTuple, Integer> paramTokenPlus2paramIndex,
+ boolean makeChangeSet,
+ Hashtable<ReferenceEdge, ChangeTupleSet> edgePlannedChanges) {
+ assert(hrn == null && edge != null) ||
+ (hrn != null && edge == null);
assert rules != null;
assert p_i != null;
TokenTupleSet ttsEmpty = new TokenTupleSet().makeCanonical();
// use this to construct a change set if required; the idea is to
- // map every partially rewritten token tuple set to the set of
+ // map every partially rewritten token tuple set to the set of
// caller-context token tuple sets that were used to generate it
Hashtable<TokenTupleSet, HashSet<TokenTupleSet> > rewritten2source =
new Hashtable<TokenTupleSet, HashSet<TokenTupleSet> >();
ReachabilitySet ttCalleeRewrites = null;
boolean callerSourceUsed = false;
- if( ttCallee.equals( p_i ) ) {
+ if( ttCallee.equals(p_i) ) {
// replace the arity-one token of the current parameter with the reachability
// information from the caller edge
ttCalleeRewrites = callerReachabilityCurrent;
callerSourceUsed = true;
-
- } else if( paramToken2paramIndex.containsKey( ttCallee ) ) {
+
+ } else if( paramToken2paramIndex.containsKey(ttCallee) ) {
// use little d
- Integer paramIndex_j = paramToken2paramIndex.get( ttCallee );
+ Integer paramIndex_j = paramToken2paramIndex.get(ttCallee);
assert paramIndex_j != null;
- ttCalleeRewrites = paramIndex2rewrite_d.get( paramIndex_j );
+ ttCalleeRewrites = paramIndex2rewrite_d.get(paramIndex_j);
assert ttCalleeRewrites != null;
- } else if( paramTokenPlus2paramIndex.containsKey( ttCallee ) ) {
+ } else if( paramTokenPlus2paramIndex.containsKey(ttCallee) ) {
// worse, use big D
- Integer paramIndex_j = paramTokenPlus2paramIndex.get( ttCallee );
+ Integer paramIndex_j = paramTokenPlus2paramIndex.get(ttCallee);
assert paramIndex_j != null;
- ttCalleeRewrites = paramIndex2rewriteD.get( paramIndex_j );
+ ttCalleeRewrites = paramIndex2rewriteD.get(paramIndex_j);
assert ttCalleeRewrites != null;
} else {
TokenTupleSet ttsCaller = new TokenTupleSet(ttCallee).makeCanonical();
ttCalleeRewrites = new ReachabilitySet(ttsCaller).makeCanonical();
}
-
- // branch every version of the working rewritten rule with
+
+ // branch every version of the working rewritten rule with
// the possibilities for rewriting the current callee token
ReachabilitySet rewrittenRuleWithTTCallee = new ReachabilitySet().makeCanonical();
while( ttCalleeRewritesItr.hasNext() ) {
TokenTupleSet ttsBranch = ttCalleeRewritesItr.next();
- TokenTupleSet ttsRewrittenNext = ttsRewritten.unionUpArity( ttsBranch );
+ TokenTupleSet ttsRewrittenNext = ttsRewritten.unionUpArity(ttsBranch);
if( makeChangeSet ) {
// in order to keep the list of source token tuple sets
// start with the sets used to make the partially rewritten
// rule up to this point
- HashSet<TokenTupleSet> sourceSets = rewritten2source.get( ttsRewritten );
+ HashSet<TokenTupleSet> sourceSets = rewritten2source.get(ttsRewritten);
assert sourceSets != null;
// make a shallow copy for possible modification
- sourceSets = (HashSet<TokenTupleSet>) sourceSets.clone();
+ sourceSets = (HashSet<TokenTupleSet>)sourceSets.clone();
// if we used something from the caller to rewrite it, remember
if( callerSourceUsed ) {
- sourceSets.add( ttsBranch );
+ sourceSets.add(ttsBranch);
}
// set mapping for the further rewritten rule
- rewritten2source.put( ttsRewrittenNext, sourceSets );
+ rewritten2source.put(ttsRewrittenNext, sourceSets);
}
-
- rewrittenRuleWithTTCallee =
- rewrittenRuleWithTTCallee.union( ttsRewrittenNext );
+
+ rewrittenRuleWithTTCallee =
+ rewrittenRuleWithTTCallee.union(ttsRewrittenNext);
}
}
// the rule has been entirely rewritten into the caller context
// now, so add it to the new reachability information
callerReachabilityNew =
- callerReachabilityNew.union( rewrittenRule );
+ callerReachabilityNew.union(rewrittenRule);
}
if( makeChangeSet ) {
ChangeTupleSet callerChangeSet = new ChangeTupleSet().makeCanonical();
-
+
// each possibility for the final reachability should have a set of
// caller sources mapped to it, use to create the change set
Iterator<TokenTupleSet> callerReachabilityItr = callerReachabilityNew.iterator();
while( callerReachabilityItr.hasNext() ) {
TokenTupleSet ttsRewrittenFinal = callerReachabilityItr.next();
- HashSet<TokenTupleSet> sourceSets = rewritten2source.get( ttsRewrittenFinal );
+ HashSet<TokenTupleSet> sourceSets = rewritten2source.get(ttsRewrittenFinal);
assert sourceSets != null;
Iterator<TokenTupleSet> sourceSetsItr = sourceSets.iterator();
while( sourceSetsItr.hasNext() ) {
- TokenTupleSet ttsSource = sourceSetsItr.next();
+ TokenTupleSet ttsSource = sourceSetsItr.next();
callerChangeSet =
- callerChangeSet.union( new ChangeTuple( ttsSource, ttsRewrittenFinal ) );
+ callerChangeSet.union(new ChangeTuple(ttsSource, ttsRewrittenFinal) );
}
}
ReachabilitySet beta1 = edgeSpecialQ1.getBeta();
assert beta1 != null;
- if( beta1.containsTupleSetWithBoth(p1, p2 ) ) { return true; }
- if( beta1.containsTupleSetWithBoth(pPlus1, p2 ) ) { return true; }
- if( beta1.containsTupleSetWithBoth(pStar1, p2 ) ) { return true; }
- if( beta1.containsTupleSetWithBoth(p1, pPlus2) ) { return true; }
- if( beta1.containsTupleSetWithBoth(pPlus1, pPlus2) ) { return true; }
- if( beta1.containsTupleSetWithBoth(pStar1, pPlus2) ) { return true; }
- if( beta1.containsTupleSetWithBoth(p1, pStar2) ) { return true; }
- if( beta1.containsTupleSetWithBoth(pPlus1, pStar2) ) { return true; }
- if( beta1.containsTupleSetWithBoth(pStar1, pStar2) ) { return true; }
+ if( beta1.containsTupleSetWithBoth(p1, p2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(pPlus1, p2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(pStar1, p2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(p1, pPlus2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(pPlus1, pPlus2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(pStar1, pPlus2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(p1, pStar2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(pPlus1, pStar2) ) {
+ return true;
+ }
+ if( beta1.containsTupleSetWithBoth(pStar1, pStar2) ) {
+ return true;
+ }
return false;
}
TokenTuple.ARITY_ZEROORMORE).makeCanonical();
- if( beta.containsTupleSetWithBoth(p, gs ) ) { return true; }
- if( beta.containsTupleSetWithBoth(pPlus, gs ) ) { return true; }
- if( beta.containsTupleSetWithBoth(pStar, gs ) ) { return true; }
- if( beta.containsTupleSetWithBoth(p, gsPlus) ) { return true; }
- if( beta.containsTupleSetWithBoth(pPlus, gsPlus) ) { return true; }
- if( beta.containsTupleSetWithBoth(pStar, gsPlus) ) { return true; }
- if( beta.containsTupleSetWithBoth(p, gsStar) ) { return true; }
- if( beta.containsTupleSetWithBoth(pPlus, gsStar) ) { return true; }
- if( beta.containsTupleSetWithBoth(pStar, gsStar) ) { return true; }
+ if( beta.containsTupleSetWithBoth(p, gs) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pPlus, gs) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pStar, gs) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(p, gsPlus) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pPlus, gsPlus) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pStar, gsPlus) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(p, gsStar) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pPlus, gsStar) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pStar, gsStar) ) {
+ return true;
+ }
// check for other nodes
for( int i = 0; i < as.getAllocationDepth(); ++i ) {
TokenTuple.ARITY_ONE).makeCanonical();
TokenTuple giStar = new TokenTuple(as.getIthOldest(i),
- false,
- TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+ false,
+ TokenTuple.ARITY_ZEROORMORE).makeCanonical();
- if( beta.containsTupleSetWithBoth(p, gi ) ) { return true; }
- if( beta.containsTupleSetWithBoth(pPlus, gi ) ) { return true; }
- if( beta.containsTupleSetWithBoth(pStar, gi ) ) { return true; }
- if( beta.containsTupleSetWithBoth(p, giStar) ) { return true; }
- if( beta.containsTupleSetWithBoth(pPlus, giStar) ) { return true; }
- if( beta.containsTupleSetWithBoth(pStar, giStar) ) { return true; }
+ if( beta.containsTupleSetWithBoth(p, gi) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pPlus, gi) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pStar, gi) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(p, giStar) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pPlus, giStar) ) {
+ return true;
+ }
+ if( beta.containsTupleSetWithBoth(pStar, giStar) ) {
+ return true;
+ }
}
return false;
assert alphaSum2 != null;
// does either one report reachability from the other tokens?
- if( alphaSum1.containsTuple(gsPlus2) ) { return true; }
- if( alphaSum1.containsTuple(gsStar2) ) { return true; }
- if( alphaSum2.containsTuple(gsPlus1) ) { return true; }
- if( alphaSum2.containsTuple(gsStar1) ) { return true; }
+ if( alphaSum1.containsTuple(gsPlus2) ) {
+ return true;
+ }
+ if( alphaSum1.containsTuple(gsStar2) ) {
+ return true;
+ }
+ if( alphaSum2.containsTuple(gsPlus1) ) {
+ return true;
+ }
+ if( alphaSum2.containsTuple(gsStar1) ) {
+ return true;
+ }
// only check ONE token if they are different sites
if( as1 != as2 ) {
- if( alphaSum1.containsTuple(gs2) ) { return true; }
- if( alphaSum2.containsTuple(gs1) ) { return true; }
+ if( alphaSum1.containsTuple(gs2) ) {
+ return true;
+ }
+ if( alphaSum2.containsTuple(gs1) ) {
+ return true;
+ }
}
TokenTuple.ARITY_ONE).makeCanonical();
TokenTuple giStar1 = new TokenTuple(as1.getIthOldest(i),
- false,
- TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+ false,
+ TokenTuple.ARITY_ZEROORMORE).makeCanonical();
- if( alphaSum2.containsTuple(gi1 ) ) { return true; }
- if( alphaSum2.containsTuple(giStar1) ) { return true; }
- if( alphaI1.containsTuple(gs2 ) ) { return true; }
- if( alphaI1.containsTuple(gsPlus2) ) { return true; }
- if( alphaI1.containsTuple(gsStar2) ) { return true; }
+ if( alphaSum2.containsTuple(gi1) ) {
+ return true;
+ }
+ if( alphaSum2.containsTuple(giStar1) ) {
+ return true;
+ }
+ if( alphaI1.containsTuple(gs2) ) {
+ return true;
+ }
+ if( alphaI1.containsTuple(gsPlus2) ) {
+ return true;
+ }
+ if( alphaI1.containsTuple(gsStar2) ) {
+ return true;
+ }
}
// check sum1 against alloc2 nodes
TokenTuple.ARITY_ONE).makeCanonical();
TokenTuple giStar2 = new TokenTuple(as2.getIthOldest(i),
- false,
- TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+ false,
+ TokenTuple.ARITY_ZEROORMORE).makeCanonical();
- if( alphaSum1.containsTuple(gi2 ) ) { return true; }
- if( alphaSum1.containsTuple(giStar2) ) { return true; }
- if( alphaI2.containsTuple(gs1 ) ) { return true; }
- if( alphaI2.containsTuple(gsPlus1) ) { return true; }
- if( alphaI2.containsTuple(gsStar1) ) { return true; }
+ if( alphaSum1.containsTuple(gi2) ) {
+ return true;
+ }
+ if( alphaSum1.containsTuple(giStar2) ) {
+ return true;
+ }
+ if( alphaI2.containsTuple(gs1) ) {
+ return true;
+ }
+ if( alphaI2.containsTuple(gsPlus1) ) {
+ return true;
+ }
+ if( alphaI2.containsTuple(gsStar1) ) {
+ return true;
+ }
// while we're at it, do an inner loop for alloc2 vs alloc1 nodes
for( int j = 0; j < as1.getAllocationDepth(); ++j ) {
TokenTuple.ARITY_ONE).makeCanonical();
TokenTuple giStar1 = new TokenTuple(as1.getIthOldest(j),
- false,
- TokenTuple.ARITY_ZEROORMORE).makeCanonical();
+ false,
+ TokenTuple.ARITY_ZEROORMORE).makeCanonical();
- if( alphaI2.containsTuple(gi1 ) ) { return true; }
- if( alphaI2.containsTuple(giStar1) ) { return true; }
- if( alphaI1.containsTuple(gi2 ) ) { return true; }
- if( alphaI1.containsTuple(giStar2) ) { return true; }
+ if( alphaI2.containsTuple(gi1) ) {
+ return true;
+ }
+ if( alphaI2.containsTuple(giStar1) ) {
+ return true;
+ }
+ if( alphaI1.containsTuple(gi2) ) {
+ return true;
+ }
+ if( alphaI1.containsTuple(giStar2) ) {
+ return true;
+ }
}
}
boolean labelSelect,
boolean pruneGarbage,
boolean writeReferencers,
- boolean writeParamMappings
+ boolean writeParamMappings
) throws java.io.IOException {
writeGraph(
methodDesc.getSymbol() +
boolean labelSelect,
boolean pruneGarbage,
boolean writeReferencers,
- boolean writeParamMappings
+ boolean writeParamMappings
) throws java.io.IOException {
writeGraph(methodDesc+"COMPLETE",
labelSelect,
pruneGarbage,
writeReferencers,
- writeParamMappings
+ writeParamMappings
);
}
boolean labelSelect,
boolean pruneGarbage,
boolean writeReferencers,
- boolean writeParamMappings
+ boolean writeParamMappings
) throws java.io.IOException {
writeGraph(methodDesc+"COMPLETE"+String.format("%05d", numUpdate),
labelSelect,
pruneGarbage,
writeReferencers,
- writeParamMappings
+ writeParamMappings
);
}
boolean labelSelect,
boolean pruneGarbage,
boolean writeReferencers,
- boolean writeParamMappings
+ boolean writeParamMappings
) throws java.io.IOException {
// remove all non-word characters from the graph name so
Map.Entry me = (Map.Entry)i.next();
HeapRegionNode hrn = (HeapRegionNode) me.getValue();
if( !pruneGarbage ||
- hrn.isFlagged() ||
- hrn.getDescription().startsWith( "param" )
- ) {
-
+ hrn.isFlagged() ||
+ hrn.getDescription().startsWith("param")
+ ) {
+
if( !visited.contains(hrn) ) {
traverseHeapRegionNodes(VISIT_HRN_WRITE_FULL,
- hrn,
- bw,
- null,
- visited,
- writeReferencers);
+ hrn,
+ bw,
+ null,
+ visited,
+ writeReferencers);
}
}
}
-
+
bw.write(" graphTitle[label=\""+graphName+"\",shape=box];\n");
if( writeParamMappings ) {
return possibleReachabilities.iterator();
}
-
+
public int size() {
return possibleReachabilities.size();
}
Iterator itrRelement = r.iterator();
while( itrRelement.hasNext() ) {
TokenTuple ttR = (TokenTuple) itrRelement.next();
- TokenTuple ttO = o.containsToken( ttR.getToken() );
+ TokenTuple ttO = o.containsToken(ttR.getToken() );
if( ttO != null ) {
- theUnion = theUnion.union( new TokenTupleSet( ttR.unionArity(ttO) ) ).makeCanonical();
+ theUnion = theUnion.union(new TokenTupleSet(ttR.unionArity(ttO) ) ).makeCanonical();
} else {
- theUnion = theUnion.union( new TokenTupleSet( ttR ) ).makeCanonical();
+ theUnion = theUnion.union(new TokenTupleSet(ttR) ).makeCanonical();
}
}
Iterator itrOelement = o.iterator();
while( itrOelement.hasNext() ) {
TokenTuple ttO = (TokenTuple) itrOelement.next();
- TokenTuple ttR = theUnion.containsToken( ttO.getToken() );
+ TokenTuple ttR = theUnion.containsToken(ttO.getToken() );
if( ttR == null ) {
- theUnion = theUnion.union( new TokenTupleSet(ttO) ).makeCanonical();
+ theUnion = theUnion.union(new TokenTupleSet(ttO) ).makeCanonical();
}
}
-
+
if( !theUnion.isEmpty() ) {
- ctsOut = ctsOut.union( new ChangeTupleSet( new ChangeTuple(o, theUnion) ) );
+ ctsOut = ctsOut.union(new ChangeTupleSet(new ChangeTuple(o, theUnion) ) );
}
}
}
Iterator<TokenTupleSet> itrThis = this.iterator();
while( itrThis.hasNext() ) {
TokenTupleSet ttsUnit = itrThis.next();
- ttsImprecise = ttsImprecise.unionUpArity( ttsUnit.makeArityZeroOrMore() );
+ ttsImprecise = ttsImprecise.unionUpArity(ttsUnit.makeArityZeroOrMore() );
}
//rsOut = this.union( ttsImprecise );
- rsOut = rsOut.union( ttsImprecise );
+ rsOut = rsOut.union(ttsImprecise);
return rsOut;
}
private boolean oldHashSet = false;
- private int oldHash = 0;
+ private int oldHash = 0;
public int hashCode() {
int currentHash = possibleReachabilities.hashCode();
oldHashSet = true;
} else {
if( oldHash != currentHash ) {
- System.out.println( "IF YOU SEE THIS A CANONICAL ReachabilitySet CHANGED" );
+ System.out.println("IF YOU SEE THIS A CANONICAL ReachabilitySet CHANGED");
Integer x = null;
x.toString();
}
}
- public TokenTuple unionArity( TokenTuple tt ) {
+ public TokenTuple unionArity(TokenTuple tt) {
assert tt != null;
assert token == tt.token;
assert isMultiObject == tt.isMultiObject;
// when two tokens are present (absence of a token is arity=zero and is
// handled outside of this method)
if( arity == ARITY_ZEROORMORE && tt.arity == ARITY_ZEROORMORE ) {
- return new TokenTuple( token, true, ARITY_ZEROORMORE ).makeCanonical();
+ return new TokenTuple(token, true, ARITY_ZEROORMORE).makeCanonical();
} else {
- return new TokenTuple( token, true, ARITY_ONEORMORE ).makeCanonical();
+ return new TokenTuple(token, true, ARITY_ONEORMORE).makeCanonical();
}
} else {
// a single object region's token can only have ZEROORMORE or ONE
if( arity == ARITY_ZEROORMORE && tt.arity == ARITY_ZEROORMORE ) {
- return new TokenTuple( token, false, ARITY_ZEROORMORE ).makeCanonical();
+ return new TokenTuple(token, false, ARITY_ZEROORMORE).makeCanonical();
} else {
- return new TokenTuple( token, false, ARITY_ONE ).makeCanonical();
+ return new TokenTuple(token, false, ARITY_ONE).makeCanonical();
}
}
}
}
private boolean oldHashSet = false;
- private int oldHash = 0;
+ private int oldHash = 0;
public int hashCode() {
int currentHash = token.intValue()*31 + arity;
oldHashSet = true;
} else {
if( oldHash != currentHash ) {
- System.out.println( "IF YOU SEE THIS A CANONICAL TokenTuple CHANGED" );
+ System.out.println("IF YOU SEE THIS A CANONICAL TokenTuple CHANGED");
Integer x = null;
x.toString();
}
Iterator<TokenTuple> ttItr = this.iterator();
while( ttItr.hasNext() ) {
TokenTuple ttThis = ttItr.next();
- TokenTuple ttIn = ttsIn.containsToken( ttThis.getToken() );
+ TokenTuple ttIn = ttsIn.containsToken(ttThis.getToken() );
if( ttIn != null ) {
- ttsOut.tokenTuples.add( ttThis.unionArity( ttIn ) );
+ ttsOut.tokenTuples.add(ttThis.unionArity(ttIn) );
} else {
- ttsOut.tokenTuples.add( ttThis );
+ ttsOut.tokenTuples.add(ttThis);
}
}
ttItr = ttsIn.iterator();
while( ttItr.hasNext() ) {
TokenTuple ttIn = ttItr.next();
- TokenTuple ttThis = ttsOut.containsToken( ttIn.getToken() );
+ TokenTuple ttThis = ttsOut.containsToken(ttIn.getToken() );
if( ttThis == null ) {
- ttsOut.tokenTuples.add( ttIn );
+ ttsOut.tokenTuples.add(ttIn);
}
}
private boolean oldHashSet = false;
- private int oldHash = 0;
+ private int oldHash = 0;
public int hashCode() {
int currentHash = tokenTuples.hashCode();
oldHashSet = true;
} else {
if( oldHash != currentHash ) {
- System.out.println( "IF YOU SEE THIS A CANONICAL TokenTupleSet CHANGED" );
+ System.out.println("IF YOU SEE THIS A CANONICAL TokenTupleSet CHANGED");
Integer x = null;
x.toString();
}
} else if( ttSummary == null && ttOldest != null ) {
ttsOut.tokenTuples.add(new TokenTuple(as.getSummary(),
true,
- ttOldest.getArity()
- ).makeCanonical()
- );
+ ttOldest.getArity()
+ ).makeCanonical()
+ );
} else if( ttSummary != null && ttOldest != null ) {
ttsOut.tokenTuples.add(ttSummary.unionArity(new TokenTuple(as.getSummary(),
- true,
- ttOldest.getArity()
- ).makeCanonical()
- )
- );
+ true,
+ ttOldest.getArity()
+ ).makeCanonical()
+ )
+ );
}
return ttsOut.makeCanonical();
ttsOut.tokenTuples.add(ttSummary);
} else if( ttSummary == null && ttShadowSummary != null ) {
- ttsOut.tokenTuples.add( new TokenTuple(as.getSummary(),
- true,
- ttShadowSummary.getArity()
- ).makeCanonical()
- );
+ ttsOut.tokenTuples.add(new TokenTuple(as.getSummary(),
+ true,
+ ttShadowSummary.getArity()
+ ).makeCanonical()
+ );
} else if( ttSummary != null && ttShadowSummary != null ) {
- ttsOut.tokenTuples.add(ttSummary.unionArity( new TokenTuple(as.getSummary(),
- true,
- ttShadowSummary.getArity()
- ).makeCanonical()
- )
- );
+ ttsOut.tokenTuples.add(ttSummary.unionArity(new TokenTuple(as.getSummary(),
+ true,
+ ttShadowSummary.getArity()
+ ).makeCanonical()
+ )
+ );
}
return ttsOut.makeCanonical();
if( makeChangeSet ) {
assert forChangeSet != null;
-
+
if( forChangeSet.get(this) == null ) {
forChangeSet.put(this, new HashSet<TokenTupleSet>() );
}
-
+
forChangeSet.get(this).add(replaced);
}
}
while( itrThis.hasNext() ) {
TokenTuple tt = itrThis.next();
- ttsOut = ttsOut.union( new TokenTuple( tt.getToken(),
- tt.isMultiObject(),
- TokenTuple.ARITY_ZEROORMORE
- ).makeCanonical()
- );
+ ttsOut = ttsOut.union(new TokenTuple(tt.getToken(),
+ tt.isMultiObject(),
+ TokenTuple.ARITY_ZEROORMORE
+ ).makeCanonical()
+ );
}
return ttsOut.makeCanonical();
}
-
+
public String toString() {
return tokenTuples.toString();
}
try {
if(!copy) {
//merge se into its source ScheduleNode
+ sNode.setCid(((ScheduleNode)se.getSource()).getCid());
((ScheduleNode)se.getSource()).mergeSEdge(se);
scheduleNodes.remove(se.getTarget());
scheduleEdges.removeElement(se);
se.getTargetCNode().addEdge(se);
}
} else {
+ sNode.setCid(ScheduleNode.colorID++);
handleScheduleEdge(se, true);
}
} catch (Exception e) {
int N_sim=1200;
int N_samp=8;
int N_ch=16;
- int N_col=256;
+ int N_col=128;
int i,j;
float r[] = new float[N_sim];
//System.printString("task t1\n");
int datasize = 1000; //should be times of 2
- int nruns = 64 * 16;
+ int nruns = 32 * 16;
int group = 16;
AppDemo ad = new AppDemo(datasize, nruns, group){merge};
task t1(StartupObject s{initialstate}) {
//System.printString("task t1\n");
- int datasize = 32;
+ int datasize = 16;
for(int i = 0; i < datasize; ++i) {
SeriesRunner sr = new SeriesRunner(i){!finish};
}
TILE_PATTERN = 4x1
OBJECT_FILES_COMMON = multicoretask.o multicoreruntime.o Queue.o file.o math.o object.o \
- GenericHashtable.o SimpleHash.o ObjectHash.o socket.o checkpoint.o\
+ GenericHashtable.o SimpleHash.o ObjectHash.o socket.o\
taskdefs.o methods.o mem.o raw_dataCache.o raw_interrupt.o
# this is for a multi-tile test
TILE_PATTERN = 4x2
OBJECT_FILES_COMMON = multicoretask.o multicoreruntime.o Queue.o file.o math.o object.o \
- GenericHashtable.o SimpleHash.o ObjectHash.o socket.o checkpoint.o\
+ GenericHashtable.o SimpleHash.o ObjectHash.o socket.o\
taskdefs.o methods.o mem.o raw_dataCache.o raw_interrupt2.o
# this is for a multi-tile test
TILE_PATTERN = 4x4
OBJECT_FILES_COMMON = multicoretask.o multicoreruntime.o Queue.o file.o math.o object.o \
- GenericHashtable.o SimpleHash.o ObjectHash.o socket.o checkpoint.o\
+ GenericHashtable.o SimpleHash.o ObjectHash.o socket.o\
taskdefs.o methods.o mem.o raw_dataCache.o raw_interrupt4.o
# this is for a multi-tile test
+
+USEBOOTLOADER=no
+
+ifeq ($(USEBOOTLOADER),yes)
+ATTRIBUTES += LARGE_STATIC_DATA
+endif
+
+# We need to define the host OS to get access
+# to the host specific OS defines! - VS
+DEFS += -D$(shell uname -s) -D__raw__
+
TOPDIR=/home/jzhou/starsearch
include $(TOPDIR)/Makefile.include
ATTRIBUTES += HWIC
-TILE_PATTERN = 4x1
+TILES = 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
+
+#TILE_PATTERN = 4x1
OBJECT_FILES_COMMON = multicoretask.o multicoreruntime.o Queue.o file.o math.o object.o \
- GenericHashtable.o SimpleHash.o ObjectHash.o socket.o checkpoint.o\
+ GenericHashtable.o SimpleHash.o ObjectHash.o socket.o \
taskdefs.o methods.o mem.o raw_dataCache.o raw_interrupt.o
-
+
+OBJECT_FILES_00 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_01 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_02 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_03 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_04 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_05 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_06 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_07 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_08 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_09 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_10 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_11 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_12 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_13 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_14 = $(OBJECT_FILES_COMMON)
+OBJECT_FILES_15 = $(OBJECT_FILES_COMMON)
+
# this is for a multi-tile test
include $(COMMONDIR)/Makefile.all
+ifneq ($(USEBOOTLOADER),yes)
+# Load the host interface and host OS simulator into btl
+BTL-ARGS += -host # -imem_size 65536
+endif
+
+BTL-ARGS += -host_stop_time
TILE_PATTERN = 4x2
OBJECT_FILES_COMMON = multicoretask.o multicoreruntime.o Queue.o file.o math.o object.o \
- GenericHashtable.o SimpleHash.o ObjectHash.o socket.o checkpoint.o\
+ GenericHashtable.o SimpleHash.o ObjectHash.o socket.o\
taskdefs.o methods.o mem.o raw_dataCache.o raw_interrupt2.o
# this is for a multi-tile test
TILE_PATTERN = 4x4
OBJECT_FILES_COMMON = multicoretask.o multicoreruntime.o Queue.o file.o math.o object.o \
- GenericHashtable.o SimpleHash.o ObjectHash.o socket.o checkpoint.o\
+ GenericHashtable.o SimpleHash.o ObjectHash.o socket.o\
taskdefs.o methods.o mem.o raw_dataCache.o raw_interrupt4.o
# this is for a multi-tile test
#define ARRAY_SIZE 10100
#define GETSTARTDELAY(start, count) { \
- struct timeval tv; \
- count++; \
- gettimeofday(&tv, NULL); \
- start = tv.tv_sec+(tv.tv_usec/1000000.0); \
+ struct timeval tv; \
+ count++; \
+ gettimeofday(&tv, NULL); \
+ start = tv.tv_sec+(tv.tv_usec/1000000.0); \
}
#define GETSTART(start) { \
- struct timeval tv; \
- gettimeofday(&tv, NULL); \
- start = tv.tv_sec+(tv.tv_usec/1000000.0); \
+ struct timeval tv; \
+ gettimeofday(&tv, NULL); \
+ start = tv.tv_sec+(tv.tv_usec/1000000.0); \
}
#define GETENDDELAY(start, end, time) { \
- struct timeval tv; \
- gettimeofday(&tv, NULL); \
- end = tv.tv_sec+(tv.tv_usec/1000000.0); \
- time = (end-start); \
+ struct timeval tv; \
+ gettimeofday(&tv, NULL); \
+ end = tv.tv_sec+(tv.tv_usec/1000000.0); \
+ time = (end-start); \
}
#endif
/* Process each oid in the machine pile/ group per thread */
for (i = 0; i < fixed->numread + fixed->nummod; i++) {
if (i < fixed->numread) { //Objs only read and not modified
- int incr = sizeof(unsigned int) + sizeof(unsigned short); // Offset that points to next position in the objread array
+ int incr = sizeof(unsigned int) + sizeof(unsigned short); // Offset that points to next position in the objread array
incr *= i;
oid = *((unsigned int *)(objread + incr));
incr += sizeof(unsigned int);
struct QueueItem * prev;
};
-#define isEmpty(x) (x->head==NULL)
+#define isEmpty(x) ((x)->head==NULL)
void * getItem(struct Queue * queue);
void freeQueue(struct Queue * q);
#include <errno.h>
#endif
#ifdef RAW
+#ifdef RAWPROFILE
+#include "stdio.h"
+#include "string.h"
+#endif
#include <raw.h>
#include <raw_compiler_defs.h>
-//#include <libints.h>
#elif defined THREADSIMULATE
// use POSIX message queue
// for each core, its message queue named as
bool getwritelock(void* ptr);
void releasewritelock(void* ptr);
+// profiling mode of RAW version
+#ifdef RAWPROFILE
+//#include "stdio.h"
+//#include "string.h"
+
+#define TASKINFOLENGTH 150
+#define INTERRUPTINFOLENGTH 500
+
+bool stall;
+bool isInterrupt;
+int totalexetime;
+
+typedef struct task_info {
+ char* taskName;
+ int startTime;
+ int endTime;
+} TaskInfo;
+
+typedef struct interrupt_info {
+ int startTime;
+ int endTime;
+} InterruptInfo;
+
+TaskInfo * taskInfoArray[TASKINFOLENGTH];
+int taskInfoIndex;
+bool taskInfoOverflow;
+InterruptInfo * interruptInfoArray[INTERRUPTINFOLENGTH];
+int interruptInfoIndex;
+bool interruptInfoOverflow;
+int profilestatus[NUMCORES]; // records status of each core
+ // 1: running tasks
+// 0: stall
+bool transProfileRequestMsg(int targetcore);
+void outputProfileData();
+#endif
+
#ifdef RAW
+#ifdef RAWPROFILE
+int main(void) {
+#else
void begin() {
+#endif
#else
int main(int argc, char **argv) {
#endif
numsendobjs[i] = 0; // assume all variables in RAW are local variables! MAY BE WRONG!!!
numreceiveobjs[i] = 0;
}
+#ifdef RAWPROFILE
+ for(i = 0; i < NUMCORES; ++i) {
+ profilestatus[i] = 1;
+ }
+#endif
}
self_numsendobjs = 0;
self_numreceiveobjs = 0;
raw_test_pass(0xee03);
#endif
+#ifdef RAWPROFILE
+ stall = false;
+ isInterrupt = true;
+ totalexetime = -1;
+ taskInfoIndex = 0;
+ interruptInfoIndex = 0;
+ taskInfoOverflow = false;
+ interruptInfoOverflow = false;
+#endif
+
#ifdef INTERRUPT
if (corenum < NUMCORES) {
// set up interrupts
if(corenum > NUMCORES - 1) {
failedtasks = NULL;
activetasks = NULL;
+/*#ifdef RAWPROFILE
+ raw_test_pass(0xee01);
+ raw_test_pass_reg(taskInfoIndex);
+ raw_test_pass_reg(taskInfoOverflow);
+ if(!taskInfoOverflow) {
+ TaskInfo* taskInfo = RUNMALLOC(sizeof(struct task_info));
+ taskInfoArray[taskInfoIndex] = taskInfo;
+ taskInfo->taskName = "msg handling";
+ taskInfo->startTime = raw_get_cycle();
+ taskInfo->endTime = -1;
+ }
+ #endif*/
+#ifdef RAWPROFILE
+ isInterrupt = false;
+#endif
while(true) {
receiveObject();
}
tocontinue = false;
#ifdef RAWDEBUG
raw_test_pass(0xee0d);
+#endif
+#ifdef RAWPROFILE
+ {
+ bool isChecking = false;
+ if(!isEmpty(&objqueue)) {
+ if(!taskInfoOverflow) {
+ TaskInfo* taskInfo = RUNMALLOC(sizeof(struct task_info));
+ taskInfoArray[taskInfoIndex] = taskInfo;
+ taskInfo->taskName = "objqueue checking";
+ taskInfo->startTime = raw_get_cycle();
+ taskInfo->endTime = -1;
+ }
+ isChecking = true;
+ }
#endif
while(!isEmpty(&objqueue)) {
void * obj = NULL;
#ifdef INTERRUPT
raw_user_interrupts_off();
#endif
+#ifdef RAWPROFILE
+ isInterrupt = false;
+#endif
#ifdef RAWDEBUG
raw_test_pass(0xeee1);
#endif
// and try to execute active tasks already enqueued first
removeItem(&objqueue, objitem);
addNewItem_I(&objqueue, objInfo);
+#ifdef RAWPROFILE
+ isInterrupt = true;
+#endif
#ifdef INTERRUPT
raw_user_interrupts_on();
#endif
raw_test_pass(0xee0e);
#endif
}
+#ifdef RAWPROFILE
+ if(isChecking && (!taskInfoOverflow)) {
+ taskInfoArray[taskInfoIndex]->endTime = raw_get_cycle();
+ taskInfoIndex++;
+ if(taskInfoIndex == TASKINFOLENGTH) {
+ taskInfoOverflow = true;
+ }
+ }
+ }
+#endif
#ifdef RAWDEBUG
raw_test_pass(0xee0f);
#endif
}
if(allStall) {
// check if the sum of send objs and receive obj are the same
- // yes->terminate
+ // yes->terminate; for profiling mode, yes->send request to all
+ // other cores to pour out profiling data
// no->go on executing
sumsendobj = 0;
for(i = 0; i < NUMCORES; ++i) {
#ifdef RAWDEBUG
raw_test_pass(0xee11);
#endif
+#ifdef RAWPROFILE
+ totalexetime = raw_get_cycle();
+#else
+ raw_test_pass(0xbbbbbbbb);
raw_test_pass(raw_get_cycle());
+#endif
+
+ // profile mode, send msgs to other cores to request pouring
+ // out progiling data
+#ifdef RAWPROFILE
+#ifdef INTERRUPT
+ // reopen gdn_avail interrupts
+ raw_user_interrupts_on();
+#endif
+ for(i = 1; i < NUMCORES; ++i) {
+ transProfileRequestMsg(i);
+ }
+ // pour profiling data on startup core
+ outputProfileData();
+ while(true) {
+#ifdef INTERRUPT
+ raw_user_interrupts_off();
+#endif
+ profilestatus[corenum] = 0;
+ // check the status of all cores
+ allStall = true;
+#ifdef RAWDEBUG
+ raw_test_pass_reg(NUMCORES);
+#endif
+ for(i = 0; i < NUMCORES; ++i) {
+#ifdef RAWDEBUG
+ raw_test_pass(0xe000 + profilestatus[i]);
+#endif
+ if(profilestatus[i] != 0) {
+ allStall = false;
+ break;
+ }
+ }
+ if(!allStall) {
+ int halt = 10000;
+#ifdef INTERRUPT
+ raw_user_interrupts_on();
+#endif
+ while(halt--) {
+ }
+ } else {
+ break;
+ }
+ }
+#endif
+
raw_test_done(1); // All done.
}
}
if(!sendStall) {
#ifdef RAWDEBUG
raw_test_pass(0xee12);
+#endif
+#ifdef RAWPROFILE
+ if(!stall) {
#endif
if(isfirst) {
// wait for some time
sendStall = transStallMsg(STARTUPCORE);
isfirst = true;
}
+#ifdef RAWPROFILE
+ }
+#endif
} else {
isfirst = true;
#ifdef RAWDEBUG
* 3 -- lock grount
* 4 -- lock deny
* 5 -- lock release
+ * 6 -- transfer profile output msg
+ * 7 -- transfer profile ouput finish msg
*
* ObjMsg: 0 + size of msg + obj's address + (task index + param index)+
* StallMsg: 1 + corenum + sendobjs + receiveobjs (size is always 4 * sizeof(int))
* LockMsg: 2 + lock type + obj pointer + request core (size is always 4 * sizeof(int))
* 3/4/5 + lock type + obj pointer (size is always 3 * sizeof(int))
* lock type: 0 -- read; 1 -- write
+ * ProfileMsg: 6 + totalexetime (size is always 2 * sizeof(int))
+ * 7 + corenum (size is always 2 * sizeof(int))
*/
// transfer an object to targetcore
#endif
}
+#ifdef RAWPROFILE
+// send profile request message to targetcore
+// format: 6
+bool transProfileRequestMsg(int targetcore) {
+ unsigned msgHdr;
+ int self_y, self_x, target_y, target_x;
+ // for 32 bit machine, the size is always 4 words
+ //int msgsize = sizeof(int) * 4;
+ int msgsize = 2;
+
+ calCoords(corenum, &self_y, &self_x);
+ calCoords(targetcore, &target_y, &target_x);
+ // Build the message header
+ msgHdr = construct_dyn_hdr(0, msgsize, 0, // msgsize word sent.
+ self_y, self_x,
+ target_y, target_x);
+ // start sending msgs, set msg sending flag
+ isMsgSending = true;
+ gdn_send(msgHdr); // Send the message header to EAST to handle fab(n - 1).
+#ifdef RAWDEBUG
+ raw_test_pass(0xbbbb);
+ raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
+ gdn_send(6);
+#ifdef RAWDEBUG
+ raw_test_pass(6);
+#endif
+ gdn_send(totalexetime);
+#ifdef RAWDEBUG
+ raw_test_pass_reg(totalexetime);
+ raw_test_pass(0xffff);
+#endif
+ // end of sending this msg, set sand msg flag false
+ isMsgSending = false;
+ // check if there are pending msgs
+ while(isMsgHanging) {
+ // get the msg from outmsgdata[]
+ // length + target + msg
+ outmsgleft = outmsgdata[outmsgindex++];
+ targetcore = outmsgdata[outmsgindex++];
+ calCoords(targetcore, &target_y, &target_x);
+ // Build the message header
+ msgHdr = construct_dyn_hdr(0, outmsgleft, 0, // msgsize word sent.
+ self_y, self_x,
+ target_y, target_x);
+ isMsgSending = true;
+ gdn_send(msgHdr);
+#ifdef RAWDEBUG
+ raw_test_pass(0xbbbb);
+ raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
+ while(outmsgleft-- > 0) {
+ gdn_send(outmsgdata[outmsgindex++]);
+#ifdef RAWDEBUG
+ raw_test_pass_reg(outmsgdata[outmsgindex - 1]);
+#endif
+ }
+#ifdef RAWDEBUG
+ raw_test_pass(0xffff);
+#endif
+ isMsgSending = false;
+#ifdef INTERRUPT
+ raw_user_interrupts_off();
+#endif
+ // check if there are still msg hanging
+ if(outmsgindex == outmsglast) {
+ // no more msgs
+ outmsgindex = outmsglast = 0;
+ isMsgHanging = false;
+ }
+#ifdef INTERRUPT
+ raw_user_interrupts_on();
+#endif
+ }
+ return true;
+}
+
+// output the profiling data
+void outputProfileData() {
+ FILE * fp;
+ char fn[50];
+ int self_y, self_x;
+ char c_y, c_x;
+ int i;
+ int totaltasktime = 0;
+ int preprocessingtime = 0;
+ int objqueuecheckingtime = 0;
+ int postprocessingtime = 0;
+ //int interruptiontime = 0;
+ int other = 0;
+ int averagetasktime = 0;
+ int tasknum = 0;
+
+ for(i = 0; i < 50; i++) {
+ fn[i] = 0;
+ }
+
+ calCoords(corenum, &self_y, &self_x);
+ c_y = (char)self_y + '0';
+ c_x = (char)self_x + '0';
+ strcat(fn, "profile_");
+ strcat(fn, &c_x);
+ strcat(fn, "_");
+ strcat(fn, &c_y);
+ strcat(fn, ".rst");
+
+ if((fp = fopen(fn, "w+")) == NULL) {
+ fprintf(stderr, "fopen error\n");
+ return -1;
+ }
+
+ fprintf(fp, "Task Name, Start Time, End Time, Duration\n");
+ // output task related info
+ for(i = 0; i < taskInfoIndex; i++) {
+ TaskInfo* tmpTInfo = taskInfoArray[i];
+ int duration = tmpTInfo->endTime - tmpTInfo->startTime;
+ fprintf(fp, "%s, %d, %d, %d\n", tmpTInfo->taskName, tmpTInfo->startTime, tmpTInfo->endTime, duration);
+ if(strcmp(tmpTInfo->taskName, "tpd checking") == 0) {
+ preprocessingtime += duration;
+ } else if(strcmp(tmpTInfo->taskName, "post task execution") == 0) {
+ postprocessingtime += duration;
+ } else if(strcmp(tmpTInfo->taskName, "objqueue checking") == 0) {
+ objqueuecheckingtime += duration;
+ } else {
+ totaltasktime += duration;
+ averagetasktime += duration;
+ tasknum++;
+ }
+ }
+
+ if(taskInfoOverflow) {
+ fprintf(stderr, "Caution: task info overflow!\n");
+ }
+
+ other = totalexetime - totaltasktime - preprocessingtime - postprocessingtime;
+ averagetasktime /= tasknum;
+
+ fprintf(fp, "\nTotal time: %d\n", totalexetime);
+ fprintf(fp, "Total task execution time: %d (%f%%)\n", totaltasktime, ((double)totaltasktime/(double)totalexetime)*100);
+ fprintf(fp, "Total objqueue checking time: %d (%f%%)\n", objqueuecheckingtime, ((double)objqueuecheckingtime/(double)totalexetime)*100);
+ fprintf(fp, "Total pre-processing time: %d (%f%%)\n", preprocessingtime, ((double)preprocessingtime/(double)totalexetime)*100);
+ fprintf(fp, "Total post-processing time: %d (%f%%)\n", postprocessingtime, ((double)postprocessingtime/(double)totalexetime)*100);
+ fprintf(fp, "Other time: %d (%f%%)\n", other, ((double)other/(double)totalexetime)*100);
+
+ fprintf(fp, "\nAverage task execution time: %d\n", averagetasktime);
+
+ fclose(fp);
+
+ /*
+ int i = 0;
+ int j = 0;
+
+ raw_test_pass(0xdddd);
+ // output task related info
+ for(i= 0; i < taskInfoIndex; i++) {
+ TaskInfo* tmpTInfo = taskInfoArray[i];
+ char* tmpName = tmpTInfo->taskName;
+ int nameLen = strlen(tmpName);
+ raw_test_pass(0xddda);
+ for(j = 0; j < nameLen; j++) {
+ raw_test_pass_reg(tmpName[j]);
+ }
+ raw_test_pass(0xdddb);
+ raw_test_pass_reg(tmpTInfo->startTime);
+ raw_test_pass_reg(tmpTInfo->endTime);
+ raw_test_pass(0xdddc);
+ }
+
+ if(taskInfoOverflow) {
+ raw_test_pass(0xefee);
+ }
+
+ // output interrupt related info
+ for(i = 0; i < interruptInfoIndex; i++) {
+ InterruptInfo* tmpIInfo = interruptInfoArray[i];
+ raw_test_pass(0xddde);
+ raw_test_pass_reg(tmpIInfo->startTime);
+ raw_test_pass_reg(tmpIInfo->endTime);
+ raw_test_pass(0xdddf);
+ }
+
+ if(interruptInfoOverflow) {
+ raw_test_pass(0xefef);
+ }
+
+ raw_test_pass(0xeeee);
+ */
+}
+#endif
+
// receive object transferred from other cores
// or the terminate message from other cores
// NOTICE: following format is for threadsimulate version only
#endif
return -1;
}
+#ifdef RAWPROFILE
+ if(isInterrupt && (!interruptInfoOverflow)) {
+ // raw_test_pass(0xffff);
+ interruptInfoArray[interruptInfoIndex] = RUNMALLOC_I(sizeof(struct interrupt_info));
+ interruptInfoArray[interruptInfoIndex]->startTime = raw_get_cycle();
+ interruptInfoArray[interruptInfoIndex]->endTime = -1;
+ }
+#endif
msg:
#ifdef RAWDEBUG
raw_test_pass(0xcccc);
while((gdn_input_avail() != 0) && (msgdataindex < msglength)) {
msgdata[msgdataindex] = gdn_receive();
if(msgdataindex == 0) {
- if(msgdata[0] > 2) {
+ if(msgdata[0] == 7) {
+ msglength = 2;
+ } else if(msgdata[0] == 6) {
+ msglength = 2;
+ } else if(msgdata[0] > 2) {
msglength = 3;
} else if(msgdata[0] > 0) {
msglength = 4;
break;
}
+#ifdef RAWPROFILE
+ case 6: {
+ // receive an output request msg
+ if(corenum == STARTUPCORE) {
+ // startup core can not receive profile output finish msg
+ // return -1
+ raw_test_done(0xa00a);
+ }
+ {
+ int msgsize = 2;
+ stall = true;
+ totalexetime = data1;
+ outputProfileData();
+ /*if(data1 >= NUMCORES) {
+ raw_test_pass(0xee04);
+ raw_test_pass_reg(taskInfoIndex);
+ raw_test_pass_reg(taskInfoOverflow);
+ if(!taskInfoOverflow) {
+ taskInfoArray[taskInfoIndex]->endTime = raw_get_cycle();
+ taskInfoIndex++;
+ if(taskInfoIndex == TASKINFOLENGTH) {
+ taskInfoOverflow = true;
+ }
+ }
+ }*/
+ // no msg on sending, send it out
+ targetcore = STARTUPCORE;
+ calCoords(corenum, &self_y, &self_x);
+ calCoords(targetcore, &target_y, &target_x);
+ // Build the message header
+ msgHdr = construct_dyn_hdr(0, msgsize, 0, // msgsize word sent.
+ self_y, self_x,
+ target_y, target_x);
+ gdn_send(msgHdr);
+#ifdef RAWDEBUG
+ raw_test_pass(0xbbbb);
+ raw_test_pass(0xb000 + targetcore); // targetcore
+#endif
+ gdn_send(7);
+#ifdef RAWDEBUG
+ raw_test_pass(7);
+#endif
+ gdn_send(corenum);
+#ifdef RAWDEBUG
+ raw_test_pass_reg(corenum);
+ raw_test_pass(0xffff);
+#endif
+ }
+ break;
+ }
+
+ case 7: {
+ // receive a profile output finish msg
+ if(corenum != STARTUPCORE) {
+ // non startup core can not receive profile output finish msg
+ // return -1
+ raw_test_done(0xa00b);
+ }
+ profilestatus[data1] = 0;
+ break;
+ }
+#endif
+
default:
break;
}
if(gdn_input_avail() != 0) {
goto msg;
}
+#ifdef RAWPROFILE
+ if(isInterrupt && (!interruptInfoOverflow)) {
+ interruptInfoArray[interruptInfoIndex]->endTime = raw_get_cycle();
+ interruptInfoIndex++;
+ if(interruptInfoIndex == INTERRUPTINFOLENGTH) {
+ interruptInfoOverflow = true;
+ }
+ }
+#endif
return type;
} else {
// not a whole msg
#ifdef RAWDEBUG
raw_test_pass(0xe889);
+#endif
+#ifdef RAWPROFILE
+ if(isInterrupt && (!interruptInfoOverflow)) {
+ interruptInfoArray[interruptInfoIndex]->endTime = raw_get_cycle();
+ interruptInfoIndex++;
+ if(interruptInfoIndex == INTERRUPTINFOLENGTH) {
+ interruptInfoOverflow = true;
+ }
+ }
#endif
return -2;
}
/* See if there are any active tasks */
if (hashsize(activetasks)>0) {
int i;
+#ifdef RAWPROFILE
+ if(!taskInfoOverflow) {
+ TaskInfo* checkTaskInfo = RUNMALLOC(sizeof(struct task_info));
+ taskInfoArray[taskInfoIndex] = checkTaskInfo;
+ checkTaskInfo->taskName = "tpd checking";
+ checkTaskInfo->startTime = raw_get_cycle();
+ checkTaskInfo->endTime = -1;
+ }
+#endif
currtpd=(struct taskparamdescriptor *) getfirstkey(activetasks);
genfreekey(activetasks, currtpd);
#ifdef INTERRUPT
raw_user_interrupts_off();
+#endif
+#ifdef RAWPROFILE
+ isInterrupt = false;
#endif
while(!lockflag) {
receiveObject();
#ifndef INTERRUPT
reside = false;
#endif
+#ifdef RAWPROFILE
+ isInterrupt = true;
+#endif
#ifdef INTERRUPT
raw_user_interrupts_on();
#endif
while(halt--) {
}
}
+#ifdef RAWPROFILE
+ // fail, set the end of the checkTaskInfo
+ if(!taskInfoOverflow) {
+ taskInfoArray[taskInfoIndex]->endTime = raw_get_cycle();
+ taskInfoIndex++;
+ if(taskInfoIndex == TASKINFOLENGTH) {
+ taskInfoOverflow = true;
+ }
+ }
+#endif
goto newtask;
}
// flush the object
releasewritelock(parameter);
RUNFREE(currtpd->parameterArray);
RUNFREE(currtpd);
+#ifdef RAWPROFILE
+ // fail, set the end of the checkTaskInfo
+ if(!taskInfoOverflow) {
+ taskInfoArray[taskInfoIndex]->endTime = raw_get_cycle();
+ taskInfoIndex++;
+ if(taskInfoIndex == TASKINFOLENGTH) {
+ taskInfoOverflow = true;
+ }
+ }
+#endif
goto newtask;
}
}
}*/
/* Actually call task */
#ifdef PRECISE_GC
- ((int *)taskpointerarray)[0]=currtpd->numParameters;
+ ((int *)taskpointerarray)[0]=currtpd->numParameters;
taskpointerarray[1]=NULL;
#endif
execute:
+#ifdef RAWPROFILE
+ {
+ // check finish, set the end of the checkTaskInfo
+ if(!taskInfoOverflow) {
+ taskInfoArray[taskInfoIndex]->endTime = raw_get_cycle();
+ taskInfoIndex++;
+ if(taskInfoIndex == TASKINFOLENGTH) {
+ taskInfoOverflow = true;
+ }
+ }
+ }
+ if(!taskInfoOverflow) {
+ // new a taskInfo for the task execution
+ TaskInfo* taskInfo = RUNMALLOC(sizeof(struct task_info));
+ taskInfoArray[taskInfoIndex] = taskInfo;
+ taskInfo->taskName = currtpd->task->name;
+ taskInfo->startTime = raw_get_cycle();
+ taskInfo->endTime = -1;
+ }
+#endif
+
if(debugtask) {
#ifndef RAW
printf("ENTER %s count=%d\n",currtpd->task->name, (instaccum-instructioncount));
} else {
((void(*) (void **))currtpd->task->taskptr)(taskpointerarray);
}
+#ifdef RAWPROFILE
+ // task finish, set the end of the checkTaskInfo
+ if(!taskInfoOverflow) {
+ taskInfoArray[taskInfoIndex]->endTime = raw_get_cycle();
+ taskInfoIndex++;
+ if(taskInfoIndex == TASKINFOLENGTH) {
+ taskInfoOverflow = true;
+ }
+ }
+ // new a PostTaskInfo for the post-task execution
+ if(!taskInfoOverflow) {
+ TaskInfo* postTaskInfo = RUNMALLOC(sizeof(struct task_info));
+ taskInfoArray[taskInfoIndex] = postTaskInfo;
+ postTaskInfo->taskName = "post task execution";
+ postTaskInfo->startTime = raw_get_cycle();
+ postTaskInfo->endTime = -1;
+ }
+#endif
#ifdef RAWDEBUG
raw_test_pass(0xe998);
raw_test_pass_reg(lock);
- #endif
+#endif
if(lock) {
#ifdef RAW
#endif
}
+#ifdef RAWPROFILE
+ // post task execution finish, set the end of the postTaskInfo
+ if(!taskInfoOverflow) {
+ taskInfoArray[taskInfoIndex]->endTime = raw_get_cycle();
+ taskInfoIndex++;
+ if(taskInfoIndex == TASKINFOLENGTH) {
+ taskInfoOverflow = true;
+ }
+ }
+#endif
+
#if 0
#ifndef RAW
freeRuntimeHash(forward);
freeRuntimeHash(reverse);
+ freemalloc();
#endif
#endif
- freemalloc();
// Free up task parameter descriptor
RUNFREE(currtpd->parameterArray);
RUNFREE(currtpd);
}
/* Actually call task */
#ifdef PRECISE_GC
- ((int *)taskpointerarray)[0]=currtpd->numParameters;
+ ((int *)taskpointerarray)[0]=currtpd->numParameters;
taskpointerarray[1]=NULL;
#endif
#ifdef OPTIONAL
RAWCONFIG=''
RAWDEBUGFLAG=false
RAWPATHFLAG=false
+RAWPROFILEFLAG=false
INTERRUPTFLAG=false
THREADSIMULATEFLAG=false;
USEDMALLOC=false
EXTRAOPTIONS="$EXTRAOPTIONS -DMAC"
elif [[ $1 = '-profile' ]]
then
+RAWPROFILEFLAG=true
EXTRAOPTIONS="$EXTRAOPTIONS -pg"
elif [[ $1 = '-taskstate' ]]
then
RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWDEBUG"
fi
+if $RAWPROFILEFLAG
+then # profile version
+RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWPROFILE"
+fi
+
if $INTERRUPTFLAG
then #INTERRUPT version
MAKEFILE="$MAKEFILE.i"