From ea7cccc68067dd5a91397bb6c75409b27a7144e9 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 16 Aug 2007 09:39:42 +0000 Subject: [PATCH] fix bugs in transaction code that: 1) don't free tosend buffers 2) don't free piles (null is passed into pDelete --- Robust/src/Analysis/Locality/LocalityAnalysis.java | 4 ++-- Robust/src/IR/Flat/BuildCode.java | 8 +++++++- Robust/src/IR/Flat/TempDescriptor.java | 4 ++-- Robust/src/Runtime/DSTM/interface/dstm.h | 6 +++--- Robust/src/Runtime/DSTM/interface/localobjects.h | 2 +- Robust/src/Runtime/DSTM/interface/trans.c | 11 +++++------ Robust/src/buildscript | 2 +- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index aa3d9b19..56179dcc 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -577,9 +577,9 @@ public class LocalityAnalysis { for(Iterator tempit=livetemps.iterator();tempit.hasNext();) { TempDescriptor tmp=tempit.next(); if (writes.contains(tmp)) { - nodetosavetemps.get(fn).add(tmp); + nodetosavetemps.get(atomicnode).add(tmp); } else if (reads.contains(tmp)&&temptab.get(fn).get(tmp)==GLOBAL) { - nodetosavetemps.get(fn).add(tmp); + nodetosavetemps.get(atomicnode).add(tmp); } } } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index e645038d..de30c31e 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -290,8 +290,10 @@ public class BuildCode { outmethod.println("#include \"methodheaders.h\""); outmethod.println("#include \"virtualtable.h\""); outmethod.println("#include "); - if (state.DSM) + if (state.DSM) +{ outmethod.println("#include \"dstm.h\""); outmethod.println("#include \"localobjects.h\""); + } if (state.THREAD) outmethod.println("#include "); if (state.main!=null) { @@ -794,6 +796,10 @@ public class BuildCode { /* Create temp to hold revert table */ if (lb.getHasAtomic()) { TempDescriptor reverttmp=new TempDescriptor("revertlist", typeutil.getClass(TypeUtil.ObjectClass)); + if (GENERATEPRECISEGC) + objecttemps.addPtr(reverttmp); + else + objecttemps.addPrim(reverttmp); reverttable.put(lb, reverttmp); } } diff --git a/Robust/src/IR/Flat/TempDescriptor.java b/Robust/src/IR/Flat/TempDescriptor.java index a25fdb83..39bb16e0 100644 --- a/Robust/src/IR/Flat/TempDescriptor.java +++ b/Robust/src/IR/Flat/TempDescriptor.java @@ -31,9 +31,9 @@ public class TempDescriptor extends Descriptor { public TempDescriptor createNew() { if (tag==null) - return new TempDescriptor(name, type); + return new TempDescriptor(name+"_"+currentid, type); else - return new TempDescriptor(name, type, tag); + return new TempDescriptor(name+"_"+currentid, type, tag); } public static TempDescriptor tempFactory() { diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index 87899bb8..cf2a3b2a 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -69,10 +69,10 @@ typedef struct objheader { } objheader_t; #define OID(x)\ - ((struct ___Object___ *)((unsigned int) x + sizeof(objheader_t)))->___nextobject___ +*((unsigned int *)&((struct ___Object___ *)((unsigned int) x + sizeof(objheader_t)))->___nextobject___) #define STATUS(x)\ - ((struct ___Object___ *)((unsigned int) x + sizeof(objheader_t)))->___localcopy___ + *((unsigned int *) &(((struct ___Object___ *)((unsigned int) x + sizeof(objheader_t)))->___localcopy___)) #define TYPE(x)\ ((struct ___Object___ *)((unsigned int) x + sizeof(objheader_t)))->type @@ -214,7 +214,7 @@ int transCommitProcess(trans_commit_data_t *, int); /* Function called at beginning. Passes in the first parameter. */ /* Returns 1 if this thread should run the main process */ -int dstmStartup(char *); +int dstmStartup(const char *); void transInit(); void randomdelay(void); diff --git a/Robust/src/Runtime/DSTM/interface/localobjects.h b/Robust/src/Runtime/DSTM/interface/localobjects.h index d32095ba..9d4968dd 100644 --- a/Robust/src/Runtime/DSTM/interface/localobjects.h +++ b/Robust/src/Runtime/DSTM/interface/localobjects.h @@ -3,7 +3,7 @@ #include "structdefs.h" #include "garbage.h" void REVERT_OBJ(struct ___Object___ *); -#define COMMIT_OBJ(obj) obj->localcopy=NULL +#define COMMIT_OBJ(obj) obj->___localcopy___=NULL #ifdef PRECISE_GC void COPY_OBJ(struct garbagelist * gl, struct ___Object___ *obj); diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 67c56629..45b30ff0 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -82,7 +82,7 @@ void prefetch(int ntuples, unsigned int *oids, short *endoffsets, short *arrayfi /* This function starts up the transaction runtime. */ -int dstmStartup(char * option) { +int dstmStartup(const char * option) { pthread_t thread_Listen; pthread_attr_t attr; int master=strcmp(option, "master")==0; @@ -318,7 +318,7 @@ plistnode_t *createPiles(transrecord_t *record) { * Sends a transrequest() to each pile*/ int transCommit(transrecord_t *record) { unsigned int tot_bytes_mod, *listmid; - plistnode_t *pile; + plistnode_t *pile, *pile_ptr; int i, rc, val; int pilecount = 0, offset, threadnum = 0, trecvcount = 0, tmachcount = 0; char buffer[RECEIVE_BUFFER_SIZE],control; @@ -332,7 +332,7 @@ int transCommit(transrecord_t *record) { /* Look through all the objects in the transaction record and make piles * for each machine involved in the transaction*/ - pile = createPiles(record); + pile_ptr = pile = createPiles(record); /* Create the packet to be sent in TRANS_REQUEST */ @@ -375,7 +375,6 @@ int transCommit(transrecord_t *record) { while(pile != NULL) { //Create transaction id newtid++; - //trans_req_data_t *tosend; if ((tosend = calloc(1, sizeof(trans_req_data_t))) == NULL) { printf("Calloc error %s, %d\n", __FILE__, __LINE__); return 1; @@ -432,14 +431,14 @@ int transCommit(transrecord_t *record) { printf("ERROR return code from pthread_join() is %d\n", rc); return 1; } + free(thread_data_array[i].buffer); } /* Free resources */ pthread_cond_destroy(&tcond); pthread_mutex_destroy(&tlock); - free(tosend); free(listmid); - pDelete(pile); + pDelete(pile_ptr); free(thread_data_array); free(ltdata); diff --git a/Robust/src/buildscript b/Robust/src/buildscript index e5e5f65c..1ee6e48c 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -192,7 +192,7 @@ $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c" if $DSMFLAG then -EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -I$DSMRUNTIME" +EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -I$DSMRUNTIME" FILES="$FILES $DSMRUNTIME/trans.c $DSMRUNTIME/mcpileq.c $DSMRUNTIME/objstr.c $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $DSMRUNTIME/localobjects.c" fi -- 2.34.1