put together parts of DFJ that assumed we did not know the interprocedural parent...
authorjjenista <jjenista>
Fri, 11 Mar 2011 22:15:56 +0000 (22:15 +0000)
committerjjenista <jjenista>
Fri, 11 Mar 2011 22:15:56 +0000 (22:15 +0000)
Robust/src/IR/Flat/BuildOoOJavaCode.java
Robust/src/Tests/dfj/case3/makefile

index 4377493ad4f8cc836c5258bc4fc2dda027e40c4d..eebfa3087eb5ac672ff6cbc42d3ec0b48c1412c4 100644 (file)
@@ -1042,6 +1042,8 @@ public class BuildOoOJavaCode extends BuildCode {
           continue;
         }
 
+        // TODO: THIS STRATEGY CAN BE OPTIMIZED EVEN FURTHER, IF THERE
+        // IS EXACTLY ONE CASE, DON'T GENERATE A SWITCH AT ALL
         if( atLeastOneCase == false ) {
           atLeastOneCase = true;
           output.println("   // potential stall site ");      
@@ -1546,113 +1548,126 @@ public class BuildOoOJavaCode extends BuildCode {
 
 
   void dispatchMEMRC( FlatMethod        fm,  
-                      FlatSESEEnterNode fsen
+                      FlatSESEEnterNode newChild
                       PrintWriter       output ) {
-    // NEED TO FIX IT, TODO
-    // assumes that there is only one parent, but it is possible that
-    // currentSESE has more than one so we need to generate
-    // conditional case for each parent case        
-
-    assert false; // FIX THIS TO UNDERSTAND NO PLACEHOLDER TASKS!!!
-
-    assert fsen.getParents().size()>0;
-    FlatSESEEnterNode parent =  fsen.getParents().iterator().next();
-    ConflictGraph graph = oooa.getConflictGraph(parent);
-    if (graph != null && graph.hasConflictEdge()) {
-      Set<SESELock> seseLockSet = oooa.getLockMappings(graph);
-      SESEWaitingQueue seseWaitingQueue=graph.getWaitingElementSetBySESEID(fsen.getIdentifier(), seseLockSet);
-      if(seseWaitingQueue.getWaitingElementSize()>0) {
-       output.println("     {");
-       output.println("       REntry* rentry=NULL;");
-       output.println("       INTPTR* pointer=NULL;");
-       output.println("       seseToIssue->common.rentryIdx=0;");
-       Vector<TempDescriptor> invars=fsen.getInVarsForDynamicCoarseConflictResolution();
-       System.out.println(fm.getMethod()+"["+invars+"]");
+
+    // what we need to do here is create RCR records for the
+    // new task and insert it into the appropriate parent queues
+    assert newChild.getParents().size() > 0;
+
+    output.println("     switch( seseToIssue->common.classID ) {");
+
+    Iterator<FlatSESEEnterNode> pItr = newChild.getParents().iterator();
+    while( pItr.hasNext() ) {
+
+      FlatSESEEnterNode parent = pItr.next();
+      ConflictGraph     graph  = oooa.getConflictGraph( parent );
+
+      if( graph != null && graph.hasConflictEdge() ) {
+        Set<SESELock> seseLockSet = oooa.getLockMappings(graph);
+        SESEWaitingQueue seseWaitingQueue=graph.getWaitingElementSetBySESEID(newChild.getIdentifier(), seseLockSet);
+        if(seseWaitingQueue.getWaitingElementSize()>0) {
+
+          output.println("       /* "+parent.getPrettyIdentifier()+" */");
+          output.println("       case "+parent.getIdentifier()+": {");
+
+          output.println("         REntry* rentry=NULL;");
+          output.println("         INTPTR* pointer=NULL;");
+          output.println("         seseToIssue->common.rentryIdx=0;");
+          Vector<TempDescriptor> invars=newChild.getInVarsForDynamicCoarseConflictResolution();
+          //System.out.println(fm.getMethod()+"["+invars+"]");
        
-       Vector<Long> queuetovar=new Vector<Long>();
-
-       for(int i=0;i<invars.size();i++) {
-         TempDescriptor td=invars.get(i);
-         Set<WaitingElement> weset=seseWaitingQueue.getWaitingElementSet(td);
-         int numqueues=0;
-         Set<Integer> queueSet=new HashSet<Integer>();
-         for (Iterator iterator = weset.iterator(); iterator.hasNext();) {
-           WaitingElement  we = (WaitingElement) iterator.next();
-           Integer queueID=new Integer( we.getQueueID());
-           if(!queueSet.contains(queueID)){
-             numqueues++;
-             queueSet.add(queueID);
-           }      
-          }
+          Vector<Long> queuetovar=new Vector<Long>();
+
+          for(int i=0;i<invars.size();i++) {
+            TempDescriptor td=invars.get(i);
+            Set<WaitingElement> weset=seseWaitingQueue.getWaitingElementSet(td);
+            int numqueues=0;
+            Set<Integer> queueSet=new HashSet<Integer>();
+            for (Iterator iterator = weset.iterator(); iterator.hasNext();) {
+              WaitingElement  we = (WaitingElement) iterator.next();
+              Integer queueID=new Integer( we.getQueueID());
+              if(!queueSet.contains(queueID)){
+                numqueues++;
+                queueSet.add(queueID);
+              }           
+            }
 
-          output.println("      seseToIssue->rcrRecords["+i+"].flag="+numqueues+";");
-          output.println("      seseToIssue->rcrRecords["+i+"].index=0;");
-          output.println("      seseToIssue->rcrRecords["+i+"].next=NULL;");
-          output.println("      int dispCount"+i+"=0;");
-
-          for (Iterator<WaitingElement> wtit = weset.iterator(); wtit.hasNext();) {
-            WaitingElement waitingElement = wtit.next();
-            int queueID = waitingElement.getQueueID();
-            if (queueID >= queuetovar.size())
-              queuetovar.setSize(queueID + 1);
-            Long l = queuetovar.get(queueID);
-            long val = (l != null) ? l.longValue() : 0;
-            val = val | (1 << i);
-            queuetovar.set(queueID, new Long(val));
+            output.println("        seseToIssue->rcrRecords["+i+"].flag="+numqueues+";");
+            output.println("        seseToIssue->rcrRecords["+i+"].index=0;");
+            output.println("        seseToIssue->rcrRecords["+i+"].next=NULL;");
+            output.println("        int dispCount"+i+"=0;");
+
+            for (Iterator<WaitingElement> wtit = weset.iterator(); wtit.hasNext();) {
+              WaitingElement waitingElement = wtit.next();
+              int queueID = waitingElement.getQueueID();
+              if (queueID >= queuetovar.size())
+                queuetovar.setSize(queueID + 1);
+              Long l = queuetovar.get(queueID);
+              long val = (l != null) ? l.longValue() : 0;
+              val = val | (1 << i);
+              queuetovar.set(queueID, new Long(val));
+            }
           }
-       }
 
-       HashSet generatedqueueentry=new HashSet();
-       for(int i=0;i<invars.size();i++) {
-         TempDescriptor td=invars.get(i);
-         Set<WaitingElement> weset=seseWaitingQueue.getWaitingElementSet(td);
-         for(Iterator<WaitingElement> wtit=weset.iterator();wtit.hasNext();) {
-           WaitingElement waitingElement=wtit.next();
-           int queueID=waitingElement.getQueueID();
+          HashSet generatedqueueentry=new HashSet();
+          for(int i=0;i<invars.size();i++) {
+            TempDescriptor td=invars.get(i);
+            Set<WaitingElement> weset=seseWaitingQueue.getWaitingElementSet(td);
+            for(Iterator<WaitingElement> wtit=weset.iterator();wtit.hasNext();) {
+              WaitingElement waitingElement=wtit.next();
+              int queueID=waitingElement.getQueueID();
            
-           if(waitingElement.isBogus()){
-             continue;
-           }
-           
-           if (generatedqueueentry.contains(queueID))
-             continue;
-           else 
-             generatedqueueentry.add(queueID);
-
-           assert(waitingElement.getStatus()>=ConflictNode.COARSE);
-           long mask=queuetovar.get(queueID);
-           output.println("       rentry=mlpCreateREntry(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "]," + waitingElement.getStatus() + ", &(seseToIssue->common), "+mask+"LL);");
-           output.println("       rentry->count=2;");
-           output.println("       seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;");
-           output.println("       rentry->queue=runningSESE->memoryQueueArray[" + waitingElement.getQueueID()+"];");
+              if(waitingElement.isBogus()){
+                continue;
+              }
            
-           output.println("       if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "],rentry)==READY) {");
-           for(int j=0;mask!=0;j++) {
-             if ((mask&1)==1)
-               output.println("          dispCount"+j+"++;");
-             mask=mask>>1;
-           }
-           output.println("       } else ");
-           output.println("         refCount--;");
-
+              if (generatedqueueentry.contains(queueID))
+                continue;
+              else 
+                generatedqueueentry.add(queueID);
+              
+              assert(waitingElement.getStatus()>=ConflictNode.COARSE);
+              long mask=queuetovar.get(queueID);
+              output.println("         rentry=mlpCreateREntry(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "]," + waitingElement.getStatus() + ", &(seseToIssue->common), "+mask+"LL);");
+              output.println("         rentry->count=2;");
+              output.println("         seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;");
+              output.println("         rentry->queue=runningSESE->memoryQueueArray[" + waitingElement.getQueueID()+"];");
+                               
+              output.println("         if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "],rentry)==READY) {");
+              for(int j=0;mask!=0;j++) {
+                if ((mask&1)==1)
+                  output.println("            dispCount"+j+"++;");
+                mask=mask>>1;
+              }
+              output.println("         } else ");
+              output.println("           refCount--;");
          }
 
-         if (fsen.getDynamicInVarSet().contains(td)) {
-           // dynamic in-var case
-           //output.println("       pointer=seseToIssue->"+waitingElement.getDynID()+ 
-            //               "_srcSESE+seseToIssue->"+waitingElement.getDynID()+ 
-            //               "_srcOffset;");
-           //output.println("       rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+
-            //               ", &(seseToIssue->common),  pointer );");
-         }
-       }
-       for(int i=0;i<invars.size();i++) {
-         output.println("     if(!dispCount"+i+" || !atomic_sub_and_test(dispCount"+i+",&(seseToIssue->rcrRecords["+i+"].flag)))");
-         output.println("       localCount++;");
-       }
-       output.println("    }");
+            if (newChild.getDynamicInVarSet().contains(td)) {
+              // dynamic in-var case
+              //output.println("       pointer=seseToIssue->"+waitingElement.getDynID()+ 
+              //               "_srcSESE+seseToIssue->"+waitingElement.getDynID()+ 
+              //               "_srcOffset;");
+              //output.println("       rentry=mlpCreateFineREntry("+ waitingElement.getStatus()+
+              //               ", &(seseToIssue->common),  pointer );");
+            }
+          }
+          for(int i=0;i<invars.size();i++) {
+            output.println("       if(!dispCount"+i+" || !atomic_sub_and_test(dispCount"+i+",&(seseToIssue->rcrRecords["+i+"].flag)))");
+            output.println("         localCount++;");
+          }
+          output.println("      }");
+        }
       }
     }
+
+    output.println("       default: {");
+    output.println("         printf(\"Error: unknown SESE class ID in dispatchMEMRC.\\n\");");
+    output.println("         exit( -1 );");
+    output.println("       }");
+    output.println("     } // end switch");
+
     output.println("#ifndef OOO_DISABLE_TASKMEMPOOL");
     output.println("  RELEASE_REFERENCES_TO((SESEcommon *)seseToIssue, refCount);");
     output.println("#endif");
index dd02a9f3826f3d5fb619ff9216fba5a0fe617c3e..513d614e442a76d1b5cbbdc463265633594383b2 100644 (file)
@@ -25,7 +25,7 @@ DISJOINT= -disjoint -disjoint-k 1 -enable-assertions #-disjoint-desire-determini
 USEOOO= -ooojava 24 2      -ooodebug -squeue
 USERCR= -ooojava 23 2 -rcr -ooodebug -squeue 
 
-BSFLAGS= -mainclass $(PROGRAM) -heapsize-mb 1024 -garbagestats -noloop -joptimize -debug #-ooodebug-disable-task-mem-pool -64bit -justanalyze
+BSFLAGS= -64bit -mainclass $(PROGRAM) -heapsize-mb 1024 -garbagestats -noloop -joptimize -debug #-ooodebug-disable-task-mem-pool -justanalyze
 
 
 all: ooo