more changes towards new version of oooJava
authorbdemsky <bdemsky>
Mon, 18 Oct 2010 06:48:46 +0000 (06:48 +0000)
committerbdemsky <bdemsky>
Mon, 18 Oct 2010 06:48:46 +0000 (06:48 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/RuntimeConflictResolver.java
Robust/src/Runtime/oooJava/Queue_RCR.c
Robust/src/Runtime/oooJava/hashStructure.c
Robust/src/Runtime/oooJava/hashStructure.h
Robust/src/Runtime/oooJava/rcr_runtime.c
Robust/src/Runtime/oooJava/rcr_runtime.h
Robust/src/Runtime/oooJava/trqueue.c
Robust/src/Runtime/oooJava/trqueue.h

index 97f2eb30c877f828a0851c1ad3341bd99fde4ab3..7979db02f3d57bc999d2b6ab69e13a88612cb446 100644 (file)
@@ -620,8 +620,10 @@ public class BuildCode {
       outmethod.println("#include \"mlp_runtime.h\"");
       outmethod.println("#include \"psemaphore.h\"");
       
-      if( state.RCR && rcr != null) {
+      if( state.RCR ) {
+        outmethod.println("#include \"trqueue.h\"");
         outmethod.println("#include \"RuntimeConflictResolver.h\"");
+        outmethod.println("#include \"rcr_runtime.h\"");
       }
     }
 
@@ -2200,7 +2202,8 @@ public class BuildCode {
     }
 
     if (state.RCR) {
-      outputStructs.println("struct rcrRecord rcrRecords["+inset.size()+"];");
+      if (inset.size()!=0)
+       outputStructs.println("struct rcrRecord rcrRecords["+inset.size()+"];");
     }
     
     if( fsen.getFirstDepRecField() != null ) {
@@ -3072,7 +3075,7 @@ public class BuildCode {
               for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
                 Analysis.OoOJava.WaitingElement waitingElement = (Analysis.OoOJava.WaitingElement) iterator.next();
                 
-                if(state.RCR && rcr != null){
+                if(state.RCR{
                   Analysis.OoOJava.ConflictGraph conflictGraph = graph;
                   Hashtable<Taint, Set<Effect>> conflicts;
                   ReachGraph rg = oooa.getDisjointAnalysis().getReachGraph(currentSESE.getmdEnclosing());
@@ -3108,7 +3111,7 @@ public class BuildCode {
                 }
                 output.println("     }  ");
                 
-                if(state.RCR && rcr != null) {
+                if(state.RCR) {
                   output.println("   "+rcr.getTraverserInvocation(waitingElement.getTempDesc(), 
                       generateTemp(fm, waitingElement.getTempDesc(), null), fn));
                 }
@@ -3769,7 +3772,7 @@ public class BuildCode {
                      );
     }
     
-    if (state.RCR) {
+    if (state.RCR&&fsen.getInVarsForDynamicCoarseConflictResolution().size()>0) {
       output.println("    seseToIssue->common.offsetToParamRecords=(INTPTR)sizeof("+fsen.getSESErecordName()+") - (INTPTR) & ((("+fsen.getSESErecordName()+"*)0)->rcrRecords);");
     }
 
@@ -4180,10 +4183,10 @@ public class BuildCode {
       output.println("     CP_LOGEVENT( CP_EVENTID_PREPAREMEMQ, CP_EVENTTYPE_END );");
       output.println("#endif");
     }
-    
+
     // Enqueue Task Record
     if (state.RCR) {
-      output.println("    enqueueTR((void *)seseToIssue);");
+      output.println("    enqueueTR(TRqueue, (void *)seseToIssue);");
     }
 
     // if there were no outstanding dependencies, issue here
index af403d97bb0d156d086e1292be7db3ad4d8be5ef..e87b4377c572e0e0f2e3c4e684b085d00e1d2344 100644 (file)
@@ -78,6 +78,8 @@ public class RuntimeConflictResolver {
     cFile.println("#include \"" + hashAndQueueCFileDir + "hashRCR.h\"\n#include \""
         + hashAndQueueCFileDir + "Queue_RCR.h\"\n#include <stdlib.h>");
     cFile.println("#include \"classdefs.h\"");
+    cFile.println("#include \"structdefs.h\"");
+    cFile.println("#include \"mlp_runtime.h\"");
     cFile.println("#include \"RuntimeConflictResolver.h\"");
     cFile.println("#include \"hashStructure.h\"");
     
@@ -252,6 +254,7 @@ public class RuntimeConflictResolver {
     //Prints out the master traverser Invocation that'll call all other traverser
     //based on traverserID
     printMasterTraverserInvocation();
+    printResumeTraverserInvocation();
     
     //TODO this is only temporary, remove when thread local vars implemented. 
     createMasterHashTableArray();
@@ -305,8 +308,8 @@ public class RuntimeConflictResolver {
   }
 
   private void printMasterTraverserInvocation() {
-    headerFile.println("\nint traverse(SESECommon * record);");
-    cFile.println("\nint traverse(SESECommon * record) {");
+    headerFile.println("\nint tasktraverse(SESEcommon * record);");
+    cFile.println("\nint tasktraverse(SESEcommon * record) {");
     cFile.println("  switch(record->classID) {");
     
     for(Iterator<FlatSESEEnterNode> seseit=oooa.getAllSESEs().iterator();seseit.hasNext();) {
@@ -332,7 +335,7 @@ public class RuntimeConflictResolver {
 
   //This will print the traverser invocation that takes in a traverserID and 
   //starting ptr
-  private void printAltMasterTraverserInvocation() {
+  private void printResumeTraverserInvocation() {
     headerFile.println("\nint traverse(void * startingPtr, int traverserID);");
     cFile.println("\nint traverse(void * startingPtr, int traverserID) {");
     cFile.println(" switch(traverserID) {");
index f9449b0a2c5434d075940e6c81cca06e12890cd0..ae8f197cf3fcefd7aacdf0208a1d026c14a5c4d0 100644 (file)
@@ -34,7 +34,7 @@ void * dequeueRCRQueue() {
   tail++;
   if(tail & SIZE)
     tail =  0;
-  myRXRQueue.tail=tail;
+  myRCRQueue.tail=tail;
   return ptr;
 }
 
index 91588c60f0e25f86c60a63ef3f312ec47f16d00d..71348090ff6a8f00a2ac67eb642fbcf37791a6c2 100644 (file)
@@ -14,7 +14,7 @@ void rcr_createMasterHashTableArray(int maxSize){
 HashStructure* rcr_createHashtable(int sizeofWaitingQueue){
   int i=0;
   HashStructure* newTable=(HashStructure*)RUNMALLOC(sizeof(HashStructure));
-  for(i=0;i<NUMBINS;i++){
+  for(i=0;i<RNUMBINS;i++){
     newTable->array[i].head=NULL;
     newTable->array[i].tail=NULL;
   }
@@ -45,7 +45,7 @@ int rcr_isWriteBinItem(BinItem_rcr* b){
 }
 
 inline int rcr_generateKey(void * ptr){
-  return (((struct genericObjectStruct *) ptr)->oid)&H_MASK;
+  return (((struct genericObjectStruct *) ptr)->oid)&RH_MASK;
 }
 
 int rcr_WRITEBINCASE(HashStructure *T, void *ptr, int traverserID, SESEcommon *task, void *heaproot) {
@@ -194,7 +194,7 @@ int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr
     retval=NOTREADY;
   }
 
-  if (readbintail->index==NUMREAD) { // create new read group
+  if (readbintail->index==RNUMREAD) { // create new read group
     ReadBinItem_rcr* rb=rcr_createReadBinItem();
     td = &rb->array[rb->index++];
 
index 5b200e1fb3ebac46fe1543157f47435d5d13524f..67716af6edaa4670386648d3a62ba404a4bb1b86 100644 (file)
 #define TRUE 1\r
 #define FALSE 0\r
 \r
-#define NUMBINS 64\r
-#define NUMREAD 64\r
-#define NUMRENTRY 256\r
-#define H_MASK (NUMBINS<<4)-1\r
+#define RNUMBINS 64\r
+#define RNUMREAD 64\r
+#define RNUMRENTRY 256\r
+#define RH_MASK (RNUMBINS<<4)-1\r
 \r
 //Note: put resolved things at the end and unresolved at the front.\r
 typedef struct BinItem_rcr {\r
@@ -64,7 +64,7 @@ typedef struct BinElement_rcr {
 \r
 \r
 typedef struct Hashtable_rcr {\r
-  BinElement_rcr array[NUMBINS];\r
+  BinElement_rcr array[RNUMBINS];\r
   WaitingQueueBin * waitingQueue;\r
 } HashStructure;\r
 \r
@@ -89,7 +89,7 @@ typedef struct WriteBinItem_rcr {
 \r
 typedef struct ReadBinItem_rcr {\r
   BinItem_rcr item;\r
-  TraverserData array[NUMREAD];\r
+  TraverserData array[RNUMREAD];\r
   //We don't need a head index since if the item before it was freed, then all these would be considered ready as well.\r
   int index;\r
   \r
index cbf4e06b1280fea11f1640f834f4a79368933f01..fb98c8482a193f35703baa0749786436a8b6e959 100644 (file)
@@ -1,12 +1,15 @@
+#include "trqueue.h"
 #include "rcr_runtime.h"
 #include "mlp_runtime.h"
 
+__thread struct trQueue * TRqueue;
+
 void workerTR(void *x) {
   struct trQueue * queue=(struct trQueue *)x;
-  while(true) {
+  while(1) {
     SESEcommon * tmp;
     do {
-      tmp=(SESEcommon *) dequeueTR(TRqueue);
+      tmp=(SESEcommon *) dequeueTR(queue);
       if (tmp!=NULL)
        break;
       sched_yield();
index fe5b478243df7299b00589b5e6d7735d695b6e15..234440d3891bac812c138ab4900b5e4d7fea6b5b 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef RCR_RUNTIME_H
 #define RCR_RUNTIME_H
 
-extern __thread struct trqueue * TRqueue;
+extern __thread struct trQueue * TRqueue;
 
 void workerTR(void *);
 
index d58a33f134400dce97f6492e9ca500b9799c955a..852c48ae4e5dc648677d56d2b8b203f8e5a51785 100644 (file)
@@ -1,12 +1,13 @@
 #include "trqueue.h"
 #include "stdlib.h"
 #include "stdio.h"
+#include "mlp_lock.h"
 
 //0 would mean sucess
 //1 would mean fail
 //since if we reach SIZE, we will stop operation, it doesn't matter
 //that we overwrite the element in the queue
-void enqueueTR(trQueue *q, void * ptr) {
+void enqueueTR(struct trQueue *q, void * ptr) {
   unsigned int head=q->head+1;
   if (head&TRSIZE)
     head=0;
@@ -17,10 +18,9 @@ void enqueueTR(trQueue *q, void * ptr) {
   q->elements[head] = ptr;
   BARRIER();
   q->head=head;
-  return 0;
 }
 
-void * dequeueTR(trQueue *q) {
+void * dequeueTR(struct trQueue *q) {
   unsigned int tail=q->tail;
   if(q->head==tail)
     return NULL;
index c1f83c2e589490dd0d57531160460ce9cec8377d..28f974996c57112ab9966b3954aa2ce52a4ee714 100644 (file)
@@ -3,10 +3,10 @@
 
 //NOTE: SIZE MUST BE A POWER OF TWO;
 //SIZE is used as mask to check overflow
-#define SIZE 16384
+#define TRSIZE 16384
 
 struct trQueue {
-  void * elements[SIZE];
+  void * elements[TRSIZE];
   volatile unsigned int head;
   char buffer[60];//buffer us to the next cache line
   volatile unsigned int tail;