slightly better locks for stm...
authorbdemsky <bdemsky>
Thu, 14 May 2009 01:06:14 +0000 (01:06 +0000)
committerbdemsky <bdemsky>
Thu, 14 May 2009 01:06:14 +0000 (01:06 +0000)
Robust/src/Benchmarks/SingleTM/KMeans/makefile
Robust/src/Runtime/STM/stm.c
Robust/src/Runtime/STM/stmlock.c [new file with mode: 0644]
Robust/src/Runtime/STM/stmlock.h [new file with mode: 0644]
Robust/src/Runtime/STM/tm.h
Robust/src/buildscript

index 0c035dd0e56b8baf4eae3325a6b1298645aba803..920e129816bd5b8c73182e13c16814af3ce03349 100644 (file)
@@ -6,13 +6,15 @@ SRC=${MAINCLASS}.java \
     Common.java \
     GlobalArgs.java \
     ../../../ClassLibrary/JavaSTM/Barrier.java
-FLAGS=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -joptimize -fastmemcpy -garbagestats
-FLAGS2=-mainclass ${MAINCLASS} -optimize -debug -joptimize -thread
+FLAGS=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -joptimize -transstats -stmstats
+FLAGS2=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -joptimize -transstats
+FLAGS3=-mainclass ${MAINCLASS} -optimize -debug -joptimize -thread
 
 
 default:
        ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
-       ../../../buildscript ${FLAGS2} -o NON${MAINCLASS} ${SRC}
+       ../../../buildscript ${FLAGS3} -o LOCK${MAINCLASS} ${SRC}
+       ../../../buildscript ${FLAGS2} -o GEN${MAINCLASS} ${SRC}
 
 clean:
        rm -rf tmpbuilddirectory
index a4b57e548d0a853db56ef827a229b662666a8830..8a3173db2497101f74d2b0fe106b83a687d457a4 100644 (file)
@@ -341,7 +341,8 @@ int transCommit() {
       nSoftAbort++;
 #endif
       softaborted++;
-      if (softaborted>4) {
+      if (1) {
+       //if (softaborted>1) {
        //retry if too many soft aborts
        freenewobjs();
 #ifdef STMSTATS
@@ -351,7 +352,7 @@ int transCommit() {
        t_chashreset();
        return TRANS_ABORT;
       }
-      randomdelay(softaborted);
+      //randomdelay(softaborted);
     } else {
       printf("Error: in %s() Unknown outcome", __func__);
       exit(-1);
diff --git a/Robust/src/Runtime/STM/stmlock.c b/Robust/src/Runtime/STM/stmlock.c
new file mode 100644 (file)
index 0000000..ee52ba5
--- /dev/null
@@ -0,0 +1,20 @@
+#include "stmlock.h"
+#include <stdio.h>
+
+inline void initdsmlocks(volatile unsigned int *addr) {
+  (*addr) = RW_LOCK_BIAS;
+}
+
+int write_trylock(volatile unsigned int *lock) {
+  int retval=0;
+  __asm__ __volatile__("xchgl %0,%1"
+              : "=r"(retval)
+              : "m"(*__xg(lock)), "0"(retval)
+              : "memory");
+  return retval;
+}
+
+void write_unlock(volatile unsigned int *lock) {
+  __asm __volatile__("movl $1, %0" : "+m" (*__xg(lock))::"memory");
+}
+
diff --git a/Robust/src/Runtime/STM/stmlock.h b/Robust/src/Runtime/STM/stmlock.h
new file mode 100644 (file)
index 0000000..cbb2c41
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _STMLOCK_H_
+#define _STMLOCK_H_
+
+#define RW_LOCK_BIAS                 1
+#define LOCK_UNLOCKED          { LOCK_BIAS }
+
+struct __xchg_dummy {
+       unsigned long a[100];
+};
+
+#define __xg(x) ((struct __xchg_dummy *)(x))
+
+void initdsmlocks(volatile unsigned int *addr);
+int write_trylock(volatile unsigned int *lock);
+void write_unlock(volatile unsigned int *lock);
+
+#endif
index 9df9b74a4775750360b21fb24de09e8fa64a1de6..b6995f308506f0346e67905f0ed2212e5c99766c 100644 (file)
@@ -21,7 +21,7 @@
 #include <sys/time.h>
 #include <errno.h>
 #include "stmlookup.h"
-#include "dsmlock.h"
+#include "stmlock.h"
 
 /* ==================================
  * Bit designation for status field
index 002f4b6d50378b5ddd3797a0c98516a3d28e186f..b6c11430a96b2b73b22e142f8a5e037f703d0b34 100755 (executable)
@@ -599,7 +599,7 @@ fi
 if $SINGLETM
 then
 EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -I$DSMRUNTIME"
-FILES="$FILES $DSMRUNTIME/dsmlock.c $DSMRUNTIME/singleTMCommit.c $DSMRUNTIME/stmlookup.c $ROBUSTROOT/Runtime/thread.c"
+FILES="$FILES $DSMRUNTIME/stmlock.c $DSMRUNTIME/singleTMCommit.c $DSMRUNTIME/stmlookup.c $ROBUSTROOT/Runtime/thread.c"
 fi
 
 if $ABORTREADERS