From: bdemsky Date: Fri, 9 Oct 2009 10:53:32 +0000 (+0000) Subject: more reorg X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=388cd0ff3cdd192979ce5dbb02da1ee85d139620;p=IRC.git more reorg --- diff --git a/Robust/src/Runtime/STM/stats.c b/Robust/src/Runtime/STM/stats.c index c0fd3a2e..8c1e51e9 100644 --- a/Robust/src/Runtime/STM/stats.c +++ b/Robust/src/Runtime/STM/stats.c @@ -1,3 +1,77 @@ +#include "tm.h" +#include "garbage.h" + +#ifdef STMSTATS +extern __thread threadrec_t *trec; +extern __thread struct objlist * lockedobjs; +extern __thread int t_objnumcount=0; + +/* Collect stats for object classes causing abort */ +extern objtypestat_t typesCausingAbort[TOTALNUMCLASSANDARRAY]; + +INLINE void getTransSize(objheader_t *header , int *isObjTypeTraverse) { + (typesCausingAbort[TYPE(header)]).numabort++; + 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; +} +#endif + +#ifdef STMSTATS +#define DEBUGSTMSTAT(args...) +#else +#define DEBUGSTMSTAT(args...) +#endif + +#ifdef STMDEBUG +#define DEBUGSTM(x...) printf(x); +#else +#define DEBUGSTM(x...); +#endif + +#ifdef STATDEBUG +#define DEBUGSTATS(x...) printf(x); +#else +#define DEBUGSTATS(x...); +#endif + +#ifdef STMSTATS +/*** Global variables *****/ +objlockstate_t *objlockscope; +/** + * ABORTCOUNT + * params: object header + * Increments the abort count for each object + **/ +void ABORTCOUNT(objheader_t * x) { + 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, 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*100) >= transAbortProbForObj) && (x->riskyflag != 1)) { + DEBUGSTATS("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->offsetobjlock=&(objlockscope->lock[objlockscope->offset++]); + } else { + objlockstate_t *tmp=malloc(sizeof(objlockstate_t)); + tmp->next=objlockscope; + tmp->offset=1; + x->objlock=&(tmp->lock[0]); + objlockscope=tmp; + } + pthread_mutex_unlock(&lockedobjstore); + pthread_mutex_init(x->objlock, NULL); + //should put a memory barrier here + x->riskyflag = 1; + } +} +#endif + #if defined(STMSTATS)||defined(SOFTABORT) /** ======================================================================================== * getTotalAbortCount (for traverseCache only) diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index f8b83a1e..114a77d2 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -50,20 +50,9 @@ __thread int t_objnumcount=0; /* Collect stats for object classes causing abort */ objtypestat_t typesCausingAbort[TOTALNUMCLASSANDARRAY]; -/** - * Inline fuction to get Transaction size per object type for those - * objects that cause - * - **/ +#endif -INLINE void getTransSize(objheader_t *header , int *isObjTypeTraverse) { - (typesCausingAbort[TYPE(header)]).numabort++; - 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; -} +#ifdef STMSTATS #define DEBUGSTMSTAT(args...) #else #define DEBUGSTMSTAT(args...) @@ -112,41 +101,6 @@ extern void * curr_heapbase; extern void * curr_heapptr; extern void * curr_heaptop; -#ifdef STMSTATS -/*** Global variables *****/ -objlockstate_t *objlockscope; -/** - * ABORTCOUNT - * params: object header - * Increments the abort count for each object - **/ -void ABORTCOUNT(objheader_t * x) { - 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, 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*100) >= transAbortProbForObj) && (x->riskyflag != 1)) { - DEBUGSTATS("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->offsetobjlock=&(objlockscope->lock[objlockscope->offset++]); - } else { - objlockstate_t *tmp=malloc(sizeof(objlockstate_t)); - tmp->next=objlockscope; - tmp->offset=1; - x->objlock=&(tmp->lock[0]); - objlockscope=tmp; - } - pthread_mutex_unlock(&lockedobjstore); - pthread_mutex_init(x->objlock, NULL); - //should put a memory barrier here - x->riskyflag = 1; - } -} -#endif - /* ================================================== * stmStartup * This function starts up the transaction runtime.