Debug Barrier
authorbdemsky <bdemsky>
Fri, 25 Apr 2008 21:49:17 +0000 (21:49 +0000)
committerbdemsky <bdemsky>
Fri, 25 Apr 2008 21:49:17 +0000 (21:49 +0000)
Robust/src/Benchmarks/Prefetch/Moldyn/dsm/DebugBarrier.java [new file with mode: 0644]
Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile

diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/DebugBarrier.java b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/DebugBarrier.java
new file mode 100644 (file)
index 0000000..f9455db
--- /dev/null
@@ -0,0 +1,54 @@
+public class Barrier {
+  int numthreads;
+  int entercount;
+  boolean cleared;
+
+  public Barrier(int n) {
+      System.printString("Initializing barrier for "+n+" threads.\n");
+    numthreads=n;
+    cleared = false;
+    entercount = 0;
+  }
+
+  public Barrier() {
+  }
+
+  public void reset() {
+    cleared = false;
+    entercount = 0;
+  }
+
+  public static void enterBarrier(Barrier b) {
+    int tmp;
+    boolean retry=true;
+
+    do {
+      atomic {
+         System.printString("Entering barrier with ec="+b.entercount+" cl="+b.cleared+"\n");
+        if (!b.cleared) {
+          b.entercount++;
+          tmp = b.entercount;
+          if (tmp==b.numthreads) {
+            if(b.numthreads > 1)
+              b.cleared=true;
+            b.entercount--;
+            return;
+          }
+          retry=false;
+        }
+      }
+    } while(retry);
+
+    while(true) {
+      atomic {
+        if (b.cleared) {
+          b.entercount--;
+          int count = b.entercount;
+          if (count==0)
+            b.cleared=false;
+          return;
+        }
+      }
+    }
+  }
+}
index 59051f96b6233035c5d0c3e98a027249745c8ddd..7b6529e65b3e432c48161b0a1e61ca449a50f3ec 100644 (file)
@@ -3,7 +3,7 @@ SRC=${MAINCLASS}.java \
 JGFInstrumentor.java \
 JGFTimer.java \
 JGFMolDynBench.java \
-Barrier.java
+DebugBarrier.java
 FLAGS=-dsm -prefetch -excprefetch particle.force -excprefetch particle.domove -excprefetch particle.mkekin -excprefetch TournamentBarrier.DoBarrier -excprefetch JGFMolDynBench.JGFvalidate -excprefetch JGFMolDynBench.JGFapplication -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8
 FLAGS2=-dsm -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP