}
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();) {
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;
}
}
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+");");
#ifdef SANDBOX
abortenabled=0;
#endif
- TRANSWRAP(numTransCommit++;);
int softaborted=0;
do {
/* Look through all the objects in the transaction hash table */
/* 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; \
} \
}
continue; \
}
#define ARRAYCHECK \
- if (transao->arrayversion!=mainao->arrayversion) \
- ABORT
+ if (transao->arrayversion!=mainao->arrayversion) { \
+ ABORT;}
#else
#define QUICKCHECK
#define ARRAYCHECK
/* 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));
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
#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
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));
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));
#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
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;
}
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;"
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))) {
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
echo -help help
}
+tmpbuilddirectory="tmpbuilddirectory"
SANDBOX=false;
ABORTREADERS=false;
ROBUSTROOT=~/research/Robust/src
then
ROBUSTROOT="$2"
shift
+elif [[ $1 = '-builddir' ]]
+then
+tmpbuilddirectory="$2"
+shift
elif [[ $1 = '-nojava' ]]
then
NOJAVA=true
shift
done
-BUILDDIR="$CURDIR/tmpbuilddirectory"
+BUILDDIR="$CURDIR/$tmpbuilddirectory"
cd $1
cd $CURDIR
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
cp ../Tilera/Runtime/*.c ./
cp ../Tilera/Runtime/*.h ./
cp ../Tilera/lib/* ./
-cp ../tmpbuilddirectory/*.c ./
-cp ../tmpbuilddirectory/*.h ./
+cp ../$tmpbuilddirectory/*.c ./
+cp ../$tmpbuilddirectory/*.h ./
make
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"
if $OPTIONALFLAG
then
EXTRAOPTIONS="$EXTRAOPTIONS -DOPTIONAL"
-FILES="$FILES tmpbuilddirectory/optionalarrays.c"
+FILES="$FILES $tmpbuilddirectory/optionalarrays.c"
fi
if $THREADFLAG
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