2 /*import java.util.Enumeration;
3 import java.lang.Math;*/
6 * A Java implementation of the <tt>bh</tt> Olden benchmark.
7 * The Olden benchmark implements the Barnes-Hut benchmark
8 * that is decribed in :
10 * J. Barnes and P. Hut, "A hierarchical o(NlogN) force-calculation algorithm",
11 * Nature, 324:446-449, Dec. 1986
14 * The original code in the Olden benchmark suite is derived from the
15 * <a href="ftp://hubble.ifa.hawaii.edu/pub/barnes/treecode">
16 * source distributed by Barnes</a>.
18 public class TestRunner extends Thread
22 * The user specified number of bodies to create.
24 public int nbody; // = 0;
27 * The maximum number of time steps to take in the simulation
29 public int nsteps; // = 10;
32 * Should we print information messsages
34 //private static boolean printMsgs = false;
36 * Should we print detailed results
38 //private static boolean printResults = false;
40 public double DTIME; // = 0.0125;
41 public double TSTOP; // = 2.0;
43 public TestRunner(int nbody) {
55 System.out.println("nbody = " + nbody);*/
57 //long start0 = System.currentTimeMillis();
58 Tree root = new Tree(this.DTIME);
59 root.createTestData(nbody);
60 /*long end0 = System.currentTimeMillis();
62 System.out.println("Bodies created");
64 long start1 = System.currentTimeMillis();*/
67 while ((tnow < (TSTOP + 0.1f*DTIME)) && (i < nsteps)) {
71 /*long end1 = System.currentTimeMillis();
75 for (Enumeration e = root.bodies(); e.hasMoreElements(); ) {
76 Body b = (Body)e.nextElement();
77 System.out.println("body " + j++ + " -- " + b.pos);
82 System.out.println("Build Time " + (end0 - start0)/1000.0);
83 System.out.println("Compute Time " + (end1 - start1)/1000.0);
84 System.out.println("Total Time " + (end1 - start0)/1000.0);
86 System.out.println("Done!");*/
90 * Random number generator used by the orignal BH benchmark.
91 * @param seed the seed to the generator
92 * @return a random number
94 public double myRand(double seed)
96 double t = 16807.0*seed + 1;
98 seed = t - 2147483647.0 * Math.floor(t / 2147483647.0f);
103 * Generate a doubleing point random number. Used by
104 * the original BH benchmark.
106 * @param xl lower bound
107 * @param xh upper bound
109 * @return a doubleing point randon number
111 public double xRand(double xl, double xh, double r)
113 double res = xl + (xh-xl)*r/2147483647.0;
117 public static void main(String[] args) {
120 for(int i = 0; i < threadnum; ++i) {
121 TestRunner tr = new TestRunner(nbody);