From 0c425f3bc39aeecf711b073b568662cb9776a9f1 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 6 Nov 2009 10:53:48 +0000 Subject: [PATCH] enough bugs for tonight --- .../Analysis/Locality/DiscoverConflicts.java | 7 ++-- Robust/src/IR/Flat/BuildCode.java | 3 +- Robust/src/Runtime/STM/commit.c | 41 ++++++++++++++----- Robust/src/Runtime/STM/inlinestm.h | 7 +++- Robust/src/Runtime/STM/stmlock.h | 20 ++++----- Robust/src/buildscript | 26 +++++++----- 6 files changed, 66 insertions(+), 38 deletions(-) diff --git a/Robust/src/Analysis/Locality/DiscoverConflicts.java b/Robust/src/Analysis/Locality/DiscoverConflicts.java index 1d32d9f7..22d55e90 100644 --- a/Robust/src/Analysis/Locality/DiscoverConflicts.java +++ b/Robust/src/Analysis/Locality/DiscoverConflicts.java @@ -123,7 +123,8 @@ public class DiscoverConflicts { } private void computeneedsarrayget(LocalityBinding lb, Hashtable>> fnmap) { - Set writeset=(state.READSET&&gft!=null)?twritemap.get(lb):treadmap.get(lb); + // Set gwriteset=(state.READSET&&gft!=null)?twritemap.get(lb):treadmap.get(lb); + Set gwriteset=treadmap.get(lb); FlatMethod fm=state.getMethodFlat(lb.getMethod()); HashSet needsget=new HashSet(); for(Iterator fnit=fm.getNodeSet().iterator();fnit.hasNext();) { @@ -135,8 +136,8 @@ public class DiscoverConflicts { if (tfpset!=null) { for(Iterator 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; } } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index ea95749a..9894e983 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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+");"); diff --git a/Robust/src/Runtime/STM/commit.c b/Robust/src/Runtime/STM/commit.c index a0aa9f68..bd467152 100644 --- a/Robust/src/Runtime/STM/commit.c +++ b/Robust/src/Runtime/STM/commit.c @@ -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])->typelock>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->typelock>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->typelock==(RW_LOCK_BIAS-1))) { #else { #endif @@ -934,7 +943,12 @@ int alttraverseCache() { for(i=0; ilock>0)) { +#if defined(STMARRAY)&&defined(DUALVIEW) + unsigned int isobject=((struct ___Object___ *)&header[1])->typelock>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->typelock>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->typelock==(RW_LOCK_BIAS-1))) { #else { #endif diff --git a/Robust/src/Runtime/STM/inlinestm.h b/Robust/src/Runtime/STM/inlinestm.h index d2f6041f..050fbbcf 100644 --- a/Robust/src/Runtime/STM/inlinestm.h +++ b/Robust/src/Runtime/STM/inlinestm.h @@ -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->typelock>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; } diff --git a/Robust/src/Runtime/STM/stmlock.h b/Robust/src/Runtime/STM/stmlock.h index d75d3f21..d74d2e37 100644 --- a/Robust/src/Runtime/STM/stmlock.h +++ b/Robust/src/Runtime/STM/stmlock.h @@ -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))) { diff --git a/Robust/src/buildscript b/Robust/src/buildscript index b9b079e4..f6bbdeb3 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -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 -- 2.34.1