From f684d3e869489f0cf8fbcadd8000e659199dff2e Mon Sep 17 00:00:00 2001 From: yeom Date: Fri, 4 Dec 2009 19:18:00 +0000 Subject: [PATCH] changes on alt-prefetch lookup and gCollect --- .../src/Runtime/DSTM/interface/altprelookup.c | 40 ++++++--- .../src/Runtime/DSTM/interface/altprelookup.h | 6 +- Robust/src/Runtime/DSTM/interface/gCollect.c | 86 ++++++++++++++++++- 3 files changed, 113 insertions(+), 19 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface/altprelookup.c b/Robust/src/Runtime/DSTM/interface/altprelookup.c index 72a34011..87afbe89 100644 --- a/Robust/src/Runtime/DSTM/interface/altprelookup.c +++ b/Robust/src/Runtime/DSTM/interface/altprelookup.c @@ -24,10 +24,23 @@ unsigned int prehashCreate(unsigned int size, float loadfactor) { pflookup.threshold=loadfactor*size; //Initilize - for(i=0;i>1; - volatile unsigned int * lockptr=&pflookup.larray[keyindex&LOCKMASK].lock; + volatile unsigned int * lockptr=&pflookup.larray[keyindex&PRELOCKMASK].lock; while(!write_trylock(lockptr)) { sched_yield(); } ptr = &pflookup.table[keyindex&pflookup.mask]; - if((ptr->key==0) && (ptr->next== NULL)) { //Insert at the first bin of the table + if(ptr->key==0) { //Insert at the first bin of the table ptr->key = key; ptr->val = val; atomic_inc(&pflookup.numelements); @@ -67,7 +80,6 @@ void prehashInsert(unsigned int key, void *val) { isFound=1; tmp->val = val;//Replace value for an exsisting key write_unlock(lockptr); - return; } tmp=tmp->next; @@ -86,11 +98,11 @@ void prehashInsert(unsigned int key, void *val) { } // Search for an address for a given oid -INLINE void *prehashSearch(unsigned int key) { +void *prehashSearch(unsigned int key) { int index; unsigned int keyindex=key>>1; - volatile unsigned int * lockptr=&pflookup.larray[keyindex&LOCKMASK].lock; + volatile unsigned int * lockptr=&pflookup.larray[keyindex&PRELOCKMASK].lock; while(!read_trylock(lockptr)) { sched_yield(); } @@ -113,15 +125,17 @@ unsigned int prehashRemove(unsigned int key) { prehashlistnode_t *prev; prehashlistnode_t *ptr, *node; + //eom unsigned int keyindex=key>>1; - volatile unsigned int * lockptr=&pflookup.larray[keyindex&LOCKMASK].lock; + volatile unsigned int * lockptr=&pflookup.larray[keyindex&PRELOCKMASK].lock; while(!write_trylock(lockptr)) { sched_yield(); } prehashlistnode_t *curr = &pflookup.table[keyindex&pflookup.mask]; - + //eom + for (; curr != NULL; curr = curr->next) { if (curr->key == key) { // Find a match in the hash table @@ -161,7 +175,7 @@ unsigned int prehashResize(unsigned int newsize) { int i,index; unsigned int mask; - for(i=0;iprev=tmp; pNodeInfo.newptr=tmp; pNodeInfo.os_count++; - + if (pNodeInfo.os_count>PREFETCH_FLUSH_THRESHOLD) { //remove oldest from linked list objstr_t *tofree=pNodeInfo.oldptr; @@ -95,15 +99,33 @@ void *prefetchobjstrAlloc(unsigned int size) { return ptr; } +#if 0 void clearBlock(objstr_t *block) { + unsigned long int tmpbegin=(unsigned int)block; unsigned long int tmpend=(unsigned int)block->top; int i, j; prehashlistnode_t *ptr; - pthread_mutex_lock(&pflookup.lock); + //pthread_mutex_lock(&pflookup.lock); + /* + for(i=0;inext; @@ -133,9 +155,67 @@ void clearBlock(objstr_t *block) { } } } + + if(((i+1)&(pflookup.mask>>4))==0 && (i+1)top; + int i, j; + prehashlistnode_t *ptr; + pthread_mutex_lock(&pflookup.lock); + + ptr = pflookup.table; + for(i = 0; inext; + for(; next != NULL; curr=next, next = next->next) { + unsigned int val=(unsigned int)next->val; + if ((val>=tmpbegin)&(valnext=next->next; + free(next); + next=curr; + //loop condition is broken now...need to check before incrementing + //if (next==NULL) + // break; + } + } + { + unsigned int val=(unsigned int)orig->val; + if ((val>=tmpbegin)&(valnext==NULL) { + orig->key=0; + orig->val=NULL; + } else { + next=orig->next; + orig->val=next->val; + orig->key=next->key; + orig->next=next->next; + free(next); + } + } + } } pthread_mutex_unlock(&pflookup.lock); } +#endif objstr_t *allocateNew(unsigned int size) { objstr_t *tmp; -- 2.34.1