From 04a610a479d7012b3f430af412f7b2d090647d6e Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 8 Apr 2009 00:02:39 +0000 Subject: [PATCH] collect statistics --- .../Benchmarks/SingleTM/LeeRouting/Grid.java | 4 +- .../Benchmarks/SingleTM/LeeRouting/makefile | 2 +- Robust/src/ClassLibrary/JavaSTM/Object.java | 4 +- Robust/src/IR/Flat/BuildCode.java | 44 +++++++++++-------- Robust/src/Runtime/STM/stm.c | 15 +++++++ Robust/src/Runtime/STM/tm.h | 9 ++++ Robust/src/buildscript | 7 +-- 7 files changed, 55 insertions(+), 30 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/LeeRouting/Grid.java b/Robust/src/Benchmarks/SingleTM/LeeRouting/Grid.java index 5fce2b96..9efa4d8c 100644 --- a/Robust/src/Benchmarks/SingleTM/LeeRouting/Grid.java +++ b/Robust/src/Benchmarks/SingleTM/LeeRouting/Grid.java @@ -72,9 +72,7 @@ public class Grid { instantiateGrid(debugGrid); resetGrid(debugGrid); } else { - //debugGrid = new GridCell[width][height][depth]; - //FIXME compiler error:Type of rside (null) not compatible with type of lside (GridCell)debugGrid = null - debugGrid = null; + debugGrid = new GridCell[width][height][depth]; } } diff --git a/Robust/src/Benchmarks/SingleTM/LeeRouting/makefile b/Robust/src/Benchmarks/SingleTM/LeeRouting/makefile index eb00b053..e4f0912f 100644 --- a/Robust/src/Benchmarks/SingleTM/LeeRouting/makefile +++ b/Robust/src/Benchmarks/SingleTM/LeeRouting/makefile @@ -5,7 +5,7 @@ SRC=${MAINCLASS}.java \ GridCell.java \ LeeThread.java \ WorkQueue.java -FLAGS=-singleTM -nooptimize -debug -mainclass ${MAINCLASS} +FLAGS=-singleTM -optimize -profile -mainclass ${MAINCLASS} -joptimize -debug -garbagestats -transstats default: ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC} diff --git a/Robust/src/ClassLibrary/JavaSTM/Object.java b/Robust/src/ClassLibrary/JavaSTM/Object.java index fecc4cd1..2e85d02f 100644 --- a/Robust/src/ClassLibrary/JavaSTM/Object.java +++ b/Robust/src/ClassLibrary/JavaSTM/Object.java @@ -1,9 +1,9 @@ public class Object { public int cachedCode; //first field has to be a primitive public boolean cachedHash; - public Object objlocation; - public int objstatus; public native int nativehashCode(); + private int objstatus; + private Object objlocation; public int hashCode() { if (!cachedHash) { diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 38c761a2..07fab7f8 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -224,9 +224,11 @@ public class BuildCode { private void outputMainMethod(PrintWriter outmethod) { outmethod.println("int main(int argc, const char *argv[]) {"); outmethod.println(" int i;"); - outmethod.println("#ifdef TRANSSTATS \n"); - outmethod.println("handle();\n"); - outmethod.println("#endif\n"); + if (state.DSM) { + outmethod.println("#ifdef TRANSSTATS \n"); + outmethod.println("handle();\n"); + outmethod.println("#endif\n"); + } if (state.THREAD||state.DSM||state.SINGLETM) { outmethod.println("initializethreads();"); } @@ -292,8 +294,6 @@ public class BuildCode { outmethod.println("threadcount--;"); outmethod.println("pthread_cond_signal(&gccond);"); outmethod.println("pthread_mutex_unlock(&gclistlock);"); - if (state.THREAD||state.SINGLETM) - outmethod.println("pthread_exit(NULL);"); } if (state.DSM||state.SINGLETM) { @@ -301,15 +301,21 @@ public class BuildCode { outmethod.println("printf(\"****** Transaction Stats ******\\n\");"); outmethod.println("printf(\"numTransAbort= %d\\n\", numTransAbort);"); outmethod.println("printf(\"numTransCommit= %d\\n\", numTransCommit);"); - outmethod.println("printf(\"nchashSearch= %d\\n\", nchashSearch);"); - outmethod.println("printf(\"nmhashSearch= %d\\n\", nmhashSearch);"); - outmethod.println("printf(\"nprehashSearch= %d\\n\", nprehashSearch);"); - outmethod.println("printf(\"nRemoteReadSend= %d\\n\", nRemoteSend);"); outmethod.println("printf(\"nSoftAbort= %d\\n\", nSoftAbort);"); - outmethod.println("printf(\"bytesSent= %d\\n\", bytesSent);"); - outmethod.println("printf(\"bytesRecv= %d\\n\", bytesRecv);"); + if (state.DSM) { + outmethod.println("printf(\"nchashSearch= %d\\n\", nchashSearch);"); + outmethod.println("printf(\"nmhashSearch= %d\\n\", nmhashSearch);"); + outmethod.println("printf(\"nprehashSearch= %d\\n\", nprehashSearch);"); + outmethod.println("printf(\"nRemoteReadSend= %d\\n\", nRemoteSend);"); + outmethod.println("printf(\"bytesSent= %d\\n\", bytesSent);"); + outmethod.println("printf(\"bytesRecv= %d\\n\", bytesRecv);"); + } outmethod.println("#endif\n"); } + + if (state.THREAD||state.SINGLETM) + outmethod.println("pthread_exit(NULL);"); + outmethod.println("}"); } @@ -776,14 +782,16 @@ public class BuildCode { outclassdefs.print("#ifdef TRANSSTATS \n"); outclassdefs.print("extern int numTransAbort;\n"); outclassdefs.print("extern int numTransCommit;\n"); - outclassdefs.print("extern int nchashSearch;\n"); - outclassdefs.print("extern int nmhashSearch;\n"); - outclassdefs.print("extern int nprehashSearch;\n"); - outclassdefs.print("extern int nRemoteSend;\n"); outclassdefs.print("extern int nSoftAbort;\n"); - outclassdefs.print("extern int bytesSent;\n"); - outclassdefs.print("extern int bytesRecv;\n"); - outclassdefs.print("extern void handle();\n"); + if (state.DSM) { + outclassdefs.print("extern int nchashSearch;\n"); + outclassdefs.print("extern int nmhashSearch;\n"); + outclassdefs.print("extern int nprehashSearch;\n"); + outclassdefs.print("extern int nRemoteSend;\n"); + outclassdefs.print("extern int bytesSent;\n"); + outclassdefs.print("extern int bytesRecv;\n"); + outclassdefs.print("extern void handle();\n"); + } outclassdefs.print("#endif\n"); outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n"); diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index 56598009..56680152 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -15,6 +15,12 @@ /* Thread transaction variables */ __thread objstr_t *t_cache; +#ifdef TRANSSTATS +int numTransCommit = 0; +int numTransAbort = 0; +int nSoftAbort = 0; +#endif + /* ================================================== * stmStartup @@ -166,17 +172,26 @@ int transCommit() { /* Look through all the objects in the transaction hash table */ int finalResponse = traverseCache(); if(finalResponse == TRANS_ABORT) { +#ifdef TRANSSTATS + numTransAbort++; +#endif objstrDelete(t_cache); t_chashDelete(); return TRANS_ABORT; } if(finalResponse == TRANS_COMMIT) { +#ifdef TRANSSTATS + numTransCommit++; +#endif objstrDelete(t_cache); t_chashDelete(); return 0; } /* wait a random amount of time before retrying to commit transaction*/ if(finalResponse == TRANS_SOFT_ABORT) { +#ifdef TRANSSTATS + nSoftAbort++; +#endif randomdelay(); } else { printf("Error: in %s() Unknown outcome", __func__); diff --git a/Robust/src/Runtime/STM/tm.h b/Robust/src/Runtime/STM/tm.h index ad38145a..c5df6447 100644 --- a/Robust/src/Runtime/STM/tm.h +++ b/Robust/src/Runtime/STM/tm.h @@ -114,6 +114,15 @@ typedef struct newObjCreated { } newObjCreated_t; +#ifdef TRANSSTATS +/*********************************** + * Global Variables for statistics + **********************************/ +extern int numTransCommit; +extern int numTransAbort; +extern int nSoftAbort; +#endif + /* ================================ * Functions used * ================================ diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 02ddb88e..193f55e8 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -65,7 +65,6 @@ CHECKFLAG=false RECOVERFLAG=false MLPFLAG=false MULTICOREFLAG=false -TRANSSTATSFLAG=false RAWFLAG=false RAWCACHEFLUSHFLAG=false RAWCONFIG='' @@ -152,7 +151,7 @@ then JAVAOPTS="$JAVAOPTS -prefetch" elif [[ $1 = '-transstats' ]] then -TRANSSTATSFLAG=true +EXTRAOPTIONS="$EXTRAOPTIONS -DTRANSSTATS" elif [[ $1 = '-printflat' ]] then JAVAOPTS="$JAVAOPTS -printflat" @@ -479,10 +478,6 @@ $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c" if $DSMFLAG then EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -DDSTM -I$DSMRUNTIME" -if $TRANSSTATSFLAG -then -EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DTRANSSTATS -DCOMPILER -DDSTM -I$DSMRUNTIME" -fi FILES="$FILES $DSMRUNTIME/trans.c $DSMRUNTIME/mcpileq.c $DSMRUNTIME/objstr.c $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/threadnotify.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $ROBUSTROOT/Runtime/localobjects.c $ROBUSTROOT/Runtime/thread.c $DSMRUNTIME/sockpool.c $DSMRUNTIME/addUdpEnhance.c $DSMRUNTIME/signal.c $DSMRUNTIME/gCollect.c $DSMRUNTIME/addPrefetchEnhance.c $DSMRUNTIME/dsmlock.c $DSMRUNTIME/prefetch.c" fi -- 2.34.1