at task exit, a task should acquire any out-set variables that arent already it the...
authorjjenista <jjenista>
Tue, 5 Apr 2011 17:40:14 +0000 (17:40 +0000)
committerjjenista <jjenista>
Tue, 5 Apr 2011 17:40:14 +0000 (17:40 +0000)
Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java
Robust/src/Analysis/OoOJava/VarSrcTokTable.java
Robust/src/Benchmarks/oooJava/DelaunayRefinement/SerialDelaunayRefinement.java
Robust/src/Benchmarks/oooJava/master-makefile
Robust/src/IR/Flat/BuildOoOJavaCode.java
Robust/src/IR/Flat/FlatSESEEnterNode.java

index b98e8367a9b61069c3f9dcbf1bd31b615f83747f..141021034bdff669dfd9ca0c4049940bd186ffc2 100644 (file)
@@ -16,6 +16,7 @@ public class OoOJavaAnalysis {
   private State state;
   private TypeUtil typeUtil;
   private CallGraph callGraph;
+  private Liveness liveness;
   private RBlockRelationAnalysis rblockRel;
   private HeapAnalysis disjointAnalysisTaints;
   private DisjointAnalysis disjointAnalysisReach;
@@ -98,9 +99,10 @@ public class OoOJavaAnalysis {
                           ArrayReferencees arrayReferencees ) {
 
     State.logEvent("Starting OoOJavaAnalysis");
-    this.state = state;
-    this.typeUtil = typeUtil;
-    this.callGraph = callGraph;
+    this.state      = state;
+    this.typeUtil   = typeUtil;
+    this.callGraph  = callGraph;
+    this.liveness   = liveness;
     this.maxSESEage = state.OOO_MAXSESEAGE;
 
     livenessGlobalView     = new Hashtable<FlatNode, Set<TempDescriptor>>();
@@ -152,7 +154,7 @@ public class OoOJavaAnalysis {
     Iterator<FlatSESEEnterNode> seseItr = rblockRel.getLocalRootSESEs().iterator();
     while (seseItr.hasNext()) {
       FlatSESEEnterNode sese = seseItr.next();
-      livenessAnalysisBackward(sese,liveness);
+      livenessAnalysisBackward(sese);
     }
     
 
@@ -175,7 +177,7 @@ public class OoOJavaAnalysis {
     seseItr = rblockRel.getLocalRootSESEs().iterator();
     while (seseItr.hasNext()) {
       FlatSESEEnterNode sese = seseItr.next();
-      livenessAnalysisBackward(sese,liveness);
+      livenessAnalysisBackward(sese);
     }
     
     State.logEvent("OoOJavaAnalysis 4th pass completed");
@@ -249,7 +251,7 @@ public class OoOJavaAnalysis {
     while (methItr.hasNext()) {
       Descriptor d = methItr.next();
       FlatMethod fm = state.getMethodFlat(d);
-      codePlansForward(fm,liveness);
+      codePlansForward(fm);
     }
 
     State.logEvent("OoOJavaAnalysis 12th pass completed");    
@@ -332,7 +334,7 @@ public class OoOJavaAnalysis {
   }
 
 
-  private void livenessAnalysisBackward(FlatSESEEnterNode fsen,Liveness liveness) {
+  private void livenessAnalysisBackward(FlatSESEEnterNode fsen) {
 
     // flow backward across nodes to compute liveness, and
     // take special care with sese enter/exit nodes that
@@ -357,7 +359,7 @@ public class OoOJavaAnalysis {
         }
       }
       
-      Set<TempDescriptor> curr = liveness_nodeActions( fn, livein, liveness );
+      Set<TempDescriptor> curr = liveness_nodeActions( fn, livein );
 
       // if a new result, schedule backward nodes for analysis
       if( !curr.equals( prev ) ) {
@@ -374,7 +376,7 @@ public class OoOJavaAnalysis {
   }
 
   private Set<TempDescriptor> liveness_nodeActions( FlatNode            fn, 
-                                                    Set<TempDescriptor> liveIn, Liveness liveness
+                                                    Set<TempDescriptor> liveIn
                                                     ) {
     switch( fn.kind() ) {
 
@@ -403,7 +405,6 @@ public class OoOJavaAnalysis {
           FlatSESEExitNode fsexn = fsen.getFlatExit();
           //note: liveness analysis can have corresponding decisions 
           Set<TempDescriptor> livetemps= liveness.getLiveInTemps(fsen.getfmEnclosing(), fsexn);
-//          Set<TempDescriptor> livetemps = livenessGlobalView.get( fsexn );
           if( livetemps != null && livetemps.contains( writeTemps[i] ) ) {
             fsen.addOutVar( writeTemps[i] );
           }          
@@ -495,7 +496,9 @@ public class OoOJavaAnalysis {
       // written by an SESE and should be added to the in-set
       // anything virtually read by this SESE should be pruned
       // of parent or sibling sources
-      Set<TempDescriptor> liveVars = livenessGlobalView.get(fn);
+      Set<TempDescriptor> liveVars = liveness.getLiveInTemps(fsen.getfmEnclosing(),
+                                                             fn);
+
       Set<TempDescriptor> fsenVirtReads =
         vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, 
                                                              liveVars);
@@ -506,6 +509,10 @@ public class OoOJavaAnalysis {
       }
       livenessVirtualReads.put(fn, fsenVirtReads);
 
+      // virtual reads are forced in-vars!
+      fsen.addInVarSet( fsenVirtReads );
+
+
       // then all child out-set tokens are guaranteed
       // to be filled in, so clobber those entries with
       // the latest, clean sources
@@ -765,7 +772,7 @@ public class OoOJavaAnalysis {
   }
 
 
-  private void codePlansForward(FlatMethod fm, Liveness liveness) {
+  private void codePlansForward(FlatMethod fm) {
 
     // start from flat method top, visit every node in
     // method exactly once
@@ -807,7 +814,7 @@ public class OoOJavaAnalysis {
       }
 
       codePlans_nodeActions(fm, fn, 
-                            /*dotSTlive*/liveness, dotSTtable, dotSTnotAvailSet, 
+                            dotSTtable, dotSTnotAvailSet, 
                             currentSESE);
 
       for (int i = 0; i < fn.numNext(); i++) {
@@ -822,8 +829,6 @@ public class OoOJavaAnalysis {
       
   private void codePlans_nodeActions(FlatMethod fm,
                                      FlatNode fn,
-//                                     Set<TempDescriptor> liveSetIn,
-                                     Liveness liveness,
                                      VarSrcTokTable vstTableIn, 
                                      Set<TempDescriptor> notAvailSetIn, 
                                      FlatSESEEnterNode currentSESE) {
@@ -860,13 +865,14 @@ public class OoOJavaAnalysis {
         // variable and the child needs space in its SESE record
         if (srcType.equals(VarSrcTokTable.SrcType_DYNAMIC)) {
           fsen.addDynamicInVar(inVar);
-          addDynamicVar( fsen, fm, inVar );
+          addDynamicVar( parent, fm, inVar );
 
         } else if (srcType.equals(VarSrcTokTable.SrcType_STATIC)) {
           fsen.addStaticInVar(inVar);
           VariableSourceToken vst = vstIfStatic.vst;
           fsen.putStaticInVar2src(inVar, vst);
           fsen.addStaticInVarSrc(new SESEandAgePair(vst.getSESE(), vst.getAge()));
+
         } else {
           assert srcType.equals(VarSrcTokTable.SrcType_READY);
           fsen.addReadyInVar(inVar);
@@ -876,11 +882,40 @@ public class OoOJavaAnalysis {
 
     case FKind.FlatSESEExitNode: {
       FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
-      //TODO! Shouldn't there be a code plan for task exit
-      // where the exiting task calculates whether its own
-      // siblings need variables from its children, so the
-      // exiter should copy those variables into its own out-set
-      // and make the available?
+
+      // Classify the sources of out-set variables so code
+      // gen can acquire them from children if necessary
+      // before this task exits
+      FlatSESEEnterNode exiter = fsexn.getFlatEnter();
+
+      Iterator<TempDescriptor> outVarItr = exiter.getOutVarSet().iterator();
+      while( outVarItr.hasNext() ) {
+        TempDescriptor outVar = outVarItr.next();
+                
+        VSTWrapper vstIfStatic = new VSTWrapper();
+        Integer srcType = vstTableIn.getRefVarSrcType( outVar, 
+                                                       exiter,
+                                                       vstIfStatic
+                                                       );
+
+        if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) {
+          // if the out-var is dynamic, put it in the set of dyn out vars
+          // so exiting code gen knows to look for the value, but also put
+          // it in the set of dynamic vars the exiter must track!
+          exiter.addDynamicOutVar( outVar );
+          addDynamicVar( exiter, fm, outVar );
+
+        } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) {
+          exiter.addStaticOutVar( outVar );
+          VariableSourceToken vst = vstIfStatic.vst;
+          exiter.putStaticOutVar2src( outVar, vst );
+          exiter.addStaticOutVarSrc( new SESEandAgePair( vst.getSESE(), vst.getAge() ) );
+
+        } else {
+          assert srcType.equals( VarSrcTokTable.SrcType_READY );          
+          exiter.addReadyOutVar( outVar );
+        }
+      }
     } break;
 
     case FKind.FlatOpNode: {
@@ -970,12 +1005,9 @@ public class OoOJavaAnalysis {
             while (refVarItr.hasNext()) {
               TempDescriptor refVar = refVarItr.next();
               //note: this should just use normal liveness in...only want to copy live variables...
-//              if (liveSetIn.contains(refVar)) {
-//                copySet.add(refVar);
-//              }
-                if(liveness.getLiveInTemps(fm, fn).contains(refVar)){
-                  copySet.add(refVar);
-                }
+              if(liveness.getLiveInTemps(fm, fn).contains(refVar)){
+                copySet.add(refVar);
+              }
             }
 
             if (!copySet.isEmpty()) {
@@ -1026,16 +1058,48 @@ public class OoOJavaAnalysis {
 
     codePlans.put(fn, plan);
 
-    // if any variables at this-node-*dot* have a static source (exactly one
-    // vst)
+
+
+
+    // if any variables at this-node-*dot* have a static source (exactly one vst)
     // but go to a dynamic source at next-node-*dot*, create a new IR graph
     // node on that edge to track the sources dynamically
+    // NOTE: for this calculation use the currentSESE variable, except when the 
+    // FlatNode fn is an Exit--in that case currentSESE is for the exiting task,
+    // be we want to consider that the parent is tracking a variable coming out
+    // of the exiting task
+    FlatSESEEnterNode fsenDoingTracking;
+    if( fn instanceof FlatSESEExitNode ) {
+      fsenDoingTracking = currentSESE.getLocalParent();
+
+      if( fsenDoingTracking == null ) {
+        // if there is no local parent, there are one of two cases
+        // 1) the current task is main, in which case this FlatNode
+        //    is the main's exit, and doesn't need to do any of the
+        //    following dynamic tracking
+        // 2) the current task is defined in a method, so use the
+        //    caller proxy in the variable source calcs below
+        if( currentSESE.equals( rblockRel.getMainSESE() ) ) {          
+          return;
+        } else {
+          fsenDoingTracking = rblockRel.getCallerProxySESE();
+        }
+      }
+    } else {
+      fsenDoingTracking = currentSESE;
+    }
+
+
+    if( fsenDoingTracking.getPrettyIdentifier().equals( "workLoop" ) ) {
+      System.out.println( "\n\nWriteDyn for "+fsenDoingTracking+" at "+fn );
+    }
+
+
     VarSrcTokTable thisVstTable = variableResults.get(fn);
     for (int i = 0; i < fn.numNext(); i++) {
       FlatNode nn = fn.getNext(i);
       VarSrcTokTable nextVstTable = variableResults.get(nn);
       // note: using the result of liveness analysis regardless of task structures 
-      // Set<TempDescriptor> nextLiveIn = livenessGlobalView.get(nn);
       Set<TempDescriptor> nextLiveIn=liveness.getLiveInTemps(fm, nn);
 
       // the table can be null if it is one of the few IR nodes
@@ -1043,17 +1107,24 @@ public class OoOJavaAnalysis {
       if (nextVstTable != null && nextLiveIn != null) {
 
         Hashtable<TempDescriptor, VSTWrapper> readyOrStatic2dynamicSet =
-            thisVstTable.getReadyOrStatic2DynamicSet(nextVstTable, nextLiveIn, currentSESE);
+            thisVstTable.getReadyOrStatic2DynamicSet(nextVstTable, nextLiveIn, fsenDoingTracking);
 
         if (!readyOrStatic2dynamicSet.isEmpty()) {
 
+
+
+          if( fsenDoingTracking.getPrettyIdentifier().equals( "workLoop" ) ) {
+            System.out.println( "  found newly dyn vars: "+readyOrStatic2dynamicSet );
+          }
+
+
           // either add these results to partial fixed-point result
           // or make a new one if we haven't made any here yet
           FlatEdge fe = new FlatEdge(fn, nn);
           FlatWriteDynamicVarNode fwdvn = wdvNodesToSpliceIn.get(fe);
 
           if (fwdvn == null) {
-            fwdvn = new FlatWriteDynamicVarNode(fn, nn, readyOrStatic2dynamicSet, currentSESE);
+            fwdvn = new FlatWriteDynamicVarNode(fn, nn, readyOrStatic2dynamicSet, fsenDoingTracking);
             wdvNodesToSpliceIn.put(fe, fwdvn);
           } else {
             fwdvn.addMoreVar2Src(readyOrStatic2dynamicSet);
@@ -1061,6 +1132,10 @@ public class OoOJavaAnalysis {
         }
       }
     }
+
+    if( fsenDoingTracking.getPrettyIdentifier().equals( "workLoop" ) ) {
+      System.out.println( "WriteDyn for "+fsenDoingTracking+" at "+fn+" is done\n\n" );
+    }
   }
 
   private void addDynamicVar( FlatSESEEnterNode fsen, 
@@ -1070,15 +1145,15 @@ public class OoOJavaAnalysis {
     
     // note: dynamic variable declarations are always located in the flat method that encloses task block
     // there is no need to set fnContext to fsen
-//    if( fsen.getIsCallerProxySESE() ) {
-//      // attach the dynamic variable to track to
-//      // the flat method, so it can be declared at entry
-//      fnContext = fm;
-//    } else {
-//      // otherwise the code context is a task body
-//      fnContext = fsen;
-//    }
-    fnContext=fm;
+    if( fsen.getIsCallerProxySESE() ) {
+      // attach the dynamic variable to track to
+      // the flat method, so it can be declared at entry
+      fnContext = fm;
+    } else {
+      // otherwise the code context is a task body
+      fnContext = fsen;
+    }
+    //fnContext=fm;
 
     ContextTaskNames ctn = fn2contextTaskNames.get( fnContext );
     if( ctn == null ) {
@@ -1721,6 +1796,19 @@ public class OoOJavaAnalysis {
       bw.write("   Dynamic vars to manage: " + getContextTaskNames( fsen ).getDynamicVarSet() + "\n");
 
       bw.write("  out-set: " + fsen.getOutVarSet() + "\n");
+      tItr = fsen.getOutVarSet().iterator();
+      while (tItr.hasNext()) {
+        TempDescriptor outVar = tItr.next();
+        if (fsen.getReadyOutVarSet().contains(outVar)) {
+          bw.write("    (ready)  " + outVar + "\n");
+        }
+        if (fsen.getStaticOutVarSet().contains(outVar)) {
+          bw.write("    (static) " + outVar + " from " + fsen.getStaticOutVarSrc(outVar) + "\n");
+        }
+        if (fsen.getDynamicOutVarSet().contains(outVar)) {
+          bw.write("    (dynamic)" + outVar + "\n");
+        }
+      }
 
       bw.write("  local parent:   " + fsen.getLocalParent() + "\n");
       bw.write("  local children: " + fsen.getLocalChildren() + "\n");
index c51517ffe2462e5d6524b4f960b8099e8572e435..c799ca640542efb64db140d814fe76c16e56e536 100644 (file)
@@ -385,23 +385,25 @@ public class VarSrcTokTable {
   public void remapChildTokens( FlatSESEEnterNode curr ) {
 
     Iterator<FlatSESEEnterNode> childItr = curr.getLocalChildren().iterator();
-    if( childItr.hasNext() ) {
+    while( childItr.hasNext() ) {
       FlatSESEEnterNode child = childItr.next();
       
       // set of VSTs for removal
       HashSet<VariableSourceToken> removalSet=new HashSet<VariableSourceToken>();
       // set of VSTs for additon
       HashSet<VariableSourceToken> additionSet=new HashSet<VariableSourceToken>();
-      
+     
       Iterator<VariableSourceToken> vstItr = get( child ).iterator();
       while( vstItr.hasNext() ) {
         VariableSourceToken vst = vstItr.next();
         removalSet.add(vst);
-        additionSet.add(new VariableSourceToken( vst.getRefVars(),
-                             curr,
-                             new Integer( 0 ),
-                             vst.getAddrVar()
-                                  ));
+
+        additionSet.add( new VariableSourceToken( vst.getRefVars(),
+                                                  curr,
+                                                  new Integer( 0 ),
+                                                  vst.getAddrVar()
+                                                  )
+                         );
       }
       
       // remove( eah item in forremoval )
@@ -466,8 +468,6 @@ public class VarSrcTokTable {
         alternateSESEs.add( sibling );
       }
     }
-
-
     
     // VSTs to remove if they are alternate sources for exiter VSTs
     // whose variables will become virtual reads
@@ -512,8 +512,9 @@ public class VarSrcTokTable {
            forRemoval.add( vstPossibleOtherSrc );  
 
          } else {
-            if( !vstPossibleOtherSrc.getSESE().equals( exiter ) ||
-                !vstPossibleOtherSrc.getAge().equals( 0 )
+            if( !(vstPossibleOtherSrc.getSESE().equals( exiter ) &&
+                  vstPossibleOtherSrc.getAge().equals( 0 )
+                 )
                 ) {
               System.out.println( "For refVar="+refVar+" at exit of "+exiter+
                                   ", unexpected possible variable source "+vstPossibleOtherSrc );
index c4cb1d6a879fb14365c3d83cc6e67e3f9180ee9b..5f2672df4b3617ebe9e0e085fa0bdac4f1fb4474 100644 (file)
@@ -100,247 +100,256 @@ public class SerialDelaunayRefinement {
     System.out.println( "done gc" );
 
 
-    Node  [] nodesForBadTris = new Node  [numWorkers];
-    Cavity[] cavities        = new Cavity[numWorkers];
-    Cavity lastAppliedCavity = null;
+    //int zzz = 0;
 
 
-    int zzz = 0;
+    long startTime = System.currentTimeMillis();
 
 
-    long startTime = System.currentTimeMillis();
-    while (!worklist.isEmpty()) {
-
-      // Phase 1, grab enough work from list for
-      // each worker in the parent      
-      for(int i=0;i<numWorkers;i++) {
-        if(worklist.isEmpty()) {
-          nodesForBadTris[i] = null; 
-        } else {
-          nodesForBadTris[i] = (Node) worklist.pop();
+    sese workLoop {
+
+      Node  [] nodesForBadTris = new Node  [numWorkers];
+      Cavity[] cavities        = new Cavity[numWorkers];
+      Cavity lastAppliedCavity = null;
+
+      while (!worklist.isEmpty()) {
+
+        // Phase 1, grab enough work from list for
+        // each worker in the parent      
+        for(int i=0;i<numWorkers;i++) {
+          if(worklist.isEmpty()) {
+            nodesForBadTris[i] = null; 
+          } else {
+            nodesForBadTris[i] = (Node) worklist.pop();
+          }
         }
-      }
       
-      // Phase 2, read mesh and compute cavities in parallel
-      for(int i=0;i<numWorkers;i++) {
+        // Phase 2, read mesh and compute cavities in parallel
+        for(int i=0;i<numWorkers;i++) {
         
-        Node nodeForBadTri = nodesForBadTris[i];        
+          Node nodeForBadTri = nodesForBadTris[i];        
 
-        if (nodeForBadTri != null &&
-            nodeForBadTri.inGraph
-            ) {
+          if (nodeForBadTri != null &&
+              nodeForBadTri.inGraph
+              ) {
      
-          //System.out.println( "computing a cavity for tri "+
-          //                    mesh.getNodeData( nodeForBadTri )+"..." );
+            //System.out.println( "computing a cavity for tri "+
+            //                    mesh.getNodeData( nodeForBadTri )+"..." );
      
-          sese computeCavity {
-            //takes < 1 sec 
-            Cavity cavity = new Cavity(mesh);
+            sese computeCavity {
+              //takes < 1 sec 
+              Cavity cavity = new Cavity(mesh);
           
-            //Appears to only call getters (only possible conflict is inherent in Hashmap)
-            cavity.initialize(nodeForBadTri);
+              //Appears to only call getters (only possible conflict is inherent in Hashmap)
+              cavity.initialize(nodeForBadTri);
           
-            //Takes up 15% of computation
-            //Problem:: Build is recursive upon building neighbor upon neighbor upon neighbor
-            //This is could be a problem....
-            //TODO check dimensions problem
-            cavity.build();
+              //Takes up 15% of computation
+              //Problem:: Build is recursive upon building neighbor upon neighbor upon neighbor
+              //This is could be a problem....
+              //TODO check dimensions problem
+              cavity.build();
           
-            //Takes up a whooping 50% of computation time and changes NOTHING but cavity :D
-            cavity.update();
+              //Takes up a whooping 50% of computation time and changes NOTHING but cavity :D
+              cavity.update();
 
 
-            /*
-            LinkedList nodes  = cavity.getPre().getNodes();
-            LinkedList border = cavity.getPre().getBorder();
-            LinkedList edges  = cavity.getPre().getEdges();
+              /*
+                LinkedList nodes  = cavity.getPre().getNodes();
+                LinkedList border = cavity.getPre().getBorder();
+                LinkedList edges  = cavity.getPre().getEdges();
 
-            String s = "nodes:  \n";
+                String s = "nodes:  \n";
     
-            for( Iterator iter = nodes.iterator(); iter.hasNext(); ) {
-              Node    node = (Node) iter.next();
-              Element element = (Element) mesh.getNodeData(node);
-              s += "  "+element+"\n";
-            }
+                for( Iterator iter = nodes.iterator(); iter.hasNext(); ) {
+                Node    node = (Node) iter.next();
+                Element element = (Element) mesh.getNodeData(node);
+                s += "  "+element+"\n";
+                }
 
-            s += "\nborder: \n";
+                s += "\nborder: \n";
 
-            for( Iterator iter = border.iterator(); iter.hasNext(); ) {
-              Node    node = (Node) iter.next();
-              Element element = (Element) mesh.getNodeData(node);
-              s += "  "+element+"\n";
-            }
+                for( Iterator iter = border.iterator(); iter.hasNext(); ) {
+                Node    node = (Node) iter.next();
+                Element element = (Element) mesh.getNodeData(node);
+                s += "  "+element+"\n";
+                }
 
-            s += "\nedges:  \n";
+                s += "\nedges:  \n";
 
-            for( Iterator iter = edges.iterator(); iter.hasNext(); ) {
-              Edge_d  edge    = (Edge_d)  iter.next();
-              Element element = (Element) mesh.getEdgeData(edge);
-              s += "  "+element+"\n";
-            }
+                for( Iterator iter = edges.iterator(); iter.hasNext(); ) {
+                Edge_d  edge    = (Edge_d)  iter.next();
+                Element element = (Element) mesh.getEdgeData(edge);
+                s += "  "+element+"\n";
+                }
 
-            System.out.println( "Pre:\n"+s );
-            */
+                System.out.println( "Pre:\n"+s );
+              */
 
-          }
+            }
           
-          sese storeCavity {
-            cavities[i] = cavity;
-          }
+            sese storeCavity {
+              cavities[i] = cavity;
+            }
 
-        } else {
-          sese storeNoCavity {
-            cavities[i] = null;
+          } else {
+            sese storeNoCavity {
+              cavities[i] = null;
+            }
           }
         }
-      }
       
-      // Phase 3, apply cavities to mesh, if still applicable
-      // this phase can proceed in parallel when a cavity's
-      // start nodes are still present
-      for(int i=0;i<numWorkers;i++) {
-
-        Cavity  cavity        = cavities[i];
-        boolean appliedCavity = false;
-        Node    nodeForBadTri = nodesForBadTris[i];
+        // Phase 3, apply cavities to mesh, if still applicable
+        // this phase can proceed in parallel when a cavity's
+        // start nodes are still present
+        for(int i=0;i<numWorkers;i++) {
+
+          Cavity  cavity        = cavities[i];
+          Node    nodeForBadTri = nodesForBadTris[i];
+
         
-        sese applyCavity {
+          sese applyCavity {
+            
+            int appliedCavity = 0;
 
-          // go ahead with applying cavity when all of its
-          // pre-nodes are still in
-          if( cavity != null &&
-              cavity.getPre().allNodesAndBorderStillInCompleteGraph() ) {
+            // go ahead with applying cavity when all of its
+            // pre-nodes are still in
+            if( cavity != null &&
+                cavity.getPre().allNodesAndBorderStillInCompleteGraph() ) {
 
-            appliedCavity     = true;
-            lastAppliedCavity = cavity;
+              appliedCavity     = 1;
 
 
-            //boolean printChange = true; //(zzz % 10 == 0);
+              //boolean printChange = true; //(zzz % 10 == 0);
         
 
-            //remove old data
-            Node node;
-            //if( printChange ) {
-            //  System.out.println( "\n\n\nbad tri: "+mesh.getNodeData( nodeForBadTri ) );
-            //  System.out.println( "\npre nodes: " );
-            //}
-            //Takes up 8.9% of runtime
-            for (Iterator iterator = cavity.getPre().getNodes().iterator();
-                 iterator.hasNext();) {
-
-              node = (Node) iterator.next();
+              //remove old data
+              Node node;
               //if( printChange ) {
-              //  System.out.println( "  "+mesh.getNodeData( node ) );
-              //}          
-              mesh.removeNode(node);
-            }
+              //  System.out.println( "\n\n\nbad tri: "+mesh.getNodeData( nodeForBadTri ) );
+              //  System.out.println( "\npre nodes: " );
+              //}
+              //Takes up 8.9% of runtime
+              for (Iterator iterator = cavity.getPre().getNodes().iterator();
+                   iterator.hasNext();) {
+
+                node = (Node) iterator.next();
+                //if( printChange ) {
+                //  System.out.println( "  "+mesh.getNodeData( node ) );
+                //}          
+                mesh.removeNode(node);
+              }
  
-            //add new data
-            //if( printChange ) {
-            //  System.out.println( "post nodes: " );
-            //}
-            //Takes up 1.7% of runtime
-            for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); 
-                 iterator1.hasNext();) {
-
-              node = (Node) iterator1.next();
+              //add new data
               //if( printChange ) {
-              //  System.out.println( "  "+mesh.getNodeData( node ) );
-              //}          
-              mesh.addNode(node);
-            }
+              //  System.out.println( "post nodes: " );
+              //}
+              //Takes up 1.7% of runtime
+              for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); 
+                   iterator1.hasNext();) {
+
+                node = (Node) iterator1.next();
+                //if( printChange ) {
+                //  System.out.println( "  "+mesh.getNodeData( node ) );
+                //}          
+                mesh.addNode(node);
+              }
  
-            //if( printChange ) {
-            //  System.out.println( "post edges: " );
-            //}
-            //Takes up 7.8% of runtime
-            Edge_d edge;
-            for (Iterator iterator2 = cavity.getPost().getEdges().iterator();
-                 iterator2.hasNext();) {
-              
-              edge = (Edge_d) iterator2.next();
               //if( printChange ) {
-              //  System.out.println( "  "+mesh.getEdgeData( edge ) );
-              //}                        
-              mesh.addEdge(edge);
-            }
-
+              //  System.out.println( "post edges: " );
+              //}
+              //Takes up 7.8% of runtime
+              Edge_d edge;
+              for (Iterator iterator2 = cavity.getPost().getEdges().iterator();
+                   iterator2.hasNext();) {
+              
+                edge = (Edge_d) iterator2.next();
+                //if( printChange ) {
+                //  System.out.println( "  "+mesh.getEdgeData( edge ) );
+                //}                        
+                mesh.addEdge(edge);
+              }
 
 
-            for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); 
-                 iterator1.hasNext();) {
-              node = (Node) iterator1.next();
+              /*
+              for (Iterator iterator1 = cavity.getPost().getNodes().iterator(); 
+                   iterator1.hasNext();) {
+                node = (Node) iterator1.next();
 
-              Element e = (Element)mesh.getNodeData( node );
+                Element e = (Element)mesh.getNodeData( node );
 
-              int cntOutNeighbors = 0;
-              for (Iterator iterator = mesh.getOutNeighbors(node); iterator.hasNext();) {
-                ++cntOutNeighbors;
-                Node neighbor = (Node) iterator.next();
-              }
+                int cntOutNeighbors = 0;
+                for (Iterator iterator = mesh.getOutNeighbors(node); iterator.hasNext();) {
+                  ++cntOutNeighbors;
+                  Node neighbor = (Node) iterator.next();
+                }
 
-              int dim = e.getDim();
-              int out = cntOutNeighbors;
+                int dim = e.getDim();
+                int out = cntOutNeighbors;
 
-              if( dim == 3 && out < 3 ) {
-                System.out.println( e+" has dim="+dim+" and num out-neighbors in graph="+out );
+                if( dim == 3 && out < 3 ) {
+                  System.out.println( e+" has dim="+dim+" and num out-neighbors in graph="+out );
+                }
               }
-            }
+              */
 
+            }
           }
-        }
          
 
-        sese scheduleMoreBad {
+          sese scheduleMoreBad {
 
-          if( appliedCavity ) {
-            // we did apply the cavity, and we may 
-            // have introduced new bad triangles
-            HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
-            while (it2.hasNext()) {
-              worklist.push((Node)it2.next());
+            if( appliedCavity == 1 ) {
+
+              lastAppliedCavity = cavity;
+              
+              // we did apply the cavity, and we may 
+              // have introduced new bad triangles
+              HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
+              while (it2.hasNext()) {
+                worklist.push((Node)it2.next());
+              }
             }
-          }
         
-          // the logic of having this out here seems wacky, and overconservative,
-          // but it matches the original algorithm and it works...
-          if( nodeForBadTri != null && mesh.containsNode( nodeForBadTri ) ) {
-            worklist.push( nodeForBadTri );
-          }
+            // the logic of having this out here seems wacky, and overconservative,
+            // but it matches the original algorithm and it works...
+            if( nodeForBadTri != null && mesh.containsNode( nodeForBadTri ) ) {
+              worklist.push( nodeForBadTri );
+            }
           
-          /*
-          if( !appliedCavity ) {
+            /*
+              if( appliedCavity != 1 ) {
 
-            // if we couldn't even apply this cavity, just
-            // throw it back on the worklist
-            if( nodeForBadTri != null && nodeForBadTri.inGraph ) {
+              // if we couldn't even apply this cavity, just
+              // throw it back on the worklist
+              if( nodeForBadTri != null && nodeForBadTri.inGraph ) {
               worklist.push( nodeForBadTri );
-            } else {
+              } else {
               System.out.println( "\n\n\nthis tri no longer a concern: "+
-                                  mesh.getNodeData( nodeForBadTri ) );
-            }
+              mesh.getNodeData( nodeForBadTri ) );
+              }
 
-          } else {
-            // otherwise we did apply the cavity,
-            // and we may have introduced new bad triangles
-            HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
-            while (it2.hasNext()) {
+              } else {
+              // otherwise we did apply the cavity,
+              // and we may have introduced new bad triangles
+              HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
+              while (it2.hasNext()) {
               worklist.push((Node)it2.next());
-            }
-          }
-          */
+              }
+              }
+            */
 
-        } // end scheduleMoreBad
-      } // end phase 3
+          } // end scheduleMoreBad
+        } // end phase 3
 
-      //++zzz;
-      //Node aNode = (Node)lastAppliedCavity.getPost().getNodes().iterator().next();      
-      //mesh.discoverAllNodes( aNode );
-      //System.out.println( "\n\ntris="+mesh.getNumNodes()+
-      //                    " [wl="+worklist.size()+"]");
-      //if( zzz == 10 ) { System.exit( 0 ); }
+        //++zzz;
+        //Node aNode = (Node)lastAppliedCavity.getPost().getNodes().iterator().next();      
+        //mesh.discoverAllNodes( aNode );
+        //System.out.println( "\n\ntris="+mesh.getNumNodes()+
+        //                    " [wl="+worklist.size()+"]");
+        //if( zzz == 10 ) { System.exit( 0 ); }
 
-    } // end while( !worklist.isEmpty() )
+      } // end while( !worklist.isEmpty() )
+    } // end sese workLoop
 
     long time = System.currentTimeMillis() - startTime;
     System.out.println("runtime: " + time + " ms");
index 1c0ce76c2de7eaee96883c5c8bd1270212280478..2132b2970d81465ec8258c0f3e0a93b2872dde2c 100644 (file)
@@ -33,11 +33,11 @@ USECOREPROF= #-coreprof $(COREPROFOVERFLOW) \
 
 
 USEOOO= -ooojava $(NUM_OOO_WORKERS) 2 -squeue #-ooodebug-disable-task-mem-pool
-USERCR= -ooojava $(NUM_RCR_WORKERS) 2 -rcr -squeue 
+USERCR= -ooodebug -ooojava $(NUM_RCR_WORKERS) 2 -rcr -squeue 
 OOODEBUG= -ooodebug -printlinenum
 RCRDEBUG= -rcr_debug -printlinenum
 RCRDEBUGV= -rcr_debug_verbose -printlinenum
-BSFLAGS= -64bit -mainclass $(PROGRAM)  -heapsize-mb 8000 -garbagestats -joptimize -noloop -optimize -debug #-nooptimize #src-after-pp
+BSFLAGS= -64bit -mainclass $(PROGRAM)  -heapsize-mb 8000 -garbagestats -joptimize -noloop -nooptimize -debug # #src-after-pp  -optimize
 
 
 DRELEASEMODE=-disjoint-release-mode -disjoint-dvisit-stack-callees-on-top -disjoint-alias-file aliases.txt tabbed
index 9857ca60e88f352bcb664a18ebd002b587953d2e..fd92fdecf6159b3aeb404d79b2350b2cb3e1a8f1 100644 (file)
@@ -1741,35 +1741,80 @@ public class BuildOoOJavaCode extends BuildCode {
     output.println("   }");
 
 
-    // copy out-set from local temps into the sese record
-    Iterator<TempDescriptor> itr = fsen.getOutVarSet().iterator();
+
+    ////////////////////////////////////////
+    // go through all out-vars and determine where to get them
+    ////////////////////////////////////////
+    output.println("   // copy ready out-set primitive variables from locals into record");
+    Iterator<TempDescriptor> itr = fsen.getReadyOutVarSet().iterator();
     while( itr.hasNext() ) {
       TempDescriptor temp = itr.next();
 
-      // only have to do this for primitives non-arrays
+      // only have to do this for primitives, non-arrays
       if( !(
             temp.getType().isPrimitive() && !temp.getType().isArray()
-           )
-        ) {
+            )
+          ) {
        continue;
       }
 
-      String from;
-
-      // determine whether this new task instance is in a method context,
-      // or within the body of another task
-      assert !fsen.getIsCallerProxySESE();
-      FlatSESEEnterNode parent = fsen.getLocalParent();
-      if( parent != null && !parent.getIsCallerProxySESE() ) {
-        from = generateTemp( parent.getfmBogus(),   temp );
-      } else {
-       from = generateTemp( fsen.getfmEnclosing(), temp );
-      }
+      String from = generateTemp( fsen.getfmBogus(), temp );
 
       output.println("   "+paramsprefix+
                     "->"+temp.getSafeSymbol()+
                     " = "+from+";");
-    }    
+    }
+
+    // static vars are from a known SESE
+    Iterator<TempDescriptor> tempItr;
+    output.println("   // copy out-set from static sources");
+    tempItr = fsen.getStaticOutVarSet().iterator();
+    while( tempItr.hasNext() ) {
+      TempDescriptor      temp    = tempItr.next();
+      VariableSourceToken vst     = fsen.getStaticOutVarSrc( temp );
+      SESEandAgePair      srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+      output.println("   "+paramsprefix+
+                    "->"+temp.getSafeSymbol()+
+                    " = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
+    }
+    
+    //output.println("   // decrement references to static sources");
+    //for( Iterator<SESEandAgePair> pairItr = fsen.getStaticOutVarSrcs().iterator(); pairItr.hasNext(); ) {
+    //  SESEandAgePair srcPair = pairItr.next();
+    //  output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+    //  output.println("   {");
+    //  output.println("     SESEcommon* src = &("+paramsprefix+"->"+srcPair+"->common);");
+    //  output.println("     RELEASE_REFERENCE_TO( src );");
+    //  output.println("   }");
+    //  output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+    //}
+
+    output.println("     // copy out-set from dynamic sources");
+    tempItr = fsen.getDynamicOutVarSet().iterator();
+    while( tempItr.hasNext() ) {
+      TempDescriptor temp = tempItr.next();
+      TypeDescriptor type = temp.getType();
+      
+      // go grab it from the SESE source, when the source is NULL it is
+      // this exiting task, so nothing to do!
+      output.println("   if( "+temp+"_srcSESE != NULL ) {");
+
+      output.println("     "+paramsprefix+
+                    "->"+temp.getSafeSymbol()+
+                    " =  (void*)"+
+                    temp+"_srcSESE + "+
+                    temp+"_srcOffset;");
+
+      //output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+      //output.println("     SESEcommon* src = "+paramsprefix+"->"+temp+"_srcSESE;");
+      //output.println("     RELEASE_REFERENCE_TO( src );");
+      //output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+      
+      output.println("   }");
+    }
+    
+
+
     
     // mark yourself done, your task data is now read-only
     output.println("   runningSESE->doneExecuting = TRUE;");
index a4fc775326e31485c8da7eb0ddc0b08d8f2c6b1a..688f23d1fd96e30b53f19dd9d051eb1efe124c30 100644 (file)
@@ -56,14 +56,27 @@ public class FlatSESEEnterNode extends FlatNode {
   protected Set<TempDescriptor> inVars;
   protected Set<TempDescriptor> outVars;
 
+
+  // for in-vars, classify them by source type to drive
+  // code gen for issuing this task
   protected Set<TempDescriptor> readyInVars;
   protected Set<TempDescriptor> staticInVars;
   protected Set<TempDescriptor> dynamicInVars;  
-
   protected Set<SESEandAgePair> staticInVarSrcs;
-
   protected Hashtable<TempDescriptor, VariableSourceToken> staticInVar2src;
 
+  // for out-vars, classify them by source type to drive
+  // code gen for when this task exits: if the exiting task
+  // has to assume the values from any of its children, it needs
+  // to know how to acquire those values before it can truly exit
+  protected Set<TempDescriptor> readyOutVars;
+  protected Set<TempDescriptor> staticOutVars;
+  protected Set<TempDescriptor> dynamicOutVars;  
+  protected Set<SESEandAgePair> staticOutVarSrcs;
+  protected Hashtable<TempDescriptor, VariableSourceToken> staticOutVar2src;
+
+
+
   // get the oldest age of this task that other contexts
   // have a static name for when tracking variables
   protected Integer oldestAgeToTrack;
@@ -106,9 +119,14 @@ public class FlatSESEEnterNode extends FlatNode {
     staticInVars         = new HashSet<TempDescriptor>();
     dynamicInVars        = new HashSet<TempDescriptor>();
     staticInVarSrcs      = new HashSet<SESEandAgePair>();
+    readyOutVars         = new HashSet<TempDescriptor>();
+    staticOutVars        = new HashSet<TempDescriptor>();
+    dynamicOutVars       = new HashSet<TempDescriptor>();
+    staticOutVarSrcs     = new HashSet<SESEandAgePair>();
     oldestAgeToTrack     = new Integer( 0 );
 
-    staticInVar2src = new Hashtable<TempDescriptor, VariableSourceToken>();
+    staticInVar2src  = new Hashtable<TempDescriptor, VariableSourceToken>();
+    staticOutVar2src = new Hashtable<TempDescriptor, VariableSourceToken>();
 
     inVarsForDynamicCoarseConflictResolution = new Vector<TempDescriptor>();
     
@@ -346,6 +364,51 @@ public class FlatSESEEnterNode extends FlatNode {
   }
 
 
+
+  public void addReadyOutVar( TempDescriptor td ) {
+    readyOutVars.add( td );
+  }
+
+  public Set<TempDescriptor> getReadyOutVarSet() {
+    return readyOutVars;
+  }
+
+  public void addStaticOutVarSrc( SESEandAgePair p ) {
+    staticOutVarSrcs.add( p );
+  }
+
+  public Set<SESEandAgePair> getStaticOutVarSrcs() {
+    return staticOutVarSrcs;
+  }
+
+  public void addStaticOutVar( TempDescriptor td ) {
+    staticOutVars.add( td );
+  }
+
+  public Set<TempDescriptor> getStaticOutVarSet() {
+    return staticOutVars;
+  }
+
+  public void putStaticOutVar2src( TempDescriptor staticOutVar,
+                                 VariableSourceToken vst ) {
+    staticOutVar2src.put( staticOutVar, vst );
+  }
+
+  public VariableSourceToken getStaticOutVarSrc( TempDescriptor staticOutVar ) {
+    return staticOutVar2src.get( staticOutVar );
+  }
+
+  public void addDynamicOutVar( TempDescriptor td ) {
+    dynamicOutVars.add( td );
+  }
+
+  public Set<TempDescriptor> getDynamicOutVarSet() {
+    return dynamicOutVars;
+  }
+
+
+
+
   public void setfmEnclosing( FlatMethod fm ) { fmEnclosing = fm; }
   public FlatMethod getfmEnclosing() { return fmEnclosing; }