From 739e62fa058600258797cbda2251804bba7519ff Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 25 Apr 2008 21:49:17 +0000 Subject: [PATCH] Debug Barrier --- .../Prefetch/Moldyn/dsm/DebugBarrier.java | 54 +++++++++++++++++++ .../Benchmarks/Prefetch/Moldyn/dsm/makefile | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Robust/src/Benchmarks/Prefetch/Moldyn/dsm/DebugBarrier.java diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/DebugBarrier.java b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/DebugBarrier.java new file mode 100644 index 00000000..f9455db8 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/DebugBarrier.java @@ -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; + } + } + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile index 59051f96..7b6529e6 100644 --- a/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile +++ b/Robust/src/Benchmarks/Prefetch/Moldyn/dsm/makefile @@ -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 -- 2.34.1