From 0f428371ab960b69d4570aaf811c5af4b94e5669 Mon Sep 17 00:00:00 2001 From: jzhou Date: Fri, 3 Oct 2008 19:16:15 +0000 Subject: [PATCH] add profile codes for multicore version --- .../OwnershipAnalysis/ChangeTuple.java | 4 +- .../OwnershipAnalysis/ChangeTupleSet.java | 4 +- .../OwnershipAnalysis/OwnershipAnalysis.java | 26 +- .../OwnershipAnalysis/OwnershipGraph.java | 498 +++++++++------- .../OwnershipAnalysis/ReachabilitySet.java | 24 +- .../OwnershipAnalysis/TokenTuple.java | 14 +- .../OwnershipAnalysis/TokenTupleSet.java | 68 +-- .../Analysis/Scheduling/ScheduleAnalysis.java | 2 + .../Scheduling/FilterBank/FilterBank.java | 2 +- .../JGFMonteCarlo/JGFMonteCarloBench.java | 2 +- .../Scheduling/JGFSeries/JGFSeriesBench.java | 2 +- Robust/src/Makefile.raw.1 | 2 +- Robust/src/Makefile.raw.2 | 2 +- Robust/src/Makefile.raw.4 | 2 +- Robust/src/Makefile.raw.i.1 | 42 +- Robust/src/Makefile.raw.i.2 | 2 +- Robust/src/Makefile.raw.i.4 | 2 +- Robust/src/Runtime/DSTM/interface/dsmdebug.h | 22 +- .../src/Runtime/DSTM/interface/dstmserver.c | 2 +- Robust/src/Runtime/Queue.h | 2 +- Robust/src/Runtime/multicoretask.c | 544 +++++++++++++++++- Robust/src/Runtime/task.c | 2 +- Robust/src/buildscript | 7 + 23 files changed, 971 insertions(+), 306 deletions(-) diff --git a/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java b/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java index c94a0cc9..3b107fa0 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ChangeTuple.java @@ -51,7 +51,7 @@ public class ChangeTuple extends Canonical } private boolean oldHashSet = false; - private int oldHash = 0; + private int oldHash = 0; public int hashCode() { int currentHash = toMatch.hashCode() + toAdd.hashCode()*3; @@ -60,7 +60,7 @@ public class ChangeTuple extends Canonical 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(); } diff --git a/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java b/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java index 4f2fe4a8..15b28751 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ChangeTupleSet.java @@ -75,7 +75,7 @@ public class ChangeTupleSet extends Canonical { } private boolean oldHashSet = false; - private int oldHash = 0; + private int oldHash = 0; public int hashCode() { int currentHash = changeTuples.hashCode(); @@ -84,7 +84,7 @@ public class ChangeTupleSet extends Canonical { 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(); } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index b0dcfb47..7de280a5 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -405,7 +405,7 @@ public class OwnershipAnalysis { // 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); @@ -450,7 +450,7 @@ public class OwnershipAnalysis { assert mapFlatNodeToOwnershipGraph.containsKey(frn); OwnershipGraph ogr = mapFlatNodeToOwnershipGraph.get(frn); completeGraph.merge(ogr); - } + } return completeGraph; } @@ -592,7 +592,7 @@ public class OwnershipAnalysis { } } - og = ogMergeOfAllPossibleCalleeResults; + og = ogMergeOfAllPossibleCalleeResults; break; case FKind.FlatReturnNode: @@ -616,28 +616,28 @@ public class OwnershipAnalysis { 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); } } @@ -685,7 +685,7 @@ public class OwnershipAnalysis { 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 ) { diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 10376cfb..735b86a4 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -85,15 +85,15 @@ public class OwnershipGraph { 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(); } } @@ -456,21 +456,21 @@ public class OwnershipGraph { // 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, @@ -561,7 +561,7 @@ public class OwnershipGraph { 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 @@ -716,15 +716,15 @@ public class OwnershipGraph { // 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() ); } } @@ -956,8 +956,8 @@ public class OwnershipGraph { 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); @@ -1016,7 +1016,7 @@ public class OwnershipGraph { 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); @@ -1096,16 +1096,16 @@ public class OwnershipGraph { 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); @@ -1145,39 +1145,39 @@ public class OwnershipGraph { 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 edgeUpstreamPlannedChanges = - new Hashtable(); + new Hashtable(); Iterator 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); } @@ -1227,16 +1227,16 @@ public class OwnershipGraph { // 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(); @@ -1259,16 +1259,16 @@ public class OwnershipGraph { 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(); } @@ -1309,19 +1309,19 @@ public class OwnershipGraph { 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(); @@ -1396,19 +1396,19 @@ public class OwnershipGraph { 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(); @@ -1602,18 +1602,18 @@ public class OwnershipGraph { private void rewriteCallerReachability(Integer paramIndex, - HeapRegionNode hrn, - ReferenceEdge edge, - ReachabilitySet rules, - Hashtable paramIndex2rewrite_d, - Hashtable paramIndex2rewriteD, - TokenTuple p_i, - Hashtable paramToken2paramIndex, - Hashtable paramTokenPlus2paramIndex, - boolean makeChangeSet, - Hashtable edgePlannedChanges) { - assert (hrn == null && edge != null) || - (hrn != null && edge == null); + HeapRegionNode hrn, + ReferenceEdge edge, + ReachabilitySet rules, + Hashtable paramIndex2rewrite_d, + Hashtable paramIndex2rewriteD, + TokenTuple p_i, + Hashtable paramToken2paramIndex, + Hashtable paramTokenPlus2paramIndex, + boolean makeChangeSet, + Hashtable edgePlannedChanges) { + assert(hrn == null && edge != null) || + (hrn != null && edge == null); assert rules != null; assert p_i != null; @@ -1631,7 +1631,7 @@ public class OwnershipGraph { 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 > rewritten2source = new Hashtable >(); @@ -1652,24 +1652,24 @@ public class OwnershipGraph { 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 { @@ -1677,8 +1677,8 @@ public class OwnershipGraph { 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(); @@ -1690,29 +1690,29 @@ public class OwnershipGraph { 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 sourceSets = rewritten2source.get( ttsRewritten ); + HashSet sourceSets = rewritten2source.get(ttsRewritten); assert sourceSets != null; // make a shallow copy for possible modification - sourceSets = (HashSet) sourceSets.clone(); + sourceSets = (HashSet)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); } } @@ -1724,26 +1724,26 @@ public class OwnershipGraph { // 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 callerReachabilityItr = callerReachabilityNew.iterator(); while( callerReachabilityItr.hasNext() ) { TokenTupleSet ttsRewrittenFinal = callerReachabilityItr.next(); - HashSet sourceSets = rewritten2source.get( ttsRewrittenFinal ); + HashSet sourceSets = rewritten2source.get(ttsRewrittenFinal); assert sourceSets != null; Iterator 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) ); } } @@ -2311,15 +2311,33 @@ public class OwnershipGraph { 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; } @@ -2377,15 +2395,33 @@ public class OwnershipGraph { 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 ) { @@ -2396,15 +2432,27 @@ public class OwnershipGraph { 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; @@ -2457,15 +2505,27 @@ public class OwnershipGraph { 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; + } } @@ -2484,14 +2544,24 @@ public class OwnershipGraph { 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 @@ -2508,14 +2578,24 @@ public class OwnershipGraph { 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 ) { @@ -2534,13 +2614,21 @@ public class OwnershipGraph { 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; + } } } @@ -2555,7 +2643,7 @@ public class OwnershipGraph { boolean labelSelect, boolean pruneGarbage, boolean writeReferencers, - boolean writeParamMappings + boolean writeParamMappings ) throws java.io.IOException { writeGraph( methodDesc.getSymbol() + @@ -2574,7 +2662,7 @@ public class OwnershipGraph { boolean labelSelect, boolean pruneGarbage, boolean writeReferencers, - boolean writeParamMappings + boolean writeParamMappings ) throws java.io.IOException { writeGraph(methodDesc+"COMPLETE", @@ -2582,7 +2670,7 @@ public class OwnershipGraph { labelSelect, pruneGarbage, writeReferencers, - writeParamMappings + writeParamMappings ); } @@ -2592,7 +2680,7 @@ public class OwnershipGraph { boolean labelSelect, boolean pruneGarbage, boolean writeReferencers, - boolean writeParamMappings + boolean writeParamMappings ) throws java.io.IOException { writeGraph(methodDesc+"COMPLETE"+String.format("%05d", numUpdate), @@ -2600,7 +2688,7 @@ public class OwnershipGraph { labelSelect, pruneGarbage, writeReferencers, - writeParamMappings + writeParamMappings ); } @@ -2609,7 +2697,7 @@ public class OwnershipGraph { boolean labelSelect, boolean pruneGarbage, boolean writeReferencers, - boolean writeParamMappings + boolean writeParamMappings ) throws java.io.IOException { // remove all non-word characters from the graph name so @@ -2628,21 +2716,21 @@ public class OwnershipGraph { 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 ) { diff --git a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java index 143db1a8..391e2758 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java @@ -46,7 +46,7 @@ public class ReachabilitySet extends Canonical { return possibleReachabilities.iterator(); } - + public int size() { return possibleReachabilities.size(); } @@ -140,27 +140,27 @@ public class ReachabilitySet extends Canonical { 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) ) ); } } } @@ -256,11 +256,11 @@ public class ReachabilitySet extends Canonical { Iterator 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; } @@ -324,7 +324,7 @@ public class ReachabilitySet extends Canonical { private boolean oldHashSet = false; - private int oldHash = 0; + private int oldHash = 0; public int hashCode() { int currentHash = possibleReachabilities.hashCode(); @@ -333,7 +333,7 @@ public class ReachabilitySet extends Canonical { 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(); } diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java index 83226ad5..84c2c26e 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java +++ b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java @@ -59,7 +59,7 @@ public class TokenTuple extends Canonical { } - public TokenTuple unionArity( TokenTuple tt ) { + public TokenTuple unionArity(TokenTuple tt) { assert tt != null; assert token == tt.token; assert isMultiObject == tt.isMultiObject; @@ -69,17 +69,17 @@ public class TokenTuple extends Canonical { // 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(); } } } @@ -110,7 +110,7 @@ public class TokenTuple extends Canonical { } private boolean oldHashSet = false; - private int oldHash = 0; + private int oldHash = 0; public int hashCode() { int currentHash = token.intValue()*31 + arity; @@ -119,7 +119,7 @@ public class TokenTuple extends Canonical { 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(); } diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java index 27dd22eb..f1ec73cf 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java +++ b/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java @@ -73,22 +73,22 @@ public class TokenTupleSet extends Canonical { Iterator 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); } } @@ -119,7 +119,7 @@ public class TokenTupleSet extends Canonical { private boolean oldHashSet = false; - private int oldHash = 0; + private int oldHash = 0; public int hashCode() { int currentHash = tokenTuples.hashCode(); @@ -128,7 +128,7 @@ public class TokenTupleSet extends Canonical { 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(); } @@ -211,17 +211,17 @@ public class TokenTupleSet extends Canonical { } 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(); @@ -277,19 +277,19 @@ public class TokenTupleSet extends Canonical { 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(); @@ -356,11 +356,11 @@ public class TokenTupleSet extends Canonical { if( makeChangeSet ) { assert forChangeSet != null; - + if( forChangeSet.get(this) == null ) { forChangeSet.put(this, new HashSet() ); } - + forChangeSet.get(this).add(replaced); } } @@ -377,16 +377,16 @@ public class TokenTupleSet extends Canonical { 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(); } diff --git a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java index ab29066c..d5932d53 100644 --- a/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java +++ b/Robust/src/Analysis/Scheduling/ScheduleAnalysis.java @@ -702,6 +702,7 @@ public class ScheduleAnalysis { 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); @@ -713,6 +714,7 @@ public class ScheduleAnalysis { se.getTargetCNode().addEdge(se); } } else { + sNode.setCid(ScheduleNode.colorID++); handleScheduleEdge(se, true); } } catch (Exception e) { diff --git a/Robust/src/Benchmarks/Scheduling/FilterBank/FilterBank.java b/Robust/src/Benchmarks/Scheduling/FilterBank/FilterBank.java index 4392e613..47de0210 100644 --- a/Robust/src/Benchmarks/Scheduling/FilterBank/FilterBank.java +++ b/Robust/src/Benchmarks/Scheduling/FilterBank/FilterBank.java @@ -4,7 +4,7 @@ task t1(StartupObject s{initialstate}) { 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]; diff --git a/Robust/src/Benchmarks/Scheduling/JGFMonteCarlo/JGFMonteCarloBench.java b/Robust/src/Benchmarks/Scheduling/JGFMonteCarlo/JGFMonteCarloBench.java index 9d99b955..23dd2a26 100644 --- a/Robust/src/Benchmarks/Scheduling/JGFMonteCarlo/JGFMonteCarloBench.java +++ b/Robust/src/Benchmarks/Scheduling/JGFMonteCarlo/JGFMonteCarloBench.java @@ -24,7 +24,7 @@ task t1(StartupObject s{initialstate}) { //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}; diff --git a/Robust/src/Benchmarks/Scheduling/JGFSeries/JGFSeriesBench.java b/Robust/src/Benchmarks/Scheduling/JGFSeries/JGFSeriesBench.java index f3090f7d..adb5e0ce 100644 --- a/Robust/src/Benchmarks/Scheduling/JGFSeries/JGFSeriesBench.java +++ b/Robust/src/Benchmarks/Scheduling/JGFSeries/JGFSeriesBench.java @@ -23,7 +23,7 @@ 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}; } diff --git a/Robust/src/Makefile.raw.1 b/Robust/src/Makefile.raw.1 index 153d672a..aebc558e 100644 --- a/Robust/src/Makefile.raw.1 +++ b/Robust/src/Makefile.raw.1 @@ -11,7 +11,7 @@ ATTRIBUTES += HWIC 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 diff --git a/Robust/src/Makefile.raw.2 b/Robust/src/Makefile.raw.2 index 1094a2c0..d4f2dbec 100644 --- a/Robust/src/Makefile.raw.2 +++ b/Robust/src/Makefile.raw.2 @@ -11,7 +11,7 @@ ATTRIBUTES += HWIC 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 diff --git a/Robust/src/Makefile.raw.4 b/Robust/src/Makefile.raw.4 index f0749b01..d63e0319 100644 --- a/Robust/src/Makefile.raw.4 +++ b/Robust/src/Makefile.raw.4 @@ -11,7 +11,7 @@ ATTRIBUTES += HWIC 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 diff --git a/Robust/src/Makefile.raw.i.1 b/Robust/src/Makefile.raw.i.1 index 5c80e08e..546b4fff 100644 --- a/Robust/src/Makefile.raw.i.1 +++ b/Robust/src/Makefile.raw.i.1 @@ -1,3 +1,14 @@ + +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 @@ -8,12 +19,37 @@ SIM-CYCLES = 10000 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 diff --git a/Robust/src/Makefile.raw.i.2 b/Robust/src/Makefile.raw.i.2 index 1094a2c0..d4f2dbec 100644 --- a/Robust/src/Makefile.raw.i.2 +++ b/Robust/src/Makefile.raw.i.2 @@ -11,7 +11,7 @@ ATTRIBUTES += HWIC 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 diff --git a/Robust/src/Makefile.raw.i.4 b/Robust/src/Makefile.raw.i.4 index f0749b01..d63e0319 100644 --- a/Robust/src/Makefile.raw.i.4 +++ b/Robust/src/Makefile.raw.i.4 @@ -11,7 +11,7 @@ ATTRIBUTES += HWIC 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 diff --git a/Robust/src/Runtime/DSTM/interface/dsmdebug.h b/Robust/src/Runtime/DSTM/interface/dsmdebug.h index 0dd0e691..7f575348 100644 --- a/Robust/src/Runtime/DSTM/interface/dsmdebug.h +++ b/Robust/src/Runtime/DSTM/interface/dsmdebug.h @@ -15,23 +15,23 @@ #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 diff --git a/Robust/src/Runtime/DSTM/interface/dstmserver.c b/Robust/src/Runtime/DSTM/interface/dstmserver.c index 1e0cac6d..d65c0df5 100644 --- a/Robust/src/Runtime/DSTM/interface/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface/dstmserver.c @@ -437,7 +437,7 @@ char handleTransReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, unsigne /* 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); diff --git a/Robust/src/Runtime/Queue.h b/Robust/src/Runtime/Queue.h index 07260fb4..01253409 100644 --- a/Robust/src/Runtime/Queue.h +++ b/Robust/src/Runtime/Queue.h @@ -13,7 +13,7 @@ struct QueueItem { 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); diff --git a/Robust/src/Runtime/multicoretask.c b/Robust/src/Runtime/multicoretask.c index 5bee1d18..36e3688e 100644 --- a/Robust/src/Runtime/multicoretask.c +++ b/Robust/src/Runtime/multicoretask.c @@ -16,9 +16,12 @@ #include #endif #ifdef RAW +#ifdef RAWPROFILE +#include "stdio.h" +#include "string.h" +#endif #include #include -//#include #elif defined THREADSIMULATE // use POSIX message queue // for each core, its message queue named as @@ -109,8 +112,48 @@ void releasereadlock_I(void* ptr); 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 @@ -140,6 +183,11 @@ int main(int argc, char **argv) { 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; @@ -183,6 +231,16 @@ int main(int argc, char **argv) { 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 @@ -298,6 +356,21 @@ void run(void* arg) { 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(); } @@ -360,12 +433,29 @@ void run(void* arg) { 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 @@ -426,6 +516,9 @@ void run(void* arg) { // 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 @@ -438,6 +531,16 @@ void run(void* arg) { 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 @@ -473,7 +576,8 @@ void run(void* arg) { } 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) { @@ -493,7 +597,57 @@ void run(void* arg) { #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. } } @@ -504,6 +658,9 @@ void run(void* arg) { if(!sendStall) { #ifdef RAWDEBUG raw_test_pass(0xee12); +#endif +#ifdef RAWPROFILE + if(!stall) { #endif if(isfirst) { // wait for some time @@ -525,6 +682,9 @@ void run(void* arg) { sendStall = transStallMsg(STARTUPCORE); isfirst = true; } +#ifdef RAWPROFILE + } +#endif } else { isfirst = true; #ifdef RAWDEBUG @@ -1275,12 +1435,16 @@ void calCoords(int core_num, int* coordY, int* coordX) { * 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 @@ -1593,6 +1757,196 @@ bool transStallMsg(int 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 @@ -1620,6 +1974,14 @@ int receiveObject() { #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); @@ -1627,7 +1989,11 @@ msg: 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; @@ -1929,6 +2295,69 @@ msg: 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; } @@ -1946,11 +2375,29 @@ msg: 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; } @@ -3116,6 +3563,15 @@ newtask: /* 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); @@ -3152,6 +3608,9 @@ newtask: #ifdef INTERRUPT raw_user_interrupts_off(); +#endif +#ifdef RAWPROFILE + isInterrupt = false; #endif while(!lockflag) { receiveObject(); @@ -3170,6 +3629,9 @@ newtask: #ifndef INTERRUPT reside = false; #endif +#ifdef RAWPROFILE + isInterrupt = true; +#endif #ifdef INTERRUPT raw_user_interrupts_on(); #endif @@ -3189,6 +3651,16 @@ newtask: 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 @@ -3321,6 +3793,16 @@ newtask: 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; } } @@ -3404,10 +3886,31 @@ parameterpresent: }*/ /* 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)); @@ -3419,10 +3922,28 @@ execute: } 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 @@ -3445,13 +3966,24 @@ execute: #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); diff --git a/Robust/src/Runtime/task.c b/Robust/src/Runtime/task.c index 52f8bcb0..e5db4ef6 100644 --- a/Robust/src/Runtime/task.c +++ b/Robust/src/Runtime/task.c @@ -1200,7 +1200,7 @@ parameterpresent: } /* Actually call task */ #ifdef PRECISE_GC - ((int *)taskpointerarray)[0]=currtpd->numParameters; + ((int *)taskpointerarray)[0]=currtpd->numParameters; taskpointerarray[1]=NULL; #endif #ifdef OPTIONAL diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 1c449c9d..565d7772 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -56,6 +56,7 @@ RAWFLAG=false RAWCONFIG='' RAWDEBUGFLAG=false RAWPATHFLAG=false +RAWPROFILEFLAG=false INTERRUPTFLAG=false THREADSIMULATEFLAG=false; USEDMALLOC=false @@ -125,6 +126,7 @@ then EXTRAOPTIONS="$EXTRAOPTIONS -DMAC" elif [[ $1 = '-profile' ]] then +RAWPROFILEFLAG=true EXTRAOPTIONS="$EXTRAOPTIONS -pg" elif [[ $1 = '-taskstate' ]] then @@ -314,6 +316,11 @@ then #debug version RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWDEBUG" fi +if $RAWPROFILEFLAG +then # profile version +RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWPROFILE" +fi + if $INTERRUPTFLAG then #INTERRUPT version MAKEFILE="$MAKEFILE.i" -- 2.34.1