enough bugs for tonight
authorbdemsky <bdemsky>
Fri, 6 Nov 2009 10:53:48 +0000 (10:53 +0000)
committerbdemsky <bdemsky>
Fri, 6 Nov 2009 10:53:48 +0000 (10:53 +0000)
Robust/src/Analysis/Locality/DiscoverConflicts.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/STM/commit.c
Robust/src/Runtime/STM/inlinestm.h
Robust/src/Runtime/STM/stmlock.h
Robust/src/buildscript

index 1d32d9f71242f24daaf031d6f873c580e61d9b46..22d55e90d04d7d22ce64a822eed8154bd851ba79 100644 (file)
@@ -123,7 +123,8 @@ public class DiscoverConflicts {
   }
   
   private void computeneedsarrayget(LocalityBinding lb, Hashtable<FlatNode, Hashtable<TempDescriptor, Set<TempFlatPair>>> fnmap) {
-    Set<FlatNode> writeset=(state.READSET&&gft!=null)?twritemap.get(lb):treadmap.get(lb);
+    //    Set<FlatNode> gwriteset=(state.READSET&&gft!=null)?twritemap.get(lb):treadmap.get(lb);
+    Set<FlatNode> gwriteset=treadmap.get(lb);
     FlatMethod fm=state.getMethodFlat(lb.getMethod());
     HashSet<FlatNode> needsget=new HashSet<FlatNode>();
     for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator();fnit.hasNext();) {
@@ -135,8 +136,8 @@ public class DiscoverConflicts {
        if (tfpset!=null) {
          for(Iterator<TempFlatPair> tfpit=tfpset.iterator();tfpit.hasNext();) {
            TempFlatPair tfp=tfpit.next();
-           if (writeset.contains(tfp.f)) {
-             needsget.add(tfp.f);
+           if (gwriteset.contains(tfp.f)) {
+             needsget.add(fen);
              break;
            }
          }
index ea95749aa90fc6a491fa0191d6aba04a69be92e1..9894e9830e54fc4ea0ca009402d5650eb49f3472 100644 (file)
@@ -3832,8 +3832,7 @@ public class BuildCode {
     if (state.SINGLETM) {
       //Single machine transaction case
       String dst=generateTemp(fm, fen.getDst(),lb);
-      if ((!state.STMARRAY)||(!wb.needBarrier(fen))||locality.getNodePreTempInfo(lb, fen).get(fen.getSrc())==LocalityAnalysis.SCRATCH||locality.getAtomic(lb).get(fen).intValue()==0||
-         (state.READSET&&!dc.getNeedGet(lb, fen))) {
+      if ((!state.STMARRAY)||(!wb.needBarrier(fen))||locality.getNodePreTempInfo(lb, fen).get(fen.getSrc())==LocalityAnalysis.SCRATCH||locality.getAtomic(lb).get(fen).intValue()==0||(state.READSET&&!dc.getNeedGet(lb, fen))) {
        output.println(dst +"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];");
       } else {
        output.println("STMGETARRAY("+dst+", "+ generateTemp(fm,fen.getSrc(),lb)+", "+generateTemp(fm, fen.getIndex(),lb)+", "+type+");");
index a0aa9f6845f5945aa4f9733a11cefde3418866de..bd467152603f92e761196b66df674c11bc7b8e76 100644 (file)
@@ -55,7 +55,6 @@ int transCommit() {
 #ifdef SANDBOX
   abortenabled=0;
 #endif
-  TRANSWRAP(numTransCommit++;);
   int softaborted=0;
   do {
     /* Look through all the objects in the transaction hash table */
@@ -302,9 +301,9 @@ int transCommit() {
 /* Try to grab object lock...If we get it, check object access
    version and abort on mismatch */
   
-#define DVGETLOCK if (!addwrobject) {                          \
+#define DVGETLOCK if (!addwrobject) {                                  \
     unsigned int * objlock=&(&((objheader_t *)mainao)[-1])->lock;      \
-    if(!rwread_trylock(objlock)) {                                     \
+    if(unlikely(!rwread_trylock(objlock))) {                           \
       ABORT;                                                           \
     }                                                                  \
 }
@@ -413,8 +412,8 @@ int transCommit() {
       continue;                                                                \
   }
 #define ARRAYCHECK                                     \
-  if (transao->arrayversion!=mainao->arrayversion)     \
-    ABORT
+  if (transao->arrayversion!=mainao->arrayversion) {   \
+    ABORT;}
 #else
 #define QUICKCHECK
 #define ARRAYCHECK
@@ -734,7 +733,12 @@ int traverseCache() {
     /* Read from the main heap  and compare versions */
     objheader_t *header=oidrdlocked[i];
     unsigned int version=oidrdversion[i];
-    if(header->lock>0) { //not write locked
+#if defined(STMARRAY)&&defined(DUALVIEW)
+    unsigned int isobject=((struct ___Object___ *)&header[1])->type<NUMCLASSES;
+    if(likely((isobject&&header->lock>0)||(!isobject&&header->lock==RW_LOCK_BIAS))) {
+#else      
+    if(likely(header->lock>0)) { //not write locked
+#endif
       CFENCE;
       if(version != header->version) { /* versions do not match */
        transAbortProcess(oidwrlocked, NUMWRTOTAL ARRAYDELAYWRAP1(dirwrindex) ARRAYDELAYWRAP1(numoidwrlocked));
@@ -777,7 +781,12 @@ int traverseCache() {
     unsigned int version=rd_curr->version;
     struct ___Object___ * objptr=rd_curr->key;
     objheader_t *header=(objheader_t *)(((char *)objptr)-sizeof(objheader_t));
-    if(header->lock>0) {
+#if defined(STMARRAY)&&defined(DUALVIEW)
+    unsigned int isobject=objptr->type<NUMCLASSES;
+    if(likely((isobject&&header->lock>0)||(!isobject&&header->lock==RW_LOCK_BIAS))) {
+#else      
+    if(likely(header->lock>0)) { //not write locked
+#endif
       //object is not write locked
       if (unlikely(version!=header->version)) {
        //have to abort
@@ -807,7 +816,7 @@ int traverseCache() {
 #endif
        //check normal table
 #ifdef STMARRAY
-      if (likely(objptr->type>=NUMCLASSES||header->lock==(RW_LOCK_BIAS-1))) {  
+      if (likely(objptr->type<NUMCLASSES||header->lock==(RW_LOCK_BIAS-1))) {   
 #else
        {
 #endif
@@ -934,7 +943,12 @@ int alttraverseCache() {
   for(i=0; i<numoidrdlocked; i++) {
     objheader_t * header=oidrdlocked[i];
     unsigned int version=oidrdversion[i];
-    if(likely(header->lock>0)) {
+#if defined(STMARRAY)&&defined(DUALVIEW)
+    unsigned int isobject=((struct ___Object___ *)&header[1])->type<NUMCLASSES;
+    if(likely((isobject&&header->lock>0)||(!isobject&&header->lock==RW_LOCK_BIAS))) {
+#else      
+    if(likely(header->lock>0)) { //not write locked
+#endif
       CFENCE;
       if(unlikely(version != header->version)) {
        transAbortProcess(oidwrlocked, NUMWRTOTAL ARRAYDELAYWRAP1(dirwrindex) ARRAYDELAYWRAP1(numoidwrlocked));
@@ -976,7 +990,12 @@ int alttraverseCache() {
     int version=rd_curr->version;
     struct ___Object___ * objptr=rd_curr->key;
     objheader_t *header=(objheader_t *)(((char *)objptr)-sizeof(objheader_t));
-    if(likely(header->lock>0)) { //object is not write locked
+#if defined(STMARRAY)&&defined(DUALVIEW)
+    unsigned int isobject=objptr->type<NUMCLASSES;
+    if(likely((isobject&&header->lock>0)||(!isobject&&header->lock==RW_LOCK_BIAS))) {
+#else      
+    if(likely(header->lock>0)) { //not write locked
+#endif
       if (unlikely(version!=header->version)) {
        //have to abort
        transAbortProcess(oidwrlocked, NUMWRTOTAL ARRAYDELAYWRAP1(dirwrindex) ARRAYDELAYWRAP1(numoidwrlocked));
@@ -1003,7 +1022,7 @@ int alttraverseCache() {
 #endif
        //check normal table
 #ifdef STMARRAY
-       if (likely(objptr->type>=NUMCLASSES||header->lock==(RW_LOCK_BIAS-1))) { 
+       if (likely(objptr->type<NUMCLASSES||header->lock==(RW_LOCK_BIAS-1))) {  
 #else
          {
 #endif
index d2f6041f311b69a2d235659ebbd580dabd3a84f2..050fbbcfe930b57e541c3df16947e523c3f82b16 100644 (file)
@@ -38,7 +38,12 @@ static inline int CHECKREADS() {
     unsigned int version=rd_curr->version;
     struct ___Object___ * objptr=rd_curr->key;
     objheader_t *header=(objheader_t *)(((char *)objptr)-sizeof(objheader_t));
-    if(likely(header->lock>0)) {//doesn't matter what type of lock...
+#if defined(STMARRAY)&&defined(DUALVIEW)
+    unsigned int isobject=objptr->type<NUMCLASSES;
+    if(likely((isobject&&header->lock>0)||(!isobject&&header->lock==RW_LOCK_BIAS))) {
+#else
+    if(likely(header->lock>0)) { //not write locked                                                 
+#endif
       if(unlikely(version!=header->version)) {
        retval=1;break;
       }
index d75d3f21b51bdba9c446b11ced61865fc59cfe51..d74d2e37d10c572eba55778a157725c7c11b4590 100644 (file)
@@ -81,7 +81,8 @@ static inline int atomic_sub_and_test(int i, volatile unsigned int *v) {
   return c;
 }
 
-static inline unsigned long cas(volatile unsigned int* ptr) {
+static inline int rwwrite_trylock(volatile unsigned int  *ptr) {
+//static inline unsigned long cas(volatile unsigned int* ptr) {
   unsigned int prev;
   __asm__ __volatile__("lock;"
                       "cmpxchgl %1, %2;"
@@ -102,16 +103,13 @@ static inline int rwread_trylock(volatile unsigned int  *lock) {
   return 0; //failure
 }
 
-static inline int rwwrite_trylock(volatile unsigned int  *lock) {
-  if (likely(cas(lock))) {
-    return 1;
-  }
-  //  if (likely(atomic_sub_and_test(RW_LOCK_BIAS, lock))) {
-  // return 1; // get a write lock
-  //}
-  atomic_add(RW_LOCK_BIAS, lock);
-  return 0; // failed to acquire a write lock
-}
+//static inline int rwwrite_trylock(volatile unsigned int  *lock) {
+//  if (likely(atomic_sub_and_test(RW_LOCK_BIAS, lock))) {
+//  return 1; // get a write lock
+//  }
+//  atomic_add(RW_LOCK_BIAS, lock);
+//  return 0; // failed to acquire a write lock
+//}
 
 static inline int rwconvert_trylock(volatile unsigned int  *lock) {
   if (likely(atomic_sub_and_test((RW_LOCK_BIAS-1), lock))) {
index b9b079e4f0ea4c3130be7e7e5c1e1b2ea9cfa2af..f6bbdeb389d16d80f18edab816a26d3f26dea539 100755 (executable)
@@ -21,6 +21,7 @@ echo -trueprob double - probabiltiy of true branch
 echo -dsmcaching -enable caching in dsm runtime
 echo
 echo Other options
+echo -builddir setup different build directory
 echo -robustroot set up the ROBUSTROOT to directory other than default one
 echo -readset turn on readset
 echo -mac distributed shared memory mac support
@@ -79,6 +80,7 @@ echo -assembly generate assembly
 echo -help help
 }
 
+tmpbuilddirectory="tmpbuilddirectory"
 SANDBOX=false;
 ABORTREADERS=false;
 ROBUSTROOT=~/research/Robust/src
@@ -157,6 +159,10 @@ elif [[ $1 = '-robustroot' ]]
 then
 ROBUSTROOT="$2"
 shift
+elif [[ $1 = '-builddir' ]]
+then
+tmpbuilddirectory="$2"
+shift
 elif [[ $1 = '-nojava' ]]
 then
 NOJAVA=true
@@ -429,7 +435,7 @@ fi
 shift
 done
 
-BUILDDIR="$CURDIR/tmpbuilddirectory"
+BUILDDIR="$CURDIR/$tmpbuilddirectory"
 
 cd $1
 cd $CURDIR
@@ -598,8 +604,8 @@ cp ../Runtime/RAW/*.c ./
 cp ../Runtime/RAW/*.h ./
 cp ../Runtime/RAW/*.S ./
 cp ../Runtime/RAW/*.s ./
-cp ../tmpbuilddirectory/*.c ./
-cp ../tmpbuilddirectory/*.h ./
+cp ../$tmpbuilddirectory/*.c ./
+cp ../$tmpbuilddirectory/*.h ./
 
 make
 
@@ -686,8 +692,8 @@ cp ../Runtime/multicorehelper.h ./
 cp ../Tilera/Runtime/*.c ./
 cp ../Tilera/Runtime/*.h ./
 cp ../Tilera/lib/* ./
-cp ../tmpbuilddirectory/*.c ./
-cp ../tmpbuilddirectory/*.h ./
+cp ../$tmpbuilddirectory/*.c ./
+cp ../$tmpbuilddirectory/*.h ./
 
 make
 
@@ -763,7 +769,7 @@ if $MULTICOREFLAG
 then
 EXTRAOPTIONS="$EXTRAOPTIONS -DMULTICORE"
 fi
-FILES="$FILES tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/checkpoint.c $ROBUSTROOT/Runtime/chash.c"
+FILES="$FILES $tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/checkpoint.c $ROBUSTROOT/Runtime/chash.c"
 if $RAWFLAG
 then
 EXTRAOPTIONS="$EXTRAOPTIONS -DRAW"
@@ -778,7 +784,7 @@ fi
 if $OPTIONALFLAG
 then
 EXTRAOPTIONS="$EXTRAOPTIONS -DOPTIONAL"
-FILES="$FILES tmpbuilddirectory/optionalarrays.c"
+FILES="$FILES $tmpbuilddirectory/optionalarrays.c"
 fi
 
 if $THREADFLAG
@@ -800,16 +806,16 @@ fi
 if $ASSEMBLY
 then
 gcc -S $INCLUDES $EXTRAOPTIONS -DPRECISE_GC \
--c tmpbuilddirectory/methods.c -lm
+-c $tmpbuilddirectory/methods.c -lm
 fi
 
 if $MULTICOREFLAG
 then
 gcc $INCLUDES $EXTRAOPTIONS \
-tmpbuilddirectory/methods.c $FILES -lm -o $MAINFILE.bin
+$tmpbuilddirectory/methods.c $FILES -lm -o $MAINFILE.bin
 else
 gcc $INCLUDES $EXTRAOPTIONS -DPRECISE_GC \
-tmpbuilddirectory/methods.c $FILES -lm -o $MAINFILE.bin
+$tmpbuilddirectory/methods.c $FILES -lm -o $MAINFILE.bin
 fi
 
 fi #!RAWFLAG