From 69a3754f9b60c61868c3504a65bc6af421741558 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 14 May 2009 02:53:52 +0000 Subject: [PATCH] more changes...fix soft abort case...it needs to let other transactions through... --- Robust/src/Runtime/STM/stm.c | 66 ++++++++++++++++++++++++++++-------- Robust/src/Runtime/STM/tm.h | 8 +++-- 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index 934b1f5a..be807312 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -12,7 +12,7 @@ #include "tm.h" #include "garbage.h" - +#define likely(x) x /* Per thread transaction variables */ __thread objstr_t *t_cache; __thread objstr_t *t_reserve; @@ -336,8 +336,11 @@ int transCommit() { nSoftAbort++; #endif softaborted++; +#ifdef SOFTABORT + if (softaborted>1) { +#else if (1) { - //if (softaborted>1) { +#endif //retry if too many soft aborts freenewobjs(); #ifdef STMSTATS @@ -418,6 +421,9 @@ int traverseCache() { free(oidrdversion); free(oidwrlocked); } + if (softabort) + return TRANS_SOFT_ABORT; + else return TRANS_ABORT; } } else { /* cannot aquire lock */ @@ -429,7 +435,10 @@ int traverseCache() { #ifdef STMSTATS ABORTCOUNT(header); (typesCausingAbort[TYPE(header)])++; - getTotalAbortCount(i+1, size, (void *)(curr->next), NULL, 1); +#endif +#if defined(STMSTATS)||defined(SOFTABORT) + if (getTotalAbortCount(i+1, size, (void *)(curr->next), NULL, 1)) + 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); DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); @@ -438,7 +447,10 @@ int traverseCache() { free(oidrdversion); free(oidwrlocked); } - return TRANS_ABORT; + if (softabort) + return TRANS_SOFT_ABORT; + else + return TRANS_ABORT; } } else { oidrdversion[numoidrdlocked]=version; @@ -481,7 +493,10 @@ int traverseCache() { #ifdef STMSTATS ABORTCOUNT(header); (typesCausingAbort[TYPE(header)])++; - getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *) oidrdversion, 0); +#endif +#if defined(STMSTATS)||defined(SOFTABORT) + if (getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *) oidrdversion, 0)) + 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); DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); @@ -490,7 +505,10 @@ int traverseCache() { free(oidrdversion); free(oidwrlocked); } - return TRANS_ABORT; + if (softabort) + return TRANS_SOFT_ABORT; + else + return TRANS_ABORT; } } @@ -573,7 +591,10 @@ int alttraverseCache() { #ifdef STMSTATS ABORTCOUNT(header); (typesCausingAbort[TYPE(header)])++; - getTotalAbortCount(0, 1, (void *) curr->next, NULL, 1); +#endif +#if defined(STMSTATS)||defined(SOFTABORT) + if (getTotalAbortCount(0, 1, (void *) curr->next, NULL, 1)) + 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); DEBUGSTMSTAT("WR Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); @@ -582,7 +603,10 @@ int alttraverseCache() { free(oidrdversion); free(oidwrlocked); } - return TRANS_ABORT; + if (softabort) + return TRANS_SOFT_ABORT; + else + return TRANS_ABORT; } } else { /* Read from the main heap and compare versions */ @@ -620,7 +644,10 @@ int alttraverseCache() { #ifdef STMSTATS ABORTCOUNT(header); (typesCausingAbort[TYPE(header)])++; - getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *)oidrdversion, 0); +#endif +#if defined(STMSTATS)||defined(SOFTABORT) + if (getTotalAbortCount(i+1, numoidrdlocked, oidrdlocked, (void *)oidrdversion, 0)) + 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); DEBUGSTMSTAT("RD Abort: Access Count: %u AbortCount: %u type: %u ver: %u \n", header->accessCount, header->abortCount, TYPE(header), header->version); @@ -629,7 +656,10 @@ int alttraverseCache() { free(oidrdversion); free(oidwrlocked); } - return TRANS_ABORT; + if (softabort) + return TRANS_SOFT_ABORT; + else + return TRANS_ABORT; } } @@ -682,7 +712,7 @@ void transAbortProcess(void **oidwrlocked, int numoidwrlocked) { * * ================================= */ -int transCommitProcess(void ** oidwrlocked, int numoidwrlocked) { +void transCommitProcess(void ** oidwrlocked, int numoidwrlocked) { objheader_t *header; void *ptrcreate; int i; @@ -731,8 +761,6 @@ int transCommitProcess(void ** oidwrlocked, int numoidwrlocked) { ptr=ptr->next; } #endif - - return 0; } /** ======================================================================================== @@ -743,9 +771,10 @@ int transCommitProcess(void ** oidwrlocked, int numoidwrlocked) { * 0='r'/1='w' if found when visiting objects read/ objects modified * ========================================================================================= **/ -#ifdef STMSTATS -void getTotalAbortCount(int start, int stop, void *startptr, void *checkptr, int type) { +#if defined(STMSTATS)||defined(SOFTABORT) +int getTotalAbortCount(int start, int stop, void *startptr, void *checkptr, int type) { int i; + int hardabort=0; if(type) { int isFirstTime = 0; chashlistnode_t *curr = (chashlistnode_t *) startptr; @@ -762,8 +791,11 @@ void getTotalAbortCount(int start, int stop, void *startptr, void *checkptr, int unsigned int version = headeraddr->version; /* versions do not match */ if(version != header->version) { +#ifdef STMSTATS ABORTCOUNT(header); (typesCausingAbort[TYPE(header)])++; +#endif + hardabort=1; } curr = curr->next; } @@ -775,11 +807,15 @@ void getTotalAbortCount(int start, int stop, void *startptr, void *checkptr, int objheader_t *header = ((void **)startptr)[i]; unsigned int version = ((int *)checkptr)[i]; if(version != header->version) { /* versions do not match */ +#ifdef STMSTATS ABORTCOUNT(header); (typesCausingAbort[TYPE(header)])++; +#endif + hardabort=1; } } } + return hardabort; } /** diff --git a/Robust/src/Runtime/STM/tm.h b/Robust/src/Runtime/STM/tm.h index b6995f30..3ee4128e 100644 --- a/Robust/src/Runtime/STM/tm.h +++ b/Robust/src/Runtime/STM/tm.h @@ -169,11 +169,13 @@ __attribute__((pure)) void *transRead(void *, void *); int transCommit(); int traverseCache(); int alttraverseCache(); -int transAbortProcess(void **, int); -int transCommmitProcess(void **, int); +void transAbortProcess(void **, int); +void transCommitProcess(void **, int); void randomdelay(int); +#if defined(STMSTATS)||defined(SOFTABORT) +int getTotalAbortCount(int, int, void *, void *, int); +#endif #ifdef STMSTATS -void getTotalAbortCount(int, int, void *, void *, int); objheader_t * needLock(objheader_t *, void *); #endif #endif -- 2.34.1