From d48a4d1ba868e1d38c837725368ec408de6d4bce Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 15 May 2009 05:31:06 +0000 Subject: [PATCH] this change isn't all that well tested... but it lets us declare intwrapper, doublewrapper types which work just like the primitives but are really objects behind the scenes --- .../SingleTM/KMeans/GlobalArgs.java | 2 +- .../Benchmarks/SingleTM/KMeans/Normal.java | 5 +- .../src/Benchmarks/SingleTM/KMeans/makefile | 6 +- Robust/src/IR/Flat/BuildFlat.java | 61 ++++++++++++++----- Robust/src/IR/Tree/ArrayAccessNode.java | 10 ++- Robust/src/IR/Tree/NameNode.java | 4 +- Robust/src/IR/Tree/SemanticCheck.java | 37 ++++++++++- Robust/src/IR/TypeDescriptor.java | 14 +++++ Robust/src/Runtime/STM/stm.c | 9 ++- Robust/src/Runtime/STM/tm.h | 3 + 10 files changed, 121 insertions(+), 30 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/GlobalArgs.java b/Robust/src/Benchmarks/SingleTM/KMeans/GlobalArgs.java index d6e8b61b..6285ae75 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/GlobalArgs.java +++ b/Robust/src/Benchmarks/SingleTM/KMeans/GlobalArgs.java @@ -61,7 +61,7 @@ public class GlobalArgs { /** * Number of points in each cluster [nclusters] **/ - public int[] new_centers_len; + public intwrapper[] new_centers_len; /** * New centers of the clusters [nclusters][nfeatures] diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/Normal.java b/Robust/src/Benchmarks/SingleTM/KMeans/Normal.java index 93f3bf74..590fae23 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/Normal.java +++ b/Robust/src/Benchmarks/SingleTM/KMeans/Normal.java @@ -104,7 +104,7 @@ public class Normal { int nclusters = args.nclusters; int[] membership = args.membership; double[][] clusters = args.clusters; - int[] new_centers_len = args.new_centers_len; + intwrapper[] new_centers_len = args.new_centers_len; double[][] new_centers = args.new_centers; double delta = 0.0; int index, start, stop; @@ -194,7 +194,8 @@ public class Normal { * Need to initialize new_centers_len and new_centers[0] to all 0. * Allocate clusters on different cache lines to reduce false sharing. */ - int[] new_centers_len = new int[nclusters]; + intwrapper[] new_centers_len = new intwrapper[nclusters]; + double[][] new_centers = new double[nclusters][nfeatures]; int loop = 0; diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/makefile b/Robust/src/Benchmarks/SingleTM/KMeans/makefile index 920e1298..a2771204 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/makefile +++ b/Robust/src/Benchmarks/SingleTM/KMeans/makefile @@ -6,14 +6,12 @@ SRC=${MAINCLASS}.java \ Common.java \ GlobalArgs.java \ ../../../ClassLibrary/JavaSTM/Barrier.java -FLAGS=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -joptimize -transstats -stmstats -FLAGS2=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -joptimize -transstats +FLAGS=-mainclass ${MAINCLASS} -singleTM -optimize -debug -dcopts -joptimize -stmstats -fastmemcpy +FLAGS2=-mainclass ${MAINCLASS} -singleTM -optimize -debug -joptimize -dcopts -fastmemcpy FLAGS3=-mainclass ${MAINCLASS} -optimize -debug -joptimize -thread default: - ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC} - ../../../buildscript ${FLAGS3} -o LOCK${MAINCLASS} ${SRC} ../../../buildscript ${FLAGS2} -o GEN${MAINCLASS} ${SRC} clean: diff --git a/Robust/src/IR/Flat/BuildFlat.java b/Robust/src/IR/Flat/BuildFlat.java index d1b7ae92..ea908a1f 100644 --- a/Robust/src/IR/Flat/BuildFlat.java +++ b/Robust/src/IR/Flat/BuildFlat.java @@ -286,6 +286,10 @@ public class BuildFlat { NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0, con.isGlobal()); fn.addNext(np.getBegin()); return new NodePair(first,np.getEnd()); + } else if (td.isArray()&&td.dereference().iswrapper()) { + NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0, con.isGlobal()); + fn.addNext(np.getBegin()); + return new NodePair(first,np.getEnd()); } else return new NodePair(first, fn); } @@ -309,7 +313,7 @@ public class BuildFlat { fcb.setLoop(); //is indexlnext; } - //THIS IS THE SERIALIZATION POINT ***** - for(i=numoidrdlocked-1; i>=0; i--) { + + + //THIS IS THE SERIALIZATION END POINT (START POINT IS END OF EXECUTION)***** + + for(i=0; ilock>=0) { diff --git a/Robust/src/Runtime/STM/tm.h b/Robust/src/Runtime/STM/tm.h index a68963ef..d82ecfd9 100644 --- a/Robust/src/Runtime/STM/tm.h +++ b/Robust/src/Runtime/STM/tm.h @@ -42,11 +42,14 @@ typedef struct threadrec { typedef struct objheader { unsigned int version; unsigned int lock; /* reader and writer lock for object header */ +#ifdef STMSTATS int abortCount; /* track how many times does this object cause abort */ int accessCount; /* track how many times is this object accessed */ threadrec_t *trec; /* some thread that locked this object */ int riskyflag; /* track how risky is the object */ pthread_mutex_t *objlock; /* lock this object */ + int padding; +#endif } objheader_t; #define OID(x) \ -- 2.34.1