From: bdemsky Date: Thu, 14 May 2009 01:06:14 +0000 (+0000) Subject: slightly better locks for stm... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=22d4d59cc06fb877ce4c7010245a9bcafaa85462;p=IRC.git slightly better locks for stm... --- diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/makefile b/Robust/src/Benchmarks/SingleTM/KMeans/makefile index 0c035dd0..920e1298 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/makefile +++ b/Robust/src/Benchmarks/SingleTM/KMeans/makefile @@ -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 diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index a4b57e54..8a3173db 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -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 index 00000000..ee52ba52 --- /dev/null +++ b/Robust/src/Runtime/STM/stmlock.c @@ -0,0 +1,20 @@ +#include "stmlock.h" +#include + +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 index 00000000..cbb2c41f --- /dev/null +++ b/Robust/src/Runtime/STM/stmlock.h @@ -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 diff --git a/Robust/src/Runtime/STM/tm.h b/Robust/src/Runtime/STM/tm.h index 9df9b74a..b6995f30 100644 --- a/Robust/src/Runtime/STM/tm.h +++ b/Robust/src/Runtime/STM/tm.h @@ -21,7 +21,7 @@ #include #include #include "stmlookup.h" -#include "dsmlock.h" +#include "stmlock.h" /* ================================== * Bit designation for status field diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 002f4b6d..b6c11430 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -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