From 755f7835ad93d2f8e187535db4b86114b188de49 Mon Sep 17 00:00:00 2001 From: adash Date: Tue, 11 Aug 2009 00:14:58 +0000 Subject: [PATCH] small changes and bug fix for getting stats --- .../MicroBenchmarks/SingleObjectMod.java | 2 +- .../SingleTM/MicroBenchmarks/data.plt | 47 +++++++++++++------ .../SingleTM/MicroBenchmarks/run.sh | 10 ++-- Robust/src/Runtime/DSTM/interface/trans.c | 2 - Robust/src/Runtime/STM/stm.c | 43 +++++++++++------ Robust/src/Runtime/STM/tm.h | 7 +-- Robust/src/Runtime/thread.c | 1 + 7 files changed, 74 insertions(+), 38 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java index 7cac863a..775d0fe3 100644 --- a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java +++ b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/SingleObjectMod.java @@ -74,7 +74,7 @@ public class SingleObjectMod extends Thread { index = (int)(rand.random_generate() % arrysize); // Do computation 1 for(int j = 0; j /tmp/out -# /usr/bin/time -f "%e" -o /tmp/time ./$file $ARGS8 -o > /tmp/out +# /usr/bin/time -f "%e" -o /tmp/time ./$file $ARGS4 -o > /tmp/out + /usr/bin/time -f "%e" -o /tmp/time ./$file $ARGS8 -o > /tmp/out t=`cat /tmp/time` nTcommit=`grep TransCommit /tmp/out | awk '{print $3}'` nTabort=`grep TransAbort /tmp/out | awk '{print $3}'` diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 8e2ba01c..d59cb23a 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -657,7 +657,6 @@ plistnode_t *createPiles() { int transCommit() { unsigned int tot_bytes_mod, *listmid; plistnode_t *pile, *pile_ptr; - int trecvcount; char treplyretry; /* keeps track of the common response that needs to be sent */ int firsttime=1; trans_commit_data_t transinfo; /* keeps track of objs locked during transaction */ @@ -678,7 +677,6 @@ int transCommit() { do { - trecvcount = 0; treplyretry = 0; /* Look through all the objects in the transaction record and make piles diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index efc591dd..f5c9fcc8 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -59,8 +59,10 @@ objtypestat_t typesCausingAbort[TOTALNUMCLASSANDARRAY]; **/ INLINE void getTransSize(objheader_t *header , int *isObjTypeTraverse) { (typesCausingAbort[TYPE(header)]).numabort++; - if(isObjTypeTraverse[TYPE(header)] != 1) + if(isObjTypeTraverse[TYPE(header)] != 1) { (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; //should this count be kept per object + } isObjTypeTraverse[TYPE(header)]=1; } #define DEBUGSTMSTAT(args...) @@ -114,11 +116,13 @@ objlockstate_t *objlockscope; * Increments the abort count for each object **/ void ABORTCOUNT(objheader_t * x) { - float transAbortProb = (PERCENT_ALLOWED_ABORT*FACTOR)/(float)typesCausingAbort[TYPE(x)].numaccess; + int avgTransSize = typesCausingAbort[TYPE(x)].numaccess / typesCausingAbort[TYPE(x)].numtrans; + float transAbortProbForObj = (PERCENT_ALLOWED_ABORT*FACTOR)/(float) avgTransSize; float ObjAbortProb = x->abortCount/(float) (x->accessCount); - DEBUGSTM("ABORTSTATS: oid= %x, transAbortProb= %3.2f, ObjAbortProb= %3.2f, numaccess= %3d, type= %2d, abortCount= %3d, accessCount= %3d\n", OID(x), transAbortProb, ObjAbortProb, typesCausingAbort[TYPE(x)].numaccess, TYPE(x), x->abortCount, x->accessCount); + DEBUGSTM("ABORTSTATS: oid= %x, type= %2d, transAbortProb= %2.2f, ObjAbortProb= %2.2f, Typenumaccess= %3d, avgtranssize = %2d, ObjabortCount= %2d, ObjaccessCount= %3d\n", OID(x), TYPE(x), transAbortProbForObj, ObjAbortProb, typesCausingAbort[TYPE(x)].numaccess, avgTransSize, x->abortCount, x->accessCount); /* Condition for locking objects */ - if ((ObjAbortProb > transAbortProb) && (x->riskyflag != 1)) { + if (((ObjAbortProb*100) >= transAbortProbForObj) && (x->riskyflag != 1)) { + DEBUGSTM("AFTER LOCK ABORTSTATS: oid= %x, type= %2d, transAbortProb= %2.2f, ObjAbortProb= %2.2f, Typenumaccess= %3d, avgtranssize = %2d, ObjabortCount= %2d, ObjaccessCount= %3d\n", OID(x), TYPE(x), transAbortProbForObj, ObjAbortProb, typesCausingAbort[TYPE(x)].numaccess, avgTransSize, x->abortCount, x->accessCount); //makes riskflag sticky pthread_mutex_lock(&lockedobjstore); if (objlockscope->offsetaccessCount; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; getTotalAbortCount(i+1, size, (void *)(curr->next), numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse); #endif @@ -601,6 +606,7 @@ int traverseCache() { ObjSeqId = headeraddr->accessCount; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; //(typesCausingAbort[TYPE(header)])++; #endif @@ -666,6 +672,7 @@ int traverseCache() { header->abortCount++; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; #endif #if defined(STMSTATS)||defined(SOFTABORT) @@ -704,10 +711,11 @@ int traverseCache() { header->abortCount++; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse); #endif - DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; return TRANS_ABORT; @@ -723,10 +731,11 @@ int traverseCache() { header->abortCount++; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse); #endif - DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u, oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; return TRANS_ABORT; @@ -747,13 +756,14 @@ int traverseCache() { header->abortCount++; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; #endif #if defined(STMSTATS)||defined(SOFTABORT) if(getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse)) softabort=0; #endif - DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; if (softabort) @@ -787,7 +797,7 @@ int traverseCache() { //if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion)) // softabort=0; #endif - DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; if (softabort) @@ -839,7 +849,7 @@ int traverseCache() { //if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion)) //softabort=0; #endif - DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; if (softabort) @@ -916,10 +926,11 @@ int alttraverseCache() { ObjSeqId = headeraddr->accessCount; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse); #endif - DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; return TRANS_ABORT; @@ -935,13 +946,14 @@ int alttraverseCache() { ObjSeqId = headeraddr->accessCount; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; #endif #if defined(STMSTATS)||defined(SOFTABORT) if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse)) softabort=0; #endif - DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; if (softabort) @@ -990,13 +1002,14 @@ int alttraverseCache() { ObjSeqId = headeraddr->accessCount; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; #endif #if defined(STMSTATS)||defined(SOFTABORT) if(getTotalAbortCount2((void *) curr->next, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse)) softabort=0; #endif - DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("WR Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; if (softabort) @@ -1027,10 +1040,11 @@ int alttraverseCache() { header->abortCount++; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse); #endif - DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; return TRANS_ABORT; @@ -1046,7 +1060,7 @@ int alttraverseCache() { header->abortCount++; getReadAbortCount(i+1, numoidrdlocked, oidrdlocked, oidrdversion, oidrdage, ObjSeqId, header, objtypetraverse); #endif - DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version); + DEBUGSTM("RD Abort: rd: %u wr: %u tot: %u type: %u ver: %u oid: %x\n", numoidrdlocked, numoidwrlocked, c_numelements, TYPE(header), header->version, OID(header)); DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); freearrays; return TRANS_ABORT; @@ -1066,6 +1080,7 @@ int alttraverseCache() { header->abortCount++; (typesCausingAbort[TYPE(header)]).numabort++; (typesCausingAbort[TYPE(header)]).numaccess+=c_numelements; + (typesCausingAbort[TYPE(header)]).numtrans+=1; objtypetraverse[TYPE(header)]=1; #endif #if defined(STMSTATS)||defined(SOFTABORT) diff --git a/Robust/src/Runtime/STM/tm.h b/Robust/src/Runtime/STM/tm.h index 269fc561..8e82527c 100644 --- a/Robust/src/Runtime/STM/tm.h +++ b/Robust/src/Runtime/STM/tm.h @@ -152,13 +152,14 @@ extern objlockstate_t *objlockscope; pthread_mutex_t lockedobjstore; typedef struct objtypestat { - int numabort; + int numabort; int numaccess; + int numtrans; //num of transactions that accessed this object type and aborted } objtypestat_t; /* Variables for probability model */ -#define PERCENT_ALLOWED_ABORT 10 -#define FACTOR 1 +#define PERCENT_ALLOWED_ABORT 60 +#define FACTOR 3 #endif diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index f851fd1e..b82a6349 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -200,6 +200,7 @@ void initializethreads() { for(i=0; i