From 893067e927a111fd5003e231307380a2fed512bd Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 19 Nov 2008 23:19:43 +0000 Subject: [PATCH] changes to build SOR java version --- .../SOR/javasingle/JGFInstrumentor.java | 30 +++++++++---------- .../Prefetch/SOR/javasingle/JGFSORBench.java | 23 +++++++------- .../SOR/javasingle/JGFSORBenchSizeA.java | 4 +-- .../SOR/javasingle/JGFSORBenchSizeC.java | 4 +-- .../Prefetch/SOR/javasingle/JGFTimer.java | 20 ++++++------- .../Prefetch/SOR/javasingle/makefile | 2 +- Robust/src/ClassLibrary/Math.java | 8 +++++ Robust/src/ClassLibrary/String.java | 4 +++ 8 files changed, 52 insertions(+), 43 deletions(-) diff --git a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFInstrumentor.java b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFInstrumentor.java index 69baf77f..bfacd31f 100644 --- a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFInstrumentor.java +++ b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFInstrumentor.java @@ -31,7 +31,7 @@ public class JGFInstrumentor{ public static void addTimer (String name, HashMap timers){ if (timers.containsKey(name)) { - System.out.println("JGFInstrumentor.addTimer: warning - timer " + name + + System.printString("JGFInstrumentor.addTimer: warning - timer " + name + " already exists"); } else { @@ -42,7 +42,7 @@ public class JGFInstrumentor{ public static void addTimer (String name, String opname, HashMap timers){ if (timers.containsKey(name)) { - System.out.println("JGFInstrumentor.addTimer: warning - timer " + name + + System.printString("JGFInstrumentor.addTimer: warning - timer " + name + " already exists"); } else { @@ -54,7 +54,7 @@ public class JGFInstrumentor{ public static void addTimer (String name, String opname, int size, HashMap timers){ if (timers.containsKey(name)) { - System.out.println("JGFInstrumentor.addTimer: warning - timer " + name + + System.printString("JGFInstrumentor.addTimer: warning - timer " + name + " already exists"); } else { @@ -68,7 +68,7 @@ public class JGFInstrumentor{ ((JGFTimer) timers.get(name)).start(); } else { - System.out.println("JGFInstrumentor.startTimer: failed - timer " + name + + System.printString("JGFInstrumentor.startTimer: failed - timer " + name + " does not exist"); } @@ -79,7 +79,7 @@ public class JGFInstrumentor{ ((JGFTimer) timers.get(name)).stop(); } else { - System.out.println("JGFInstrumentor.stopTimer: failed - timer " + name + + System.printString("JGFInstrumentor.stopTimer: failed - timer " + name + " does not exist"); } } @@ -89,7 +89,7 @@ public class JGFInstrumentor{ ((JGFTimer) timers.get(name)).addops(count); } else { - System.out.println("JGFInstrumentor.addOpsToTimer: failed - timer " + name + + System.printString("JGFInstrumentor.addOpsToTimer: failed - timer " + name + " does not exist"); } } @@ -99,7 +99,7 @@ public class JGFInstrumentor{ ((JGFTimer) timers.get(name)).addtime(added_time); } else { - System.out.println("JGFInstrumentor.addTimeToTimer: failed - timer " + name + + System.printString("JGFInstrumentor.addTimeToTimer: failed - timer " + name + " does not exist"); } @@ -113,7 +113,7 @@ public class JGFInstrumentor{ time = ((JGFTimer) timers.get(name)).time; } else { - System.out.println("JGFInstrumentor.readTimer: failed - timer " + name + + System.printString("JGFInstrumentor.readTimer: failed - timer " + name + " does not exist"); time = 0.0; } @@ -125,7 +125,7 @@ public class JGFInstrumentor{ ((JGFTimer) timers.get(name)).reset(); } else { - System.out.println("JGFInstrumentor.resetTimer: failed - timer " + name + + System.printString("JGFInstrumentor.resetTimer: failed - timer " + name + " does not exist"); } } @@ -135,7 +135,7 @@ public class JGFInstrumentor{ ((JGFTimer) timers.get(name)).print(); } else { - System.out.println("JGFInstrumentor.printTimer: failed - timer " + name + + System.printString("JGFInstrumentor.printTimer: failed - timer " + name + " does not exist"); } } @@ -145,7 +145,7 @@ public class JGFInstrumentor{ ((JGFTimer) timers.get(name)).printperf(); } else { - System.out.println("JGFInstrumentor.printTimer: failed - timer " + name + + System.printString("JGFInstrumentor.printTimer: failed - timer " + name + " does not exist"); } } @@ -186,15 +186,15 @@ public class JGFInstrumentor{ header = base + "3 - Size B"; } - System.out.println(header); + System.printString(header); if (nthreads == 1) { - System.out.println("Executing on " + nthreads + " thread"); + System.printString("Executing on " + nthreads + " thread"); } else { - System.out.println("Executing on " + nthreads + " threads"); + System.printString("Executing on " + nthreads + " threads"); } - System.out.println(""); + System.printString(""); } } diff --git a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBench.java b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBench.java index b0d6c4b4..3155ab01 100644 --- a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBench.java +++ b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBench.java @@ -86,17 +86,11 @@ public class JGFSORBench { thobjects[0] = new SORRunner(0,omega,G,num_iterations,sor.sync,numthreads); thobjects[0].start(); - try { - thobjects[0].join(); - } - catch (InterruptedException e) {} + thobjects[0].join(); for(int i=1;i 1.0e-12 ){ - System.out.println("Validation failed"); - System.out.println("Gtotal = " + Gtotal + " " + dev + " " + size); - } + double refval[]=new double[3]; + refval[0]=0.498574406322512; + refval[1]=1.1234778980135105; + refval[2]=1.9954895063582696; + double dev = Math.abs(Gtotal - refval[size]); + if (dev > 1.0e-12 ){ + System.printString("Validation failed"); + System.printString("Gtotal = " + Gtotal + " " + dev + " " + size); + } } /* diff --git a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBenchSizeA.java b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBenchSizeA.java index c78f29a6..7b50df8f 100644 --- a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBenchSizeA.java +++ b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBenchSizeA.java @@ -28,8 +28,8 @@ public class JGFSORBenchSizeA{ if(argv.length != 0 ) { nthreads = Integer.parseInt(argv[0]); } else { - System.out.println("The no of threads has not been specified, defaulting to 1"); - System.out.println(" "); + System.printString("The no of threads has not been specified, defaulting to 1"); + System.printString(" "); nthreads = 1; } diff --git a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBenchSizeC.java b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBenchSizeC.java index 4a96077b..71b30f19 100644 --- a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBenchSizeC.java +++ b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFSORBenchSizeC.java @@ -26,8 +26,8 @@ public class JGFSORBenchSizeC{ if(argv.length != 0 ) { nthreads = Integer.parseInt(argv[0]); } else { - System.out.println("The no of threads has not been specified, defaulting to 1"); - System.out.println(" "); + System.printString("The no of threads has not been specified, defaulting to 1"); + System.printString(" "); nthreads = 1; } diff --git a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFTimer.java b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFTimer.java index cf4daf57..72a2a9b5 100644 --- a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFTimer.java +++ b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/JGFTimer.java @@ -54,7 +54,7 @@ public class JGFTimer { public void start(){ - if (on) System.out.println("Warning timer " + " was already turned on"); + if (on) System.printString("Warning timer " + " was already turned on"); on = true; start_time = System.currentTimeMillis(); } @@ -62,7 +62,7 @@ public class JGFTimer { public void stop(){ time += (double) (System.currentTimeMillis()-start_time) / 1000.; - if (!on) System.out.println("Warning timer " + " wasn't turned on"); + if (!on) System.printString("Warning timer " + " wasn't turned on"); calls++; on = false; } @@ -87,23 +87,23 @@ public class JGFTimer { } public void longprint(){ - System.out.println("Timer Calls Time(s) Performance("+opname+"/s)"); - System.out.println(name + " " + calls + " " + time + " " + this.perf()); + System.printString("Timer Calls Time(s) Performance("+opname+"/s)"); + System.printString(name + " " + calls + " " + time + " " + this.perf()); } public void print(){ if (opname.equals("")) { - System.out.println(name + " " + time + " (s)"); + System.printString(name + " " + time + " (s)"); } else { if(size == 0) { - System.out.println(name + ":SizeA" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); + System.printString(name + ":SizeA" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); } else if (size == 1) { - System.out.println(name + ":SizeB" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); + System.printString(name + ":SizeB" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); } else if (size == 2) { - System.out.println(name + ":SizeC" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); + System.printString(name + ":SizeC" + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); } else{ - System.out.println(name + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); + System.printString(name + "\t" + time + " (s) \t " + this.perf() + "\t" + " ("+opname+"/s)"); } } } @@ -117,7 +117,7 @@ public class JGFTimer { // pad name to 40 characters while ( name.length() < 40 ) name = name + " "; - System.out.println(name + "\t" + this.perf() + "\t" + System.printString(name + "\t" + this.perf() + "\t" + " ("+opname+"/s)"); } diff --git a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/makefile b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/makefile index a430bb51..3e1a37c8 100644 --- a/Robust/src/Benchmarks/Prefetch/SOR/javasingle/makefile +++ b/Robust/src/Benchmarks/Prefetch/SOR/javasingle/makefile @@ -1,4 +1,4 @@ -MAINCLASS=JGFSORBenchSizeC +MAINCLASS=JGFSORBenchSizeA SRC=${MAINCLASS}.java \ JGFInstrumentor.java \ JGFTimer.java \ diff --git a/Robust/src/ClassLibrary/Math.java b/Robust/src/ClassLibrary/Math.java index 6f3e56bd..8a500e46 100644 --- a/Robust/src/ClassLibrary/Math.java +++ b/Robust/src/ClassLibrary/Math.java @@ -13,6 +13,14 @@ public class Math { } } + public static double abs(double x) { + if (x < 0) { + return -x; + } else { + return x; + } + } + public static float abs(float a) { if (a<0) return -a; diff --git a/Robust/src/ClassLibrary/String.java b/Robust/src/ClassLibrary/String.java index 6ae7fcfa..5bdaf0fb 100644 --- a/Robust/src/ClassLibrary/String.java +++ b/Robust/src/ClassLibrary/String.java @@ -270,6 +270,10 @@ public class String { return new String(chararray); } + public static String valueOf(double x) { + return valueOf((long)x); + } + public static String valueOf(long x) { int length=0; long tmp; -- 2.34.1