From: bdemsky Date: Wed, 8 Apr 2009 09:41:46 +0000 (+0000) Subject: allocate memory in large blocks X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bcea7094f53611afb1bbf2cafd9cb362353f47cc;p=IRC.git allocate memory in large blocks --- diff --git a/Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java b/Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java index 7e3adc43..f714d4e2 100644 --- a/Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java +++ b/Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java @@ -1,6 +1,6 @@ #define ROW 100 /* columns in the map */ #define COLUMN 100 /* rows of in the map */ -#define ROUNDS 256 /* Number of moves by each player */ +#define ROUNDS 2560 /* Number of moves by each player */ #define PLAYERS 20 /* Number of Players when num Players != num of client machines */ #define RATI0 0.5 /* Number of lumberjacks to number of planters */ #define BLOCK 3 /* Area around the gamer to consider */ diff --git a/Robust/src/Benchmarks/SingleTM/RainForest/makefile b/Robust/src/Benchmarks/SingleTM/RainForest/makefile index 80c11f9c..1c48c05b 100644 --- a/Robust/src/Benchmarks/SingleTM/RainForest/makefile +++ b/Robust/src/Benchmarks/SingleTM/RainForest/makefile @@ -10,7 +10,7 @@ SRC=tmp${MAINCLASS}.java \ Node.java \ AStarPathFinder.java -FLAGS=-singleTM -optimize -mainclass ${MAINCLASS} -debug -transstats -joptimize -profile +FLAGS=-singleTM -nooptimize -mainclass ${MAINCLASS} -debug -transstats -joptimize default: cpp ${MAINCLASS}.java > tmp1${MAINCLASS}.java diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index 0074741d..dc0dcfb6 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -103,7 +103,7 @@ void randomdelay() { t = time(NULL); req.tv_sec = 0; - req.tv_nsec = (long)(t%100); //1-11 microsec + req.tv_nsec = (long)(t%4); //1-11 microsec nanosleep(&req, NULL); return; } @@ -160,18 +160,16 @@ __attribute__((pure)) void *transRead(void * oid) { return oid; /* Read from the main heap */ + //No lock for now objheader_t *header = (objheader_t *)(((char *)oid) - sizeof(objheader_t)); - if(read_trylock(&header->lock)) { //Can further acquire read locks - GETSIZE(size, header); - size += sizeof(objheader_t); - objcopy = (objheader_t *) objstrAlloc(&t_cache, size); - memcpy(objcopy, header, size); - /* Insert into cache's lookup table */ - STATUS(objcopy)=0; - t_chashInsert((unsigned int)oid, &objcopy[1]); - read_unlock(&header->lock); - return &objcopy[1]; - } + GETSIZE(size, header); + size += sizeof(objheader_t); + objcopy = (objheader_t *) objstrAlloc(&t_cache, size); + memcpy(objcopy, header, size); + /* Insert into cache's lookup table */ + STATUS(objcopy)=0; + t_chashInsert((unsigned int)oid, &objcopy[1]); + return &objcopy[1]; } void freenewobjs() { diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index 0b8e8465..8f233fa4 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -250,6 +250,11 @@ void enqueuetag(struct ___TagDescriptor___ *ptr) { } #endif +#ifdef STM +__thread char * memorybase=NULL; +__thread char * memorytop=NULL; +#endif + void collect(struct garbagelist * stackptr) { #if defined(THREADS)||defined(DSTM)||defined(STM) @@ -281,6 +286,7 @@ void collect(struct garbagelist * stackptr) { if (c_table!=NULL) { fixtable(&c_table, c_size); fixobjlist(newobjs); + memorybase=NULL; } #endif @@ -310,6 +316,7 @@ void collect(struct garbagelist * stackptr) { if ((*listptr->tc_table)!=NULL) { fixtable(listptr->tc_table, listptr->tc_size); fixobjlist(listptr->objlist); + (*listptr->base)=NULL; } #endif stackptr=listptr->stackptr; @@ -569,7 +576,6 @@ void checkcollect2(void * ptr) { } #endif - struct listitem * stopforgc(struct garbagelist * ptr) { struct listitem * litem=malloc(sizeof(struct listitem)); litem->stackptr=ptr; @@ -580,6 +586,7 @@ struct listitem * stopforgc(struct garbagelist * ptr) { litem->tc_size=c_size; litem->tc_table=&c_table; litem->objlist=newobjs; + litem->base=&memorybase; #endif litem->prev=NULL; pthread_mutex_lock(&gclistlock); @@ -612,7 +619,26 @@ void restartaftergc(struct listitem * litem) { } #endif +#ifdef STM +#define MEMORYBLOCK 65536 +void * helper(struct garbagelist *, int); void * mygcmalloc(struct garbagelist * stackptr, int size) { + if ((size&7)!=0) + size=(size&~7)+8; + if (memorybase==NULL||(memorybase+size)>memorytop) { + int toallocate=(size>MEMORYBLOCK)?size:MEMORYBLOCK; + memorybase=helper(stackptr, toallocate); + memorytop=memorybase+toallocate; + } + char *retvalue=memorybase; + memorybase+=size; + return retvalue; +} + +void * helper(struct garbagelist * stackptr, int size) { +#else +void * mygcmalloc(struct garbagelist * stackptr, int size) { +#endif void *ptr; #if defined(THREADS)||defined(DSTM)||defined(STM) if (pthread_mutex_trylock(&gclock)!=0) { diff --git a/Robust/src/Runtime/garbage.h b/Robust/src/Runtime/garbage.h index 7d7417ab..35b88621 100644 --- a/Robust/src/Runtime/garbage.h +++ b/Robust/src/Runtime/garbage.h @@ -20,6 +20,7 @@ struct listitem { unsigned int tc_size; chashlistnode_t **tc_table; struct objlist * objlist; + char **base; #endif };