From 5c4a12ad1998ff9599ee52f98870dcb394768e9e Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 24 Mar 2008 22:19:18 +0000 Subject: [PATCH] bug fixes --- .../MatrixMultiply/MatrixMultiply.java | 6 +- .../Prefetch/MatrixMultiply/makefile | 2 +- Robust/src/IR/Flat/BuildCode.java | 7 +- Robust/src/Runtime/DSTM/interface/clookup.c | 8 +- Robust/src/Runtime/DSTM/interface/clookup.h | 2 +- Robust/src/Runtime/DSTM/interface/llookup.h | 2 +- .../src/Runtime/DSTM/interface/localobjects.c | 10 ++ Robust/src/Runtime/DSTM/interface/mlookup.h | 2 +- Robust/src/Runtime/DSTM/interface/prelookup.h | 2 +- .../src/Runtime/DSTM/interface/threadnotify.h | 2 +- Robust/src/Runtime/DSTM/interface/trans.c | 144 +++++++----------- Robust/src/Runtime/runtime.h | 3 + 12 files changed, 81 insertions(+), 109 deletions(-) diff --git a/Robust/src/Benchmarks/Prefetch/MatrixMultiply/MatrixMultiply.java b/Robust/src/Benchmarks/Prefetch/MatrixMultiply/MatrixMultiply.java index 93dda936..1687dd77 100644 --- a/Robust/src/Benchmarks/Prefetch/MatrixMultiply/MatrixMultiply.java +++ b/Robust/src/Benchmarks/Prefetch/MatrixMultiply/MatrixMultiply.java @@ -44,7 +44,7 @@ public class MatrixMultiply extends Thread{ } public static void main(String[] args) { - int mid1 = (128<<24)|(195<<16)|(175<<8)|70; + int mid1 = (128<<24)|(195<<16)|(175<<8)|73; int mid2 = (128<<24)|(195<<16)|(175<<8)|69; int mid3 = (128<<24)|(195<<16)|(175<<8)|71; int NUM_THREADS = 1; @@ -54,7 +54,7 @@ public class MatrixMultiply extends Thread{ MMul matrix; atomic { - matrix = global new MMul(800, 800, 800); + matrix = global new MMul(200, 200, 200); matrix.setValues(); matrix.transpose(); } @@ -64,7 +64,7 @@ public class MatrixMultiply extends Thread{ } atomic { - mm[0] = global new MatrixMultiply(matrix,0,0,799,799); + mm[0] = global new MatrixMultiply(matrix,0,0,199,199); } atomic { diff --git a/Robust/src/Benchmarks/Prefetch/MatrixMultiply/makefile b/Robust/src/Benchmarks/Prefetch/MatrixMultiply/makefile index 2767c1ee..f8bbf4a9 100644 --- a/Robust/src/Benchmarks/Prefetch/MatrixMultiply/makefile +++ b/Robust/src/Benchmarks/Prefetch/MatrixMultiply/makefile @@ -1,6 +1,6 @@ MAINCLASS=MatrixMultiply SRC=${MAINCLASS}.java -FLAGS=-dsm -prefetch -nooptimize -printflat -profile -debug -excprefetch MatrixMultiply.main -excprefetch MMul.setValues -excprefetch MMul.transpose -mainclass ${MAINCLASS} -o ${MAINCLASS} +FLAGS=-dsm -prefetch -nooptimize -printflat -debug -excprefetch MatrixMultiply.main -excprefetch MMul.setValues -excprefetch MMul.transpose -mainclass ${MAINCLASS} -o ${MAINCLASS} default: ../../../buildscript ${FLAGS} ${SRC} clean: diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 6f82f318..352a648d 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -924,10 +924,14 @@ public class BuildCode { if (!fieldorder.containsKey(cn)) { Vector fields=new Vector(); fieldorder.put(cn,fields); + if (sp==null) { + fields.add(cn.getFieldTable().get("cachedCode")); + } Iterator fieldit=cn.getFields(); while(fieldit.hasNext()) { FieldDescriptor fd=(FieldDescriptor)fieldit.next(); - if (sp==null||!sp.getFieldTable().contains(fd.getSymbol())) + if ((sp==null||!sp.getFieldTable().contains(fd.getSymbol()))&& + (!fd.getSymbol().equals("cachedCode"))) fields.add(fd); } } @@ -2156,7 +2160,6 @@ public class BuildCode { else output.println("COPY_OBJ("+dst+");"); output.println(dst+"->"+nextobjstr+"="+revertptr+";"); - output.println("trans->revertlist=(struct ___Object___ *)"+dst+";"); output.println("}"); } else throw new Error("Unknown array type"); diff --git a/Robust/src/Runtime/DSTM/interface/clookup.c b/Robust/src/Runtime/DSTM/interface/clookup.c index a38d22e1..e7bb74e8 100644 --- a/Robust/src/Runtime/DSTM/interface/clookup.c +++ b/Robust/src/Runtime/DSTM/interface/clookup.c @@ -66,12 +66,10 @@ unsigned int chashInsert(chashtable_t *table, unsigned int key, void *val) { // Search for an address for a given oid void *chashSearch(chashtable_t *table, unsigned int key) { - int index; - chashlistnode_t *ptr, *node; + int index = chashFunction(table, key); + chashlistnode_t *ptr =table -> table; + chashlistnode_t *node = &ptr[index]; - ptr = table->table; - index = chashFunction(table, key); - node = &ptr[index]; while(node != NULL) { if(node->key == key) { return node->val; diff --git a/Robust/src/Runtime/DSTM/interface/clookup.h b/Robust/src/Runtime/DSTM/interface/clookup.h index b71abfd5..494a7b9a 100644 --- a/Robust/src/Runtime/DSTM/interface/clookup.h +++ b/Robust/src/Runtime/DSTM/interface/clookup.h @@ -4,7 +4,7 @@ #include #include -#define LOADFACTOR 0.75 +#define LOADFACTOR 0.5 #define HASH_SIZE 100 typedef struct chashlistnode { diff --git a/Robust/src/Runtime/DSTM/interface/llookup.h b/Robust/src/Runtime/DSTM/interface/llookup.h index 20dbac72..29c0d304 100644 --- a/Robust/src/Runtime/DSTM/interface/llookup.h +++ b/Robust/src/Runtime/DSTM/interface/llookup.h @@ -7,7 +7,7 @@ #define SIMPLE_LLOOKUP -#define LOADFACTOR 0.75 +#define LOADFACTOR 0.5 #define HASH_SIZE 100 typedef struct lhashlistnode { diff --git a/Robust/src/Runtime/DSTM/interface/localobjects.c b/Robust/src/Runtime/DSTM/interface/localobjects.c index 0fdf0fd1..1c2ee006 100644 --- a/Robust/src/Runtime/DSTM/interface/localobjects.c +++ b/Robust/src/Runtime/DSTM/interface/localobjects.c @@ -33,8 +33,13 @@ void COPY_OBJ(struct ___Object___ *obj) { #else struct ___Object___ * newobj=FREEMALLOC(size); #endif +#ifdef PRECISE_GC memcpy(newobj, (struct ___Object___ *) ptrarray[2], size); ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj; +#else + memcpy(newobj, obj, size); + obj->___localcopy___=newobj; +#endif } else { /* We have an array */ struct ArrayObject *ao=(struct ArrayObject *)obj; @@ -47,7 +52,12 @@ void COPY_OBJ(struct ___Object___ *obj) { #else struct ___Object___ * newobj=FREEMALLOC(size); #endif +#ifdef PRECISE_GC memcpy(newobj, (struct ___Object___ *) ptrarray[2], size); ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj; +#else + memcpy(newobj, obj, size); + obj->___localcopy___=newobj; +#endif } } diff --git a/Robust/src/Runtime/DSTM/interface/mlookup.h b/Robust/src/Runtime/DSTM/interface/mlookup.h index 85396c52..aec88798 100644 --- a/Robust/src/Runtime/DSTM/interface/mlookup.h +++ b/Robust/src/Runtime/DSTM/interface/mlookup.h @@ -5,7 +5,7 @@ #include #include -#define LOADFACTOR 0.75 +#define LOADFACTOR 0.5 #define HASH_SIZE 100 typedef struct mhashlistnode { diff --git a/Robust/src/Runtime/DSTM/interface/prelookup.h b/Robust/src/Runtime/DSTM/interface/prelookup.h index acb540d9..df020b3b 100644 --- a/Robust/src/Runtime/DSTM/interface/prelookup.h +++ b/Robust/src/Runtime/DSTM/interface/prelookup.h @@ -5,7 +5,7 @@ #include #include -#define LOADFACTOR 0.75 +#define LOADFACTOR 0.5 #define HASH_SIZE 100 typedef struct prehashlistnode { diff --git a/Robust/src/Runtime/DSTM/interface/threadnotify.h b/Robust/src/Runtime/DSTM/interface/threadnotify.h index 05bddb48..7ed1c7a0 100644 --- a/Robust/src/Runtime/DSTM/interface/threadnotify.h +++ b/Robust/src/Runtime/DSTM/interface/threadnotify.h @@ -5,7 +5,7 @@ #include #include -#define N_LOADFACTOR 0.75 +#define N_LOADFACTOR 0.5 #define N_HASH_SIZE 20 //Structure to notify object of which other objects/threads are waiting on it diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 49f7da64..da01610c 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -309,111 +309,69 @@ transrecord_t *transStart() /* This function finds the location of the objects involved in a transaction * and returns the pointer to the object if found in a remote location */ objheader_t *transRead(transrecord_t *record, unsigned int oid) { - unsigned int machinenumber; - objheader_t *tmp, *objheader; - objheader_t *objcopy; - int size, rc, found = 0; - void *buf; - struct timespec ts; - struct timeval tp; - - if(oid == 0) { - printf("Error: %s, %d oid is NULL \n", __FILE__, __LINE__); - return NULL; - } - - rc = gettimeofday(&tp, NULL); - - /* 1ms delay */ - tp.tv_usec += 1000; - if (tp.tv_usec >= 1000000) - { - tp.tv_usec -= 1000000; - tp.tv_sec += 1; - } - /* Convert from timeval to timespec */ - ts.tv_sec = tp.tv_sec; - ts.tv_nsec = tp.tv_usec * 1000; - - /* Search local transaction cache */ - if((objheader = (objheader_t *)chashSearch(record->lookupTable, oid)) != NULL){ - -#ifdef COMPILER - return &objheader[1]; -#else - return objheader; -#endif - } else if ((objheader = (objheader_t *) mhashSearch(oid)) != NULL) { - /* Look up in machine lookup table and copy into cache*/ - GETSIZE(size, objheader); - size += sizeof(objheader_t); - objcopy = (objheader_t *) objstrAlloc(record->cache, size); - memcpy(objcopy, objheader, size); - /* Insert into cache's lookup table */ - chashInsert(record->lookupTable, OID(objheader), objcopy); + unsigned int machinenumber; + objheader_t *tmp, *objheader; + objheader_t *objcopy; + int size, found = 0; + void *buf; + + if(oid == 0) { + printf("Error: %s, %d oid is NULL \n", __FILE__, __LINE__); + return NULL; + } + + /* Search local transaction cache */ + if((objheader = (objheader_t *)chashSearch(record->lookupTable, oid)) != NULL){ #ifdef COMPILER - return &objcopy[1]; + return &objheader[1]; #else - return objcopy; + return objheader; #endif - } else if((tmp = (objheader_t *) prehashSearch(oid)) != NULL) { /* Look up in prefetch cache */ - GETSIZE(size, tmp); - size+=sizeof(objheader_t); - objcopy = (objheader_t *) objstrAlloc(record->cache, size); - memcpy(objcopy, tmp, size); - /* Insert into cache's lookup table */ - chashInsert(record->lookupTable, OID(tmp), objcopy); + } else if ((objheader = (objheader_t *) mhashSearch(oid)) != NULL) { + /* Look up in machine lookup table and copy into cache*/ + GETSIZE(size, objheader); + size += sizeof(objheader_t); + objcopy = (objheader_t *) objstrAlloc(record->cache, size); + memcpy(objcopy, objheader, size); + /* Insert into cache's lookup table */ + chashInsert(record->lookupTable, OID(objheader), objcopy); #ifdef COMPILER - return &objcopy[1]; + return &objcopy[1]; #else - return objcopy; + return objcopy; #endif - } else { - /*If object not found in prefetch cache then block until object appears in the prefetch cache */ - /* - pthread_mutex_lock(&pflookup.lock); - while(!found) { - rc = pthread_cond_timedwait(&pflookup.cond, &pflookup.lock, &ts); - // Check Prefetch cache again - if((tmp =(objheader_t *) prehashSearch(oid)) != NULL) { - found = 1; - GETSIZE(size,tmp); - size+=sizeof(objheader_t); - objcopy = (objheader_t *) objstrAlloc(record->cache, size); - memcpy(objcopy, tmp, size); - chashInsert(record->lookupTable, OID(tmp), objcopy); - pthread_mutex_unlock(&pflookup.lock); + } else if((tmp = (objheader_t *) prehashSearch(oid)) != NULL) { /* Look up in prefetch cache */ + GETSIZE(size, tmp); + size+=sizeof(objheader_t); + objcopy = (objheader_t *) objstrAlloc(record->cache, size); + memcpy(objcopy, tmp, size); + /* Insert into cache's lookup table */ + chashInsert(record->lookupTable, OID(tmp), objcopy); #ifdef COMPILER - return &objcopy[1]; + return &objcopy[1]; #else - return objcopy; + return objcopy; #endif - } else if (rc == ETIMEDOUT) { - pthread_mutex_unlock(&pflookup.lock); - break; - } - } - */ - - /* Get the object from the remote location */ - if((machinenumber = lhashSearch(oid)) == 0) { - printf("Error: %s() No machine found for oid =% %s,%dx\n",__func__, machinenumber, __FILE__, __LINE__); - return NULL; - } - objcopy = getRemoteObj(record, machinenumber, oid); - - if(objcopy == NULL) { - printf("Error: Object not found in Remote location %s, %d\n", __FILE__, __LINE__); - return NULL; - } else { - + } else { + /* Get the object from the remote location */ + if((machinenumber = lhashSearch(oid)) == 0) { + printf("Error: %s() No machine found for oid =% %s,%dx\n",__func__, machinenumber, __FILE__, __LINE__); + return NULL; + } + objcopy = getRemoteObj(record, machinenumber, oid); + + if(objcopy == NULL) { + printf("Error: Object not found in Remote location %s, %d\n", __FILE__, __LINE__); + return NULL; + } else { + #ifdef COMPILER - return &objcopy[1]; + return &objcopy[1]; #else - return objcopy; + return objcopy; #endif - } - } + } + } } /* This function creates objects in the transaction record */ diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index 7158c14f..6c1ac82b 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -8,6 +8,9 @@ extern int failurecount; #include "dstm.h" #endif +extern void * curr_heapbase; +extern void * curr_heaptop; + #define TAGARRAYINTERVAL 10 #define OBJECTARRAYINTERVAL 10 -- 2.34.1