+++ /dev/null
-/**************************************************************************
-* *
-* Java Grande Forum Benchmark Suite - Thread Version 1.0 *
-* *
-* produced by *
-* *
-* Java Grande Benchmarking Project *
-* *
-* at *
-* *
-* Edinburgh Parallel Computing Centre *
-* *
-* email: epcc-javagrande@epcc.ed.ac.uk *
-* *
-* *
-* This version copyright (c) The University of Edinburgh, 2001. *
-* All rights reserved. *
-* *
-**************************************************************************/
-
-public class JGFMolDynBench {
-
- public static void main(String args[]) {
- int datasize = 8; //8,13
- int group = 16;
- MD md = new MD(datasize, group);
- md.initialise();
- int movemx = 50;
-
-
- for (int move=0;move<movemx;move++) {
- md.domove();
- md.init();
-
- for(int i = 0; i < md.group; ++i) {
- MDRunner runner = new MDRunner(i, md);
- runner.init();
- runner.run();
- md.update(runner);
-
- }
- md.sum();
- md.scale();
- }
-
-
-
- md.validate();
-
- }
-
-}
-
+++ /dev/null
-package Benchmarks.oooJava.moldyn;
-
-/** Banboo Version */
-
-/**************************************************************************
- * * Java Grande Forum Benchmark Suite - Version 2.0 * * produced by * * Java
- * Grande Benchmarking Project * * at * * Edinburgh Parallel Computing Centre *
- * * email: epcc-javagrande@epcc.ed.ac.uk * * Original version of this code by *
- * Dieter Heermann * converted to Java by * Lorna Smith (l.smith@epcc.ed.ac.uk)
- * * (see copyright notice below) * * This version copyright (c) The University
- * of Edinburgh, 2001. * All rights reserved. * *
- **************************************************************************/
-
-public class MD {
- public int mm;
- public int group;
- public int mdsize;
- public int move;
- public int movemx;
-
- public float side;
- float hsq, hsq2, den, h, vaver, vaverh;
- float tref, tscale;
- int irep;
- int istop;
- int iprint;
-
- public Particle[] one;
- public float[][] sh_force;
- // public float[] epot;
- // public float[] vir;
- // public float[] ek;
- public float epot;
- public float vir;
- public float ek;
- float ekin;
-
- public int counter;
-
- public void MD(int d, int g) {
- this.mm = d;
- this.group = g;
- this.mdsize = this.mm * this.mm * this.mm * 4;
- this.one = new Particle[this.mdsize];
- this.sh_force = new float[3][this.mdsize];
- this.move = 0;
- this.movemx = 2;
- this.den = (float) 0.83134;
- this.h = (float) 0.064;
- this.side = Math.powf((float) (this.mdsize / this.den), (float) 0.3333333);
- this.hsq = this.h * this.h;
- this.hsq2 = this.hsq * (float) 0.5;
- this.vaver = (float) 1.13 * Math.sqrtf((float) this.tref / (float) 24.0);
- this.vaverh = this.vaver * this.h;
- this.irep = 10;
- this.istop = 19;
- // this.epot = (float)0.0;
- // this.vir = (float)0.0;
- this.tref = (float) 0.722;
- this.tscale = (float) 16.0 / ((float) 1.0 * (float) this.mdsize - (float) 1.0);
- this.iprint = 10;
- this.counter = 0;
-
- this.epot = (float) 0.0;// new float[this.group + 1];
- this.vir = (float) 0.0;// new float[this.group + 1];
- this.ek = (float) 0.0;// new float[this.group + 1];
- }
-
- public void init() {
- /*
- * for(int i = 0; i < this.group + 1; i++) { this.epot[i] = (float)0.0;
- * this.vir[i] = (float)0.0; }
- */
- this.epot = (float) 0.0;
- this.vir = (float) 0.0;
- for (int j = 0; j < 3; j++) {
- for (int i = 0; i < this.mdsize; i++) {
- this.sh_force[j][i] = (float) 0.0;
- }
- }
- this.counter = 0;
- }
-
- public void initialise() {
-
- /* Particle Generation */
- float xvelocity, yvelocity, zvelocity;
- int ijk, lg, i, j, k;
- float a = this.side / this.mm;
- xvelocity = (float) 0.0;
- yvelocity = (float) 0.0;
- zvelocity = (float) 0.0;
- // System.printString("here 1\n");
- // System.printI(0xa0);
- ijk = 0;
- for (lg = 0; lg <= 1; lg++) {
- for (i = 0; i < mm; i++) {
- for (j = 0; j < mm; j++) {
- for (k = 0; k < mm; k++) {
- one[ijk] =
- new Particle((float) (i * a + lg * a * (float) 0.5), (float) (j * a + lg * a
- * (float) 0.5), (k * a), xvelocity, yvelocity, zvelocity, this);
- ijk = ijk + 1;
- }
- }
- }
- }
- for (lg = 1; lg <= 2; lg++) {
- for (i = 0; i < mm; i++) {
- for (j = 0; j < mm; j++) {
- for (k = 0; k < mm; k++) {
- one[ijk] =
- new Particle((float) (i * a + (2 - lg) * a * (float) 0.5),
- (float) (j * a + (lg - 1) * a * (float) 0.5),
- (float) (k * a + a * (float) 0.5), xvelocity, yvelocity, zvelocity, this);
- ijk = ijk + 1;
- }
- }
- }
- }
- // System.printString("here 2\n");
- // System.printI(0xa1);
- /* Initialise velocities */
- int iseed;
- float v1, v2, r;
- iseed = 0;
- v1 = (float) 0.0;
- v2 = (float) 0.0;
-
- MyRandom random = new MyRandom(iseed, v1, v2);
- // System.printString("here 3\n");
- // System.printI(0xa2);
- for (i = 0; i < this.mdsize; i += 2) {
- r = random.seed();
- one[i].xvelocity = r * random.v1;
- one[i + 1].xvelocity = r * random.v2;
- }
- // System.printString("here 4\n");
- // System.printI(0xa3);
- for (i = 0; i < this.mdsize; i += 2) {
- r = random.seed();
- one[i].yvelocity = r * random.v1;
- one[i + 1].yvelocity = r * random.v2;
- }
- // System.printString("here 5\n");
- // System.printI(0xa4);
- for (i = 0; i < this.mdsize; i += 2) {
- r = random.seed();
- one[i].zvelocity = r * random.v1;
- one[i + 1].zvelocity = r * random.v2;
- }
-
- /*
- * for(i = 0; i < this.mdsize; i++) { System.printString("xvel: " +
- * (int)(one[i].xvelocity*100000) + "; yvel: " +
- * (int)(one[i].yvelocity*100000) + "; zvel: " +
- * (int)(one[i].zvelocity*100000) + "\n"); }
- */
-
- // System.printString("here 6\n");
- // System.printI(0xa5);
- /* velocity scaling */
- float sp, ts, sc;
- ekin = (float) 0.0;
- sp = (float) 0.0;
- // System.printString("here 7\n");
- // System.printI(0xa6);
- for (i = 0; i < this.mdsize; i++) {
- sp = sp + one[i].xvelocity;
- }
- sp = sp / this.mdsize;
- // System.printString("here 8\n");
- // System.printI(0xa7);
- for (i = 0; i < this.mdsize; i++) {
- one[i].xvelocity = one[i].xvelocity - sp;
- ekin = ekin + one[i].xvelocity * one[i].xvelocity;
- }
- // System.printString("here 9\n");
- // System.printI(0xa8);
- sp = (float) 0.0;
- for (i = 0; i < this.mdsize; i++) {
- sp = sp + one[i].yvelocity;
- }
- sp = sp / this.mdsize;
- // System.printString("here 10\n");
- // System.printI(0xa9);
- for (i = 0; i < this.mdsize; i++) {
- one[i].yvelocity = one[i].yvelocity - sp;
- ekin = ekin + one[i].yvelocity * one[i].yvelocity;
- }
- // System.printString("here 11\n");
- // System.printI(0xa10);
- sp = (float) 0.0;
- for (i = 0; i < this.mdsize; i++) {
- sp = sp + one[i].zvelocity;
- }
- sp = sp / this.mdsize;
- // System.printString("here 12\n");
- // System.printI(0xa11);
- for (i = 0; i < this.mdsize; i++) {
- one[i].zvelocity = one[i].zvelocity - sp;
- ekin = ekin + one[i].zvelocity * one[i].zvelocity;
- }
- // System.printString("here 13\n");
- // System.printI(0xa12);
- ts = this.tscale * ekin;
- sc = h * Math.sqrtf(this.tref / ts);
-
- for (i = 0; i < this.mdsize; i++) {
- one[i].xvelocity = one[i].xvelocity * sc;
- one[i].yvelocity = one[i].yvelocity * sc;
- one[i].zvelocity = one[i].zvelocity * sc;
- }
- // System.printString("here 14\n");
- // System.printI(0xa13);
- }
-
- public void domove() {
- for (int i = 0; i < this.mdsize; i++) {
- one[i].domove(this.side, i);
- }
-
- /*
- * for(int j=0;j<3;j++) { for (int i=0;i<mdsize;i++) { sh_force[j][i] =
- * (float)0.0; } }
- */
-
- this.move++;
- }
-
- public boolean finish() {
- if (this.move == this.movemx) {
- return true;
- }
- return false;
- }
-
- public void update(MDRunner runner) {
- float sum, vel, velt, count, sc;
- float etot, temp, pres, rp;
-
- /* update force arrays */
- for (int k = 0; k < 3; k++) {
- for (int i = 0; i < this.mdsize; i++) {
- sh_force[k][i] += runner.sh_force2[k][i];
- }
- }
-
- // runner.init();
-
- // this.epot[runner.id + 1] = runner.epot;
- // this.vir[runner.id + 1] = runner.vir;
- this.epot += runner.epot;
- this.vir += runner.vir;
- }
-
- public void sum() {
- float sum = (float) 0.0;
-
- for (int j = 0; j < 3; j++) {
- for (int i = 0; i < this.mdsize; i++) {
- sh_force[j][i] = sh_force[j][i] * hsq2;
- }
- }
-
- sum = (float) 0.0;
- for (int i = 0; i < this.mdsize; i++) {
- sum = sum + this.one[i].mkekin(hsq2, i);
- }
- ekin = (float) (sum / hsq);
- }
-
- public void scale() {
- float sum, vel, velt, count, sc;
- float etot, temp, pres, rp;
-
- // runner.epot = this.epot[0];
- // runner.vir = this.vir[0];
-
- vel = (float) 0.0;
- count = (float) 0.0;
-
- /* average velocity */
- for (int i = 0; i < this.mdsize; i++) {
- velt = this.one[i].velavg(vaverh, h);
- if (velt > vaverh) {
- count = count + (float) 1.0;
- }
- vel = vel + velt;
- }
- vel = (float) (vel / h);
-
- /* temperature scale if required */
- if ((this.move < this.istop) && (((this.move + 1) % this.irep) == 0)) {
- sc = Math.sqrtf(this.tref / (this.tscale * ekin));
- for (int i = 0; i < mdsize; i++) {
- one[i].dscal(sc, 1);
- }
- ekin = (float) (this.tref / this.tscale);
- }
-
- /* sum to get full potential energy and virial */
- if (((this.move + 1) % this.iprint) == 0) {
- /*
- * this.ek[runner.id+1] = (float)24.0*ekin; this.epot[runner.id+1] =
- * (float)4.0*this.epot[runner.id+1]; etot = this.ek[runner.id+1] +
- * this.epot[runner.id+1]; temp = this.tscale * ekin; pres = den *
- * (float)16.0 * (ekin - this.vir[runner.id+1]) / mdsize; vel = vel /
- * this.mdsize; rp = (count / this.mdsize) * (float)100.0;
- *
- * if(this.counter == this.group) {
- */
- this.ek = (float) 24.0 * ekin;
- // this.epot[0] = (float)4.0*this.epot[0];
- // etot = this.ek[0] + this.epot[0];
- // temp = this.tscale * ekin;
- // pres = den * (float)16.0 * (ekin - this.vir[0]) / mdsize;
- // vel = vel / this.mdsize;
- // rp = (count / this.mdsize) * (float)100.0;
- // System.printString("ek: " + (int)(this.ek*1000000) + " (" + this.move +
- // ")\n");
- // }
- }
- }
-
- public void validate() {
- float refval = (float) 1731.4306625334357;
- float dev = Math.abs(this.ek - refval);
- System.out.println("this.ek=" + this.ek);
- if (dev > 1.0e-10) {
- System.out.println("Validation failed\n");
- // System.printString("Kinetic Energy = " + (int)(this.ek*1000000) + "; "
- // + (int)(refval*1000000) + "\n");
- // System.printI(0xdddf);
- // System.printI((int)(this.ek[0]*1000000));
- // System.printI((int)(refval*1000000));
- // System.printI((int)(ek*10000));
- // System.printI((int)(refval*10000));
- } else {
- System.out.println("Validation success");
- }
- }
-}
+++ /dev/null
-public class MDRunner {
-
- public int id;
- int mm;
- int mdsize;
- public int group;
- public int ilow, iupper;
- //float l;
- float rcoff;
- //rcoffs,
- float side/*sideh,*/;
- //float rand;
- public float [][] sh_force2;
- public float epot;
- public float vir;
- public float ek;
- //int npartm,tint;
- //int iprint = 10;
- MD md;
- Particle[] one;
-
- public MDRunner(int id, MD m) {
- this.id=id;
- this.md = m;
- this.mm=this.md.mm;
- //this.l = 50e-10;
- this.mdsize = this.md.mdsize;
- this.group = this.md.group;
- this.side = this.md.side;
- this.rcoff = this.mm/(float)4.0;
-// this.rcoffs = this.rcoff * this.rcoff;
- //this.sideh = this.side * 0.5;
- //this.npartm = this.mdsize - 1;
- //this.iprint = 10;
- int slice = (this.mdsize - 1) / this.group + 1;
- this.ilow = this.id * slice;
- this.iupper = (this.id+1) * slice;
- if (this.iupper > this.mdsize ) {
- iupper = this.mdsize;
- }
- sh_force2 = new float[3][this.mdsize];
-
- this.one = this.md.one;
- this.epot = (float)0.0;//this.md.epot[id+1];
- this.vir = (float)0.0;//this.md.vir[id+1];
- this.ek = (float)0.0;//this.md.ek[id+1];
- }
-
- public void init() {
- this.epot = (float)0.0;
- this.vir = (float)0.0;
- for(int i = 0; i < this.mdsize; i++) {
- for(int j = 0; j < 3; j++) {
- this.sh_force2[j][i] = (float)0.0;
- }
- }
- }
-
- public void run() {
- /* compute forces */
- //System.printString("here 1: " + this.id + "\n");
- for (int i = this.ilow; i < this.iupper; i++) {
- one[i].force(side,rcoff,mdsize,i,this);
- }
- //System.printString("here 2: " + this.id + "\n");
- }
-
-}
\ No newline at end of file
+++ /dev/null
-public class MyRandom {
-
- public int iseed;
- public float v1,v2;
-
- public MyRandom(int iseed, float v1, float v2) {
- this.iseed = iseed;
- this.v1 = v1;
- this.v2 = v2;
- }
-
- public float update() {
-
- float rand;
- float scale= (float)4.656612875e-10;
-
- int is1,is2,iss2;
- int imult= 16807;
- int imod = 2147483647;
-
- if (iseed<=0) {
- iseed = 1;
- }
-
- is2 = iseed % 32768;
- is1 = (iseed-is2)/32768;
- iss2 = is2 * imult;
- is2 = iss2 % 32768;
- is1 = (is1 * imult+(iss2-is2) / 32768) % (65536);
-
- iseed = (is1 * 32768 + is2) % imod;
-
- rand = scale * iseed;
-
- return rand;
-
- }
-
- public float seed() {
-
- float s,u1,u2,r;
- s = (float)1.0;
- //do {
- //System.printI(0xb1);
- u1 = update();
- u2 = update();
-
- //System.printI(0xb2);
- v1 = (float)2.0 * u1 - (float)1.0;
- v2 = (float)2.0 * u2 - (float)1.0;
- s = v1*v1 + v2*v2;
- //System.printI(0xb3);
- //} while (s >= (float)1.0);
- s = s - (int)s;
- //System.printI(0xb4);
- r = Math.sqrtf((float)(-2.0*Math.logf(s))/(float)s);
- //System.printI(0xb5);
- return r;
-
- }
-}
+++ /dev/null
-public class Particle {
-
- public float xcoord, ycoord, zcoord;
- public float xvelocity,yvelocity,zvelocity;
- int id;
- //float [][] sh_force;
- //float [][][] sh_force2;
- MD md;
-
- public Particle(float xcoord, float ycoord, float zcoord, float xvelocity,
- float yvelocity,float zvelocity,/*float [][] sh_force,
- float [][][] sh_force2, int id, */MD m) {
-
- this.xcoord = xcoord;
- this.ycoord = ycoord;
- this.zcoord = zcoord;
- this.xvelocity = xvelocity;
- this.yvelocity = yvelocity;
- this.zvelocity = zvelocity;
- //this.sh_force = sh_force;
- //this.sh_force2 = sh_force2;
- this.id=id;
- this.md=m;
- }
-
- public void domove(float side,int part_id) {
- xcoord = xcoord + xvelocity + this.md.sh_force[0][part_id];
- ycoord = ycoord + yvelocity + this.md.sh_force[1][part_id];
- zcoord = zcoord + zvelocity + this.md.sh_force[2][part_id];
-
- if(xcoord < 0) { xcoord = xcoord + side; }
- if(xcoord > side) { xcoord = xcoord - side; }
- if(ycoord < 0) { ycoord = ycoord + side; }
- if(ycoord > side) { ycoord = ycoord - side; }
- if(zcoord < 0) { zcoord = zcoord + side; }
- if(zcoord > side) { zcoord = zcoord - side; }
-
- xvelocity = xvelocity + this.md.sh_force[0][part_id];
- yvelocity = yvelocity + this.md.sh_force[1][part_id];
- zvelocity = zvelocity + this.md.sh_force[2][part_id];
- //System.printI(0xc0);
- }
-
- public void force(float side, float rcoff,int mdsize,int x, MDRunner runner) {
- float sideh;
- float rcoffs;
-
- float fxi,fyi,fzi;
- float rd,rrd,rrd2,rrd3,rrd4,rrd6,rrd7,r148;
- float forcex,forcey,forcez;
-
- float xx, yy, zz;
-
- sideh = (float)0.5*side;
- rcoffs = rcoff*rcoff;
-
- fxi = (float)0.0;
- fyi = (float)0.0;
- fzi = (float)0.0;
- //System.printString("here 111: " + runner.id + "\n");
- for (int i=x+1;i<mdsize;i++) {
- xx = this.xcoord - this.md.one[i].xcoord;
- yy = this.ycoord - this.md.one[i].ycoord;
- zz = this.zcoord - this.md.one[i].zcoord;
-
- if(xx < (-sideh)) { xx = xx + side; }
- if(xx > (sideh)) { xx = xx - side; }
- if(yy < (-sideh)) { yy = yy + side; }
- if(yy > (sideh)) { yy = yy - side; }
- if(zz < (-sideh)) { zz = zz + side; }
- if(zz > (sideh)) { zz = zz - side; }
-
-
- rd = xx*xx + yy*yy + zz*zz;
-
- if(rd <= rcoffs) {
- rrd = (float)1.0/rd;
- rrd2 = rrd*rrd;
- rrd3 = rrd2*rrd;
- rrd4 = rrd2*rrd2;
- rrd6 = rrd2*rrd4;
- rrd7 = rrd6*rrd;
- runner.epot = runner.epot + (rrd6 - rrd3);
- r148 = rrd7 - (float)0.5*rrd4;
- runner.vir = runner.vir - rd*r148;
- forcex = xx * r148;
- fxi = fxi + forcex;
-
- runner.sh_force2[0][i] = runner.sh_force2[0][i] - forcex;
-
- forcey = yy * r148;
- fyi = fyi + forcey;
-
- runner.sh_force2[1][i] = runner.sh_force2[1][i] - forcey;
-
- forcez = zz * r148;
- fzi = fzi + forcez;
-
- runner.sh_force2[2][i] = runner.sh_force2[2][i] - forcez;
-
- //this.md.interacts[id]++;
- }
-
- }
- //System.printString("here 222: " + runner.id + "\n");
- runner.sh_force2[0][x] = runner.sh_force2[0][x] + fxi;
- runner.sh_force2[1][x] = runner.sh_force2[1][x] + fyi;
- runner.sh_force2[2][x] = runner.sh_force2[2][x] + fzi;
- //System.printString("here 333: " + runner.id + "\n");
- }
-
- public float mkekin(float hsq2,int part_id) {
- float sumt = (float)0.0;
-
- xvelocity = xvelocity + this.md.sh_force[0][part_id];
- yvelocity = yvelocity + this.md.sh_force[1][part_id];
- zvelocity = zvelocity + this.md.sh_force[2][part_id];
-
- sumt = (xvelocity*xvelocity)+(yvelocity*yvelocity)+(zvelocity*zvelocity);
- return sumt;
- }
-
- public float velavg(float vaverh,float h) {
- float velt;
- float sq;
-
- sq = Math.sqrtf(xvelocity*xvelocity + yvelocity*yvelocity + zvelocity*zvelocity);
-
- velt = sq;
- return velt;
- }
-
- public void dscal(float sc,int incx) {
- xvelocity = xvelocity * sc;
- yvelocity = yvelocity * sc;
- zvelocity = zvelocity * sc;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
-* *
-* Java Grande Forum Benchmark Suite - Thread Version 1.0 *
-* *
-* produced by *
-* *
-* Java Grande Benchmarking Project *
-* *
-* at *
-* *
-* Edinburgh Parallel Computing Centre *
-* *
-* email: epcc-javagrande@epcc.ed.ac.uk *
-* *
-* *
-* This version copyright (c) The University of Edinburgh, 2001. *
-* All rights reserved. *
-* *
-**************************************************************************/
-
-
-public class JGFMolDynBench extends md {
-
- public static int nthreads;
-
- public JGFMolDynBench(int nthreads) {
- this.nthreads=nthreads;
- }
-
-// int size;
-
- public void JGFsetsize(int size){
- this.size = size;
- }
-
- public void JGFinitialise(){
-
- initialise();
-
- }
-
- public void JGFapplication(){
-
- runiters();
-
- }
-
-
- public void JGFvalidate(){
- double refval[] = new double[2];
- refval[0]= 1731.4306625334357;
- refval[1]=7397.392307839352;
- double dev = Math.abs(ek[0] - refval[size]);
- if (dev > 1.0e-10 ){
- System.out.println("Validation failed");
- System.out.println("Kinetic Energy = " + ek[0] + " " + dev + " " + size);
- }
- }
-
- public void JGFrun(int size){
- JGFsetsize(size);
-
- JGFinitialise();
- JGFapplication();
- JGFvalidate();
-
- }
-
-
-}
-
+++ /dev/null
-/**************************************************************************
- * * Java Grande Forum Benchmark Suite - Thread Version 1.0 * * produced by * *
- * Java Grande Benchmarking Project * * at * * Edinburgh Parallel Computing
- * Centre * * email: epcc-javagrande@epcc.ed.ac.uk * * * This version copyright
- * (c) The University of Edinburgh, 2001. * All rights reserved. * *
- **************************************************************************/
-
-public class JGFMolDynBenchSizeB {
-
- public static void main(String argv[]) {
- int nthreads;
- 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(" ");
- nthreads = 1;
- }
- // JGFMolDynBench mold = new JGFMolDynBench(nthreads);
- // mold.JGFrun(1);
- md mold = new md();
- mold.JGFrun(1,nthreads);
- }
-}
+++ /dev/null
-import mlp.montecarlo.JGFTimer;
-
-/**************************************************************************
- * * Java Grande Forum Benchmark Suite - Version 2.0 * * produced by * * Java
- * Grande Benchmarking Project * * at * * Edinburgh Parallel Computing Centre *
- * * email: epcc-javagrande@epcc.ed.ac.uk * * Original version of this code by *
- * Dieter Heermann * converted to Java by * Lorna Smith (l.smith@epcc.ed.ac.uk)
- * * (see copyright notice below) * * This version copyright (c) The University
- * of Edinburgh, 2001. * All rights reserved. * *
- **************************************************************************/
-
-public class md {
-
- public static final int ITERS;
- public static final double LENGTH;
- public static final double m;
- public static final double mu;
- public static final double kb;
- public static final double TSIM;
- public static final double deltat;
-
- public static int PARTSIZE;
-
- public static double[] epot;
- public static double[] vir;
- public static double[] ek;
-
- int size, mm;
- int datasizes[];
-
- public static int interactions;
- public static int[] interacts;
-
- public static int nthreads;
-
- /////////////////
- double l, rcoff, rcoffs, side, sideh, hsq, hsq2, vel, velt;
- double a, r, sum, tscale, sc, ekin, ts, sp;
- double den;
- double tref;
- double h;
- double vaver, vaverh, rand;
- double etot, temp, pres, rp;
- double u1, u2, v1, v2, s, xx, yy, zz;
- double xvelocity, yvelocity, zvelocity;
- int id, i, j, k, lg, mdsize, move;
- particle one[];
- int ijk, npartm, iseed, tint;
- int irep;
- int istop;
- int iprint;
- int movemx;
- //////////////////
-
- // int size;
-
- public void JGFsetsize(int size) {
- this.size = size;
- }
-
- public void JGFinitialise() {
-
- initialise();
-
- }
-
- public void JGFapplication() {
-
- runiters();
-
- }
-
- public void JGFvalidate() {
- double refval[] = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dev = Math.abs(ek[0] - refval[size]);
- if (dev > 1.0e-10) {
- System.out.println("Validation failed");
- System.out.println("Kinetic Energy = " + ek[0] + " " + dev + " " + size);
- }
- }
-
- public void JGFrun(int size,int nthreads) {
- this.nthreads=nthreads;
-
- JGFsetsize(size);
-
- JGFinitialise();
- JGFapplication();
- JGFvalidate();
-
- }
-
- public md() {
- ITERS = 100;
- LENGTH = 50e-10;
- m = 4.0026;
- mu = 1.66056e-27;
- kb = 1.38066e-23;
- TSIM = 50;
- deltat = 5e-16;
-
- datasizes = new int[2];
- datasizes[0] = 8;
- datasizes[1] = 13;
-
- interactions = 0;
-
- }
-
- public void initialise() {
-
- mm = datasizes[size];
- PARTSIZE = mm * mm * mm * 4;
-
- }
-
- public void runiters() {
-
- /* Create new arrays */
-
- epot = new double[nthreads];
- vir = new double[nthreads];
- ek = new double[nthreads];
-
- interacts = new int[nthreads];
-
- double sh_force[][] = new double[3][PARTSIZE];
- double sh_force2[][][] = new double[3][nthreads][PARTSIZE];
-
-// mdRunner thobjects[] = new mdRunner[JGFMolDynBench.nthreads];
-// for (int i = 0; i < JGFMolDynBench.nthreads; i++) {
-// thobjects[i] = new mdRunner(i, mm, sh_force, sh_force2);
-// thobjects[0].run();
-// }
-
-
- /* Parameter determination */
-
- mdsize = PARTSIZE;
- one = new particle[mdsize];
- l = LENGTH;
-
- side = Math.pow((mdsize / den), 0.3333333);
- rcoff = mm / 4.0;
-
- a = side / mm;
- sideh = side * 0.5;
- hsq = h * h;
- hsq2 = hsq * 0.5;
- npartm = mdsize - 1;
- rcoffs = rcoff * rcoff;
- tscale = 16.0 / (1.0 * mdsize - 1.0);
- vaver = 1.13 * Math.sqrt(tref / 24.0);
- vaverh = vaver * h;
-
- /* Particle Generation */
-
- xvelocity = 0.0;
- yvelocity = 0.0;
- zvelocity = 0.0;
-
- ijk = 0;
- for (lg = 0; lg <= 1; lg++) {
- for (i = 0; i < mm; i++) {
- for (j = 0; j < mm; j++) {
- for (k = 0; k < mm; k++) {
- one[ijk] =
- new particle((i * a + lg * a * 0.5), (j * a + lg * a * 0.5), (k * a), xvelocity,
- yvelocity, zvelocity, sh_force, sh_force2, id);
- ijk = ijk + 1;
- }
- }
- }
- }
- for (lg = 1; lg <= 2; lg++) {
- for (i = 0; i < mm; i++) {
- for (j = 0; j < mm; j++) {
- for (k = 0; k < mm; k++) {
- one[ijk] =
- new particle((i * a + (2 - lg) * a * 0.5), (j * a + (lg - 1) * a * 0.5),
- (k * a + a * 0.5), xvelocity, yvelocity, zvelocity, sh_force, sh_force2, id
- );
- ijk = ijk + 1;
- }
- }
- }
- }
-
-
-
- }
-
-}
-
-class mdRunner {
-
- double count;
-
- int id, i, j, k, lg, mdsize, move, mm;
-
- double l, rcoff, rcoffs, side, sideh, hsq, hsq2, vel, velt;
- double a, r, sum, tscale, sc, ekin, ts, sp;
- double den;
- double tref;
- double h;
- double vaver, vaverh, rand;
- double etot, temp, pres, rp;
- double u1, u2, v1, v2, s, xx, yy, zz;
- double xvelocity, yvelocity, zvelocity;
-
- double[][] sh_force;
- double[][][] sh_force2;
-
- int ijk, npartm, iseed, tint;
- int irep;
- int istop;
- int iprint;
- int movemx;
-
- random randnum;
-
- particle one[];
-
- public double mdr_epot;
- public double mdr_vir;
- public int mdr_interacts;
- md md;
-
- public mdRunner(int id, int mm, double[][] sh_force, double[][][] sh_force2, md md) {
- count = 0.0;
- irep = 10;
- istop = 19;
- iprint = 10;
- movemx = 50;
- den = 0.83134;
- tref = 0.722;
- h = 0.064;
-
- this.id = id;
- this.mm = mm;
- this.sh_force = sh_force;
- this.sh_force2 = sh_force2;
- this.md=md;
- }
-
- public void run() {
-
- /* Parameter determination */
-
- mdsize = md.PARTSIZE;
- one = new particle[mdsize];
- l = md.LENGTH;
-
- side = Math.pow((mdsize / den), 0.3333333);
- rcoff = mm / 4.0;
-
- a = side / mm;
- sideh = side * 0.5;
- hsq = h * h;
- hsq2 = hsq * 0.5;
- npartm = mdsize - 1;
- rcoffs = rcoff * rcoff;
- tscale = 16.0 / (1.0 * mdsize - 1.0);
- vaver = 1.13 * Math.sqrt(tref / 24.0);
- vaverh = vaver * h;
-
- /* Particle Generation */
-
- xvelocity = 0.0;
- yvelocity = 0.0;
- zvelocity = 0.0;
-
- ijk = 0;
- for (lg = 0; lg <= 1; lg++) {
- for (i = 0; i < mm; i++) {
- for (j = 0; j < mm; j++) {
- for (k = 0; k < mm; k++) {
- one[ijk] =
- new particle((i * a + lg * a * 0.5), (j * a + lg * a * 0.5), (k * a), xvelocity,
- yvelocity, zvelocity, sh_force, sh_force2, id);
- ijk = ijk + 1;
- }
- }
- }
- }
- for (lg = 1; lg <= 2; lg++) {
- for (i = 0; i < mm; i++) {
- for (j = 0; j < mm; j++) {
- for (k = 0; k < mm; k++) {
- one[ijk] =
- new particle((i * a + (2 - lg) * a * 0.5), (j * a + (lg - 1) * a * 0.5),
- (k * a + a * 0.5), xvelocity, yvelocity, zvelocity, sh_force, sh_force2, id);
- ijk = ijk + 1;
- }
- }
- }
- }
-
- /* Initialise velocities */
-
- iseed = 0;
- v1 = 0.0;
- v2 = 0.0;
-
- randnum = new random(iseed, v1, v2);
-
- for (i = 0; i < mdsize; i += 2) {
- r = randnum.seed();
- one[i].xvelocity = r * randnum.v1;
- one[i + 1].xvelocity = r * randnum.v2;
- }
-
- for (i = 0; i < mdsize; i += 2) {
- r = randnum.seed();
- one[i].yvelocity = r * randnum.v1;
- one[i + 1].yvelocity = r * randnum.v2;
- }
-
- for (i = 0; i < mdsize; i += 2) {
- r = randnum.seed();
- one[i].zvelocity = r * randnum.v1;
- one[i + 1].zvelocity = r * randnum.v2;
- }
-
- /* velocity scaling */
-
- ekin = 0.0;
- sp = 0.0;
-
- for (i = 0; i < mdsize; i++) {
- sp = sp + one[i].xvelocity;
- }
- sp = sp / mdsize;
-
- for (i = 0; i < mdsize; i++) {
- one[i].xvelocity = one[i].xvelocity - sp;
- ekin = ekin + one[i].xvelocity * one[i].xvelocity;
- }
-
- sp = 0.0;
- for (i = 0; i < mdsize; i++) {
- sp = sp + one[i].yvelocity;
- }
- sp = sp / mdsize;
-
- for (i = 0; i < mdsize; i++) {
- one[i].yvelocity = one[i].yvelocity - sp;
- ekin = ekin + one[i].yvelocity * one[i].yvelocity;
- }
-
- sp = 0.0;
- for (i = 0; i < mdsize; i++) {
- sp = sp + one[i].zvelocity;
- }
- sp = sp / mdsize;
-
- for (i = 0; i < mdsize; i++) {
- one[i].zvelocity = one[i].zvelocity - sp;
- ekin = ekin + one[i].zvelocity * one[i].zvelocity;
- }
-
- ts = tscale * ekin;
- sc = h * Math.sqrt(tref / ts);
-
- for (i = 0; i < mdsize; i++) {
-
- one[i].xvelocity = one[i].xvelocity * sc;
- one[i].yvelocity = one[i].yvelocity * sc;
- one[i].zvelocity = one[i].zvelocity * sc;
-
- }
-
- /* Synchronise threads and start timer before MD simulation */
-
- // br.DoBarrier(id);
- // if (id == 0) JGFInstrumentor.startTimer("Section3:MolDyn:Run");
- // br.DoBarrier(id);
-
- /* MD simulation */
-
- move = 0;
- for (move = 0; move < movemx; move++) {
-
- /* move the particles and update velocities */
-
- for (i = 0; i < mdsize; i++) {
- one[i].domove(side, i);
- }
-
- /* Barrier */
- // br.DoBarrier(id);
-
- if (id == 0) {
- for (j = 0; j < 3; j++) {
- for (i = 0; i < mdsize; i++) {
- sh_force[j][i] = 0.0;
- }
- }
- }
-
- // md.epot[id] = 0.0;
- // md.vir[id] = 0.0;
- // md.interacts[id] = 0;
- mdr_epot = 0.0;
- mdr_vir = 0.0;
- mdr_interacts = 0;
-
- /* Barrier */
- // br.DoBarrier(id);
-
- /* compute forces */
-
- for (i = 0 + id; i < mdsize; i += md.nthreads) {
-// one[i].force(side, rcoff, mdsize, i, xx, yy, zz,mdr);
- }
-
- /* Barrier */
- // br.DoBarrier(id);
-
- /* update force arrays */
-
- if (id == 0) {
- for (int k = 0; k < 3; k++) {
- for (i = 0; i < mdsize; i++) {
- for (j = 0; j <md.nthreads; j++) {
- sh_force[k][i] += sh_force2[k][j][i];
- }
- }
- }
- }
-
- if (id == 0) {
- for (int k = 0; k < 3; k++) {
- for (i = 0; i < mdsize; i++) {
- for (j = 0; j < md.nthreads; j++) {
- sh_force2[k][j][i] = 0.0;
- }
- }
- }
- }
-
- if (id == 0) {
- for (j = 1; j < md.nthreads; j++) {
- md.epot[0] += md.epot[j];
- md.vir[0] += md.vir[j];
- }
- for (j = 1; j < md.nthreads; j++) {
- md.epot[j] = md.epot[0];
- md.vir[j] = md.vir[0];
- }
- for (j = 0; j <md.nthreads; j++) {
- md.interactions += md.interacts[j];
- }
- }
-
- /* Barrier */
- // br.DoBarrier(id);
-
- if (id == 0) {
- for (j = 0; j < 3; j++) {
- for (i = 0; i < mdsize; i++) {
- sh_force[j][i] = sh_force[j][i] * hsq2;
- }
- }
- }
-
- sum = 0.0;
-
- /* Barrier */
- // br.DoBarrier(id);
-
- /* scale forces, update velocities */
-
- for (i = 0; i < mdsize; i++) {
- sum = sum + one[i].mkekin(hsq2, i);
- }
-
- ekin = sum / hsq;
-
- vel = 0.0;
- count = 0.0;
-
- /* average velocity */
-
- for (i = 0; i < mdsize; i++) {
- velt = one[i].velavg(vaverh, h);
- if (velt > vaverh) {
- count = count + 1.0;
- }
- vel = vel + velt;
- }
-
- vel = vel / h;
-
- /* temperature scale if required */
-
- if ((move < istop) && (((move + 1) % irep) == 0)) {
- sc = Math.sqrt(tref / (tscale * ekin));
- for (i = 0; i < mdsize; i++) {
- one[i].dscal(sc, 1);
- }
- ekin = tref / tscale;
- }
-
- /* sum to get full potential energy and virial */
-
- if (((move + 1) % iprint) == 0) {
- md.ek[id] = 24.0 * ekin;
- md.epot[id] = 4.0 * md.epot[id];
- etot = md.ek[id] + md.epot[id];
- temp = tscale * ekin;
- pres = den * 16.0 * (ekin - md.vir[id]) / mdsize;
- vel = vel / mdsize;
- rp = (count / mdsize) * 100.0;
- }
-
- // br.DoBarrier(id);
- }
-
- // br.DoBarrier(id);
- // if (id == 0) JGFInstrumentor.stopTimer("Section3:MolDyn:Run");
-
- }
-
-}
-
-class particle {
-
- public double xcoord, ycoord, zcoord;
- public double xvelocity, yvelocity, zvelocity;
- int part_id;
- int id;
- double[][] sh_force;
- double[][][] sh_force2;
-// mdRunner runner;
-
- public particle(double xcoord, double ycoord, double zcoord, double xvelocity, double yvelocity,
- double zvelocity, double[][] sh_force, double[][][] sh_force2, int id) {
-
- this.xcoord = xcoord;
- this.ycoord = ycoord;
- this.zcoord = zcoord;
- this.xvelocity = xvelocity;
- this.yvelocity = yvelocity;
- this.zvelocity = zvelocity;
- this.sh_force = sh_force;
- this.sh_force2 = sh_force2;
- this.id = id;
-
- }
-
- public void domove(double side, int part_id) {
-
- xcoord = xcoord + xvelocity + sh_force[0][part_id];
- ycoord = ycoord + yvelocity + sh_force[1][part_id];
- zcoord = zcoord + zvelocity + sh_force[2][part_id];
-
- if (xcoord < 0) {
- xcoord = xcoord + side;
- }
- if (xcoord > side) {
- xcoord = xcoord - side;
- }
- if (ycoord < 0) {
- ycoord = ycoord + side;
- }
- if (ycoord > side) {
- ycoord = ycoord - side;
- }
- if (zcoord < 0) {
- zcoord = zcoord + side;
- }
- if (zcoord > side) {
- zcoord = zcoord - side;
- }
-
- xvelocity = xvelocity + sh_force[0][part_id];
- yvelocity = yvelocity + sh_force[1][part_id];
- zvelocity = zvelocity + sh_force[2][part_id];
-
- }
-
- public void force(double side, double rcoff, int mdsize, int x, double xx, double yy, double zz, mdRunner mdr) {
-
- double sideh;
- double rcoffs;
-
- double fxi, fyi, fzi;
- double rd, rrd, rrd2, rrd3, rrd4, rrd6, rrd7, r148;
- double forcex, forcey, forcez;
-
- sideh = 0.5 * side;
- rcoffs = rcoff * rcoff;
-
- fxi = 0.0;
- fyi = 0.0;
- fzi = 0.0;
-
- for (int i = x + 1; i < mdsize; i++) {
- xx = this.xcoord - mdr.one[i].xcoord;
- yy = this.ycoord - mdr.one[i].ycoord;
- zz = this.zcoord - mdr.one[i].zcoord;
-
- if (xx < (-sideh)) {
- xx = xx + side;
- }
- if (xx > (sideh)) {
- xx = xx - side;
- }
- if (yy < (-sideh)) {
- yy = yy + side;
- }
- if (yy > (sideh)) {
- yy = yy - side;
- }
- if (zz < (-sideh)) {
- zz = zz + side;
- }
- if (zz > (sideh)) {
- zz = zz - side;
- }
-
- rd = xx * xx + yy * yy + zz * zz;
-
- if (rd <= rcoffs) {
- rrd = 1.0 / rd;
- rrd2 = rrd * rrd;
- rrd3 = rrd2 * rrd;
- rrd4 = rrd2 * rrd2;
- rrd6 = rrd2 * rrd4;
- rrd7 = rrd6 * rrd;
- // md.epot[id] = md.epot[id] + (rrd6 - rrd3);
- mdr.mdr_epot = mdr.mdr_epot + (rrd6 - rrd3);
- r148 = rrd7 - 0.5 * rrd4;
- // md.vir[id] = md.vir[id] - rd*r148;
- mdr.mdr_vir = mdr.mdr_vir - rd * r148;
- forcex = xx * r148;
- fxi = fxi + forcex;
-
- sh_force2[0][id][i] = sh_force2[0][id][i] - forcex;
-
- forcey = yy * r148;
- fyi = fyi + forcey;
-
- sh_force2[1][id][i] = sh_force2[1][id][i] - forcey;
-
- forcez = zz * r148;
- fzi = fzi + forcez;
-
- sh_force2[2][id][i] = sh_force2[2][id][i] - forcez;
-
- // md.interacts[id]++;
- mdr.mdr_interacts++;
- }
-
- }
-
- sh_force2[0][id][x] = sh_force2[0][id][x] + fxi;
- sh_force2[1][id][x] = sh_force2[1][id][x] + fyi;
- sh_force2[2][id][x] = sh_force2[2][id][x] + fzi;
-
- }
-
- public double mkekin(double hsq2, int part_id) {
-
- double sumt = 0.0;
-
- xvelocity = xvelocity + sh_force[0][part_id];
- yvelocity = yvelocity + sh_force[1][part_id];
- zvelocity = zvelocity + sh_force[2][part_id];
-
- sumt = (xvelocity * xvelocity) + (yvelocity * yvelocity) + (zvelocity * zvelocity);
- return sumt;
- }
-
- public double velavg(double vaverh, double h) {
-
- double velt;
- double sq;
-
- sq = Math.sqrt(xvelocity * xvelocity + yvelocity * yvelocity + zvelocity * zvelocity);
-
- velt = sq;
- return velt;
- }
-
- public void dscal(double sc, int incx) {
-
- xvelocity = xvelocity * sc;
- yvelocity = yvelocity * sc;
- zvelocity = zvelocity * sc;
-
- }
-
-}
-
-class random {
-
- public int iseed;
- public double v1, v2;
-
- public random(int iseed, double v1, double v2) {
- this.iseed = iseed;
- this.v1 = v1;
- this.v2 = v2;
- }
-
- public double update() {
-
- double rand;
- double scale = 4.656612875e-10;
-
- int is1, is2, iss2;
- int imult = 16807;
- int imod = 2147483647;
-
- if (iseed <= 0) {
- iseed = 1;
- }
-
- is2 = iseed % 32768;
- is1 = (iseed - is2) / 32768;
- iss2 = is2 * imult;
- is2 = iss2 % 32768;
- is1 = (is1 * imult + (iss2 - is2) / 32768) % (65536);
-
- iseed = (is1 * 32768 + is2) % imod;
-
- rand = scale * iseed;
-
- return rand;
-
- }
-
- public double seed() {
-
- double s, u1, u2, r;
- s = 1.0;
- do {
- u1 = update();
- u2 = update();
-
- v1 = 2.0 * u1 - 1.0;
- v2 = 2.0 * u2 - 1.0;
- s = v1 * v1 + v2 * v2;
-
- } while (s >= 1.0);
-
- r = Math.sqrt(-2.0 * Math.log(s) / s);
-
- return r;
-
- }
-}
+++ /dev/null
-public class Barrier {
- int numthreads;
- int entercount;
- boolean cleared;
-
- public Barrier(int n) {
- numthreads=n;
- cleared = false;
- }
-
- public Barrier() {
-
- }
-
- public void reset() {
- cleared = false;
- entercount = 0;
- }
-
- public static void enterBarrier(Barrier b) {
- int tmp;
- boolean retry=true;
-
- do {
- 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) {
- if (b.cleared) {
- b.entercount--;
- int count = b.entercount;
- if (count==0)
- b.cleared=false;
- return;
- }
- }
- }
-}
+++ /dev/null
-public class DoubleWrapper {
- public DoubleWrapper() {
-
- }
- double d;
-}
\ No newline at end of file
+++ /dev/null
-public class IntWrapper {
- public IntWrapper() {
-
- }
- int i;
-}
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 1999. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFInstrumentor{
-
- protected HashMap timers;
- protected HashMap data;
-
- public JGFInstrumentor() {
- timers = new HashMap();
- data = new HashMap();
- }
-
- public static void addTimer (String name, HashMap timers){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists\n");
- }
- else {
- timers.put(name, new JGFTimer(name));
- }
- }
-
- public static void addTimer (String name, String opname, HashMap timers){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists\n");
- }
- else {
- timers.put(name, new JGFTimer(name,opname));
- }
-
- }
-
- public static void addTimer (String name, String opname, int size, HashMap timers){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists\n");
- }
- else {
- timers.put(name, new JGFTimer(name,opname,size));
- }
-
- }
-
- public static void startTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).start();
- }
- else {
- System.printString("JGFInstrumentor.startTimer: failed - timer " + name +
- " does not exist\n");
- }
-
- }
-
- public static void stopTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).stop();
- }
- else {
- System.printString("JGFInstrumentor.stopTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void addOpsToTimer(String name, double count, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).addops(count);
- }
- else {
- System.printString("JGFInstrumentor.addOpsToTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void addTimeToTimer(String name, double added_time, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).addtime(added_time);
- }
- else {
- System.printString("JGFInstrumentor.addTimeToTimer: failed - timer " + name +
- " does not exist\n");
- }
-
-
-
- }
-
- public static double readTimer(String name, HashMap timers){
- double time;
- if (timers.containsKey(name)) {
- time = ((JGFTimer) timers.get(name)).time;
- }
- else {
- System.printString("JGFInstrumentor.readTimer: failed - timer " + name +
- " does not exist\n");
- time = 0.0;
- }
- return time;
- }
-
- public static void resetTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).reset();
- }
- else {
- System.printString("JGFInstrumentor.resetTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void printTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).print();
- }
- else {
- System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void printperfTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).printperf();
- }
- else {
- System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void storeData(String name, Object obj, HashMap data){
- data.put(name,obj);
- }
-
- public static void retrieveData(String name, Object obj, HashMap data){
- obj = data.get(name);
- }
-
- public static void printHeader(int section, int size,int nthreads) {
-
- String header, base;
-
- header = "";
- base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section ";
-
- if (section == 1)
- {
- header = base + "1";
- }
- else if (section == 2)
- {
- if (size == 0)
- header = base + "2 - Size A";
- else if (size == 1)
- header = base + "2 - Size B";
- else if (size == 2)
- header = base + "2 - Size C";
- }
- else if (section == 3)
- {
- if (size == 0)
- header = base + "3 - Size A";
- else if (size == 1)
- header = base + "3 - Size B";
- else if (size == 2)
- header = base + "3 - Size C";
- }
-
- System.printString(header + "\n");
-
- if (nthreads == 1) {
- System.printString("Executing on " + nthreads + " thread\n");
- }
- else {
- System.printString("Executing on " + nthreads + " threads\n");
- }
-
- System.printString(" \n");
- }
-}
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFMolDynBench {
- public int ITERS;
- public double LENGTH;
- public double m;
- public double mu;
- public double kb;
- public double TSIM;
- public double deltat;
-
- public int PARTSIZE;
-
- public double[] epot;
- public double[] vir;
- public double[] ek;
-
- int size,mm;
- int[] datasizes;
-
- public int interactions;
- public int[] interacts;
-
- public int nthreads;
- public JGFInstrumentor instr;
-
- public JGFMolDynBench(int nthreads) {
- this.nthreads=nthreads;
- }
-
- public void JGFsetsize(int size){
- this.size = size;
- }
-
- public void JGFinitialise(){
- interactions = 0;
- datasizes = new int[3];
- datasizes[0] = 8;
- datasizes[1] = 13;
- datasizes[2] = 11;
-
- mm = datasizes[size];
- PARTSIZE = mm*mm*mm*4;
- ITERS = 100;
- LENGTH = 50e-10;
- m = 4.0026;
- mu = 1.66056e-27;
- kb = 1.38066e-23;
- TSIM = 50;
- deltat = 5e-16;
- }
-
- public static void JGFapplication(JGFMolDynBench mold) {
- double sh_force [][];
- double sh_force2 [][][];
- int partsize, numthreads;
- partsize = mold.PARTSIZE;
- numthreads = mold.nthreads;
-
- sh_force = new double[3][partsize];
- sh_force2 = new double[3][numthreads][partsize];
- mold.epot = new double[numthreads];
- mold.vir = new double[numthreads];
- mold.ek = new double[numthreads];
- mold.interacts = new int[numthreads];
-// for(int i=0;i<numthreads;i++) {
-// mold.epot[i]=new double();
-// mold.vir[i]=new double();
-// mold.ek[i]=new double();
-// mold.interacts[i]=new IntWrapper();
-// }
-
- // spawn threads
- MDWrap[] thobjects = new MDWrap[numthreads];
-
- for(int i=0;i<numthreads;i++) {
- thobjects[i] = new MDWrap(new mdRunner(i,mold.mm,sh_force,sh_force2,mold.nthreads,mold));
- }
-
- /*
- boolean waitfordone=true;
- while(waitfordone) {
- if (mybarr.done)
- waitfordone=false;
- }
- */
-
- for(int i=0;i<numthreads;i++) {
- //thobjects[i].md.start(mid[i]);
- thobjects[i].md.run();
- }
- }
-
- public void JGFvalidate(){
- double[] refval = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dev = Math.fabs(ek[0] - refval[size]);
- if (dev > 1.0e-10 ){
- //System.printString("Validation failed\n");
- //System.printString("Kinetic Energy = " + (long)ek[0] + " " + (long)dev + " " + size + "\n");
- }
- }
-}
-
-class mdRunner {
-
- double count;
- int id,i,j,k,lg,mm;
- double l,rcoff,rcoffs,side,sideh,hsq,hsq2,vel,velt;
- double a,r,sum,tscale,sc,ekin,ts,sp;
- double den;
- double tref;
- double h;
- double vaver,vaverh,rand;
- double etot,temp,pres,rp;
- double u1, u2, s, xx, yy, zz;
- double xvelocity, yvelocity, zvelocity;
-
- double [][] sh_force;
- double [][][] sh_force2;
-
- int ijk,npartm,iseed,tint;
- int irep;
- int istop;
- int iprint;
-
- JGFMolDynBench mymd;
- int nthreads;
-
- public mdRunner(int id, int mm, double [][] sh_force, double [][][] sh_force2,
- int nthreads, JGFMolDynBench mymd) {
- this.id=id;
- this.mm=mm;
- this.sh_force=sh_force;
- this.sh_force2=sh_force2;
- this.nthreads = nthreads;
- this.mymd = mymd;
- count = 0.0;
- den = 0.83134;
- tref = 0.722;
- h = 0.064;
- irep = 10;
- istop = 19;
- iprint = 10;
- }
-
- public void init(particle[] one, int mdsize) {
- int id=this.id;
- for (int lg=0; lg<=1; lg++) {
- for (int i=0; i<mm; i++) {
- for (int j=0; j<mm; j++) {
- for (int k=0; k<mm; k++) {
- one[ijk] = new particle((i*a+lg*a*0.5),(j*a+lg*a*0.5),(k*a),
- xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,one);
- ijk = ijk + 1;
- }
- }
- }
- }
-
- for (int lg=1; lg<=2; lg++) {
- for (int i=0; i<mm; i++) {
- for (int j=0; j<mm; j++) {
- for (int k=0; k<mm; k++) {
- one[ijk] = new particle((i*a+(2-lg)*a*0.5),(j*a+(lg-1)*a*0.5),
- (k*a+a*0.5),xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,one);
- ijk = ijk + 1;
- }
- }
- }
- }
-
- /* Initialise velocities */
-
- iseed = 0;
- double v1 = 0.0;
- double v2 = 0.0;
- random randnum = new random(iseed,v1,v2);
-
-
- for (int i=0; i<mdsize; i+=2) {
- r = randnum.seed();
- one[i].xvelocity = r*randnum.v1;
- one[i+1].xvelocity = r*randnum.v2;
- }
-
- for (int i=0; i<mdsize; i+=2) {
- r = randnum.seed();
- one[i].yvelocity = r*randnum.v1;
- one[i+1].yvelocity = r*randnum.v2;
- }
-
- for (int i=0; i<mdsize; i+=2) {
- r = randnum.seed();
- one[i].zvelocity = r*randnum.v1;
- one[i+1].zvelocity = r*randnum.v2;
- }
-
-
- /* velocity scaling */
-
- ekin = 0.0;
- sp = 0.0;
-
- for(int i=0;i<mdsize;i++) {
- sp = sp + one[i].xvelocity;
- }
- sp = sp / mdsize;
-
- for(int i=0;i<mdsize;i++) {
- one[i].xvelocity = one[i].xvelocity - sp;
- ekin = ekin + one[i].xvelocity*one[i].xvelocity;
- }
-
- sp = 0.0;
- for(int i=0;i<mdsize;i++) {
- sp = sp + one[i].yvelocity;
- }
- sp = sp / mdsize;
-
- for(int i=0;i<mdsize;i++) {
- one[i].yvelocity = one[i].yvelocity - sp;
- ekin = ekin + one[i].yvelocity*one[i].yvelocity;
- }
-
-
- sp = 0.0;
- for(int i=0;i<mdsize;i++) {
- sp = sp + one[i].zvelocity;
- }
- sp = sp / mdsize;
-
- for(int i=0;i<mdsize;i++) {
- one[i].zvelocity = one[i].zvelocity - sp;
- ekin = ekin + one[i].zvelocity*one[i].zvelocity;
- }
-
- ts = tscale * ekin;
- sc = h * Math.sqrt(tref/ts);
-
-
- for(int i=0;i<mdsize;i++) {
-
- one[i].xvelocity = one[i].xvelocity * sc;
- one[i].yvelocity = one[i].yvelocity * sc;
- one[i].zvelocity = one[i].zvelocity * sc;
-
- }
-
- }
-
- public void doinit(int mdsize) {
- for(int j=0;j<3;j++) {
- double[] sh=sh_force[j];
- for (int i=0;i<mdsize;i++) {
- sh[i] = 0.0;
- }
- }
- }
-
-
- public void doinit2(int mdsize) {
- for(int k=0;k<3;k++) {
- double[] sh=sh_force[k];
- double [][] sha=sh_force2[k];
- for(int j=0;j<nthreads;j++) {
- double[] sha2=sha[j];
- for(int i=0;i<mdsize;i++) {
- sh[i] += sha2[i];
- }
- }
- }
-
- for(int k=0;k<3;k++) {
- double [][] sh1=sh_force2[k];
- for(int j=0;j<nthreads;j++) {
- double[] sh2=sh1[j];
- for(int i=0;i<mdsize;i++) {
-
-
- sh2[i] = 0.0;
- }
- }
- }
-
- for(int j=1;j<nthreads;j++) {
- mymd.epot[0] += mymd.epot[j];
- mymd.vir[0] += mymd.vir[j];
- }
- for(int j=1;j<nthreads;j++) {
- mymd.epot[j] = mymd.epot[0];
- mymd.vir[j] = mymd.vir[0];
- }
- for(int j=0;j<nthreads;j++) {
- mymd.interactions += mymd.interacts[j];
- }
-
- for (int j=0;j<3;j++) {
- double sh[]=sh_force[j];
- for (int i=0;i<mdsize;i++) {
- sh[i] = sh[i] * hsq2;
- }
- }
- }
-
- public void run() {
- /* Parameter determination */
-
- int mdsize;
- double tmpden;
- int movemx=50;
- particle[] one;
- int id;
- id=this.id;
- mdsize = mymd.PARTSIZE;
- one=new particle[mdsize];
- l = mymd.LENGTH;
- tmpden = den;
- side = Math.pow((mdsize/tmpden),0.3333333);
- rcoff = mm/4.0;
-
- a = side/mm;
- sideh = side*0.5;
- hsq = h*h;
- hsq2 = hsq*0.5;
- npartm = mdsize - 1;
- rcoffs = rcoff * rcoff;
- tscale = 16.0 / (1.0 * mdsize - 1.0);
- vaver = 1.13 * Math.sqrt(tref / 24.0);
- vaverh = vaver * h;
-
- /* Particle Generation */
-
- xvelocity = 0.0;
- yvelocity = 0.0;
- zvelocity = 0.0;
- ijk = 0;
- init(one, mdsize);
-
-
- /* Synchronise threads and start timer before MD simulation */
-
-
- /* MD simulation */
-
- for (int move=0;move<movemx;move++) {
- /* move the particles and update velocities */
- for (int i=0;i<mdsize;i++) {
- one[i].domove(side,i);
- }
-
-
- if(id==0) {
- doinit(mdsize);
- }
-
- mymd.epot[id] = 0.0;
- mymd.vir[id] = 0.0;
- mymd.interacts[id] = 0;
-
-
-
- /* compute forces */
- for (int i=0+id;i<mdsize;i+=nthreads) {
- MDWorker worker=new MDWorker(mdsize);
- one[i].force(side,rcoff,mdsize,i,xx,yy,zz,mymd,worker);
- }
-
-
- /* update force arrays */
- if(id == 0) {
- doinit2(mdsize);
- }
-
-
- /*scale forces, update velocities */
- sum = 0.0;
- for (int i=0;i<mdsize;i++) {
- sum = sum + one[i].mkekin(hsq2,i);
- }
-
- ekin = sum/hsq;
-
- vel = 0.0;
- count = 0.0;
-
- /* average velocity */
-
- for (int i=0;i<mdsize;i++) {
- velt = one[i].velavg(vaverh,h);
- if(velt > vaverh) { count = count + 1.0; }
- vel = vel + velt;
- }
-
- vel = vel / h;
-
- /* temperature scale if required */
-
- if((move < istop) && (((move+1) % irep) == 0)) {
- sc = Math.sqrt(tref / (tscale*ekin));
- for (int i=0;i<mdsize;i++) {
- one[i].dscal(sc,1);
- }
- ekin = tref / tscale;
- }
-
- /* sum to get full potential energy and virial */
-
- if(((move+1) % iprint) == 0) {
- mymd.ek[id] = 24.0*ekin;
- mymd.epot[id] = 4.0*mymd.epot[id];
- etot = mymd.ek[id] + mymd.epot[id];
- temp = tscale * ekin;
- pres = tmpden * 16.0 * (ekin - mymd.vir[id]) / mdsize;
- vel = vel / mdsize;
- rp = (count / mdsize) * 100.0;
- }
-
- //if (id == 0) JGFInstrumentor.stopTimer("Section3:MolDyn:Run", instr.timers);
- }
- }
-}
-
- class particle {
-
- public double xcoord, ycoord, zcoord;
- public double xvelocity,yvelocity,zvelocity;
- int part_id;
- int id;
- double [][] sh_force;
- double [][][] sh_force2;
- particle[] one;
-
- public particle(double xcoord, double ycoord, double zcoord, double xvelocity,
- double yvelocity,double zvelocity, double [][] sh_force,
- double [][][] sh_force2,int id, particle[] one) {
-
- this.xcoord = xcoord;
- this.ycoord = ycoord;
- this.zcoord = zcoord;
- this.xvelocity = xvelocity;
- this.yvelocity = yvelocity;
- this.zvelocity = zvelocity;
- this.sh_force = sh_force;
- this.sh_force2 = sh_force2;
- this.id=id;
- this.one=one;
- }
-
- public void domove(double side,int part_id) {
-
- xcoord = xcoord + xvelocity + sh_force[0][part_id];
- ycoord = ycoord + yvelocity + sh_force[1][part_id];
- zcoord = zcoord + zvelocity + sh_force[2][part_id];
-
- if(xcoord < 0) { xcoord = xcoord + side; }
- if(xcoord > side) { xcoord = xcoord - side; }
- if(ycoord < 0) { ycoord = ycoord + side; }
- if(ycoord > side) { ycoord = ycoord - side; }
- if(zcoord < 0) { zcoord = zcoord + side; }
- if(zcoord > side) { zcoord = zcoord - side; }
-
- xvelocity = xvelocity + sh_force[0][part_id];
- yvelocity = yvelocity + sh_force[1][part_id];
- zvelocity = zvelocity + sh_force[2][part_id];
-
- }
-
-// public void force(double side, double rcoff,int mdsize,int x, double xx, double yy, double zz, JGFMolDynBench mymd) {
- public void force(double side, double rcoff,int mdsize,int x, double xx, double yy, double zz, JGFMolDynBench mymd, MDWorker worker) {
-
- double sideh;
- double rcoffs;
-
- double fxi,fyi,fzi;
- double rd,rrd,rrd2,rrd3,rrd4,rrd6,rrd7,r148;
- double forcex,forcey,forcez;
- int id=this.id;
- sideh = 0.5*side;
- rcoffs = rcoff*rcoff;
-
- fxi = 0.0;
- fyi = 0.0;
- fzi = 0.0;
-
- for (int i=x+1;i<mdsize;i++) {
- xx = this.xcoord - one[i].xcoord;
- yy = this.ycoord - one[i].ycoord;
- zz = this.zcoord - one[i].zcoord;
-
- if(xx < (-sideh)) { xx = xx + side; }
- if(xx > (sideh)) { xx = xx - side; }
- if(yy < (-sideh)) { yy = yy + side; }
- if(yy > (sideh)) { yy = yy - side; }
- if(zz < (-sideh)) { zz = zz + side; }
- if(zz > (sideh)) { zz = zz - side; }
-
-
- rd = xx*xx + yy*yy + zz*zz;
-
- if(rd <= rcoffs) {
- rrd = 1.0/rd;
- rrd2 = rrd*rrd;
- rrd3 = rrd2*rrd;
- rrd4 = rrd2*rrd2;
- rrd6 = rrd2*rrd4;
- rrd7 = rrd6*rrd;
-// mymd.epot[id] += (rrd6 - rrd3);
- worker.epot+=(rrd6 - rrd3);
- r148 = rrd7 - 0.5*rrd4;
-// mymd.vir[id] += - rd*r148;
- worker.vir+= - rd*r148;
- forcex = xx * r148;
- fxi = fxi + forcex;
-
-// sh_force2[0][id][i] = sh_force2[0][id][i] - forcex;
- worker.sh_force2[0][i]=worker.sh_force2[0][i]-forcex;
-
- forcey = yy * r148;
- fyi = fyi + forcey;
-
-// sh_force2[1][id][i] = sh_force2[1][id][i] - forcey;
- worker.sh_force2[1][i]=worker.sh_force2[1][i]-forcex;
-
- forcez = zz * r148;
- fzi = fzi + forcez;
-
-// sh_force2[2][id][i] = sh_force2[2][id][i] - forcez;
- worker.sh_force2[2][i]=worker.sh_force2[2][i]-forcez;
-
-// mymd.interacts[id]++;
- worker.interacts++;
- }
-
- }
-
-// sh_force2[0][id][x] = sh_force2[0][id][x] + fxi;
-// sh_force2[1][id][x] = sh_force2[1][id][x] + fyi;
-// sh_force2[2][id][x] = sh_force2[2][id][x] + fzi;
-
- worker.sh_force2[0][x]=worker.sh_force2[0][x]-fxi;
- worker.sh_force2[1][x]=worker.sh_force2[1][x]-fyi;
- worker.sh_force2[2][x]=worker.sh_force2[2][x]-fzi;
-
- }
-
- public double mkekin(double hsq2,int part_id) {
-
- double sumt = 0.0;
-
- xvelocity = xvelocity + sh_force[0][part_id];
- yvelocity = yvelocity + sh_force[1][part_id];
- zvelocity = zvelocity + sh_force[2][part_id];
-
- sumt = (xvelocity*xvelocity)+(yvelocity*yvelocity)+(zvelocity*zvelocity);
- return sumt;
- }
-
- public double velavg(double vaverh,double h) {
-
- double velt;
- double sq;
-
- sq = Math.sqrt(xvelocity*xvelocity + yvelocity*yvelocity +
- zvelocity*zvelocity);
-
- velt = sq;
- return velt;
- }
-
- public void dscal(double sc,int incx) {
- xvelocity = xvelocity * sc;
- yvelocity = yvelocity * sc;
- zvelocity = zvelocity * sc;
- }
- }
-
- class random {
-
- public int iseed;
- public double v1,v2;
-
- public random(int iseed,double v1,double v2) {
- this.iseed = iseed;
- this.v1 = v1;
- this.v2 = v2;
- }
-
- public double update() {
-
- double rand;
- double scale= 4.656612875e-10;
-
- int is1,is2,iss2;
- int imult=16807;
- int imod = 2147483647;
-
- if (iseed<=0) { iseed = 1; }
-
- is2 = iseed % 32768;
- is1 = (iseed-is2)/32768;
- iss2 = is2 * imult;
- is2 = iss2 % 32768;
- is1 = (is1*imult+(iss2-is2)/32768) % (65536);
-
- iseed = (is1*32768+is2) % imod;
-
- rand = scale * iseed;
-
- return rand;
-
- }
-
- public double seed() {
-
- double s,u1,u2,r;
- s = 1.0;
- do {
- u1 = update();
- u2 = update();
-
- v1 = 2.0 * u1 - 1.0;
- v2 = 2.0 * u2 - 1.0;
- s = v1*v1 + v2*v2;
-
- } while (s >= 1.0);
-
- r = Math.sqrt(-2.0*Math.log(s)/s);
-
- return r;
-
- }
- }
-
-
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFMolDynBenchSizeA {
-
- public static void main(String argv[]){
- int nthreads;
- if(argv.length != 0 ) {
- nthreads = Integer.parseInt(argv[0]);
- } else {
- System.printString("The no of threads has not been specified, defaulting to 1\n");
- System.printString(" " + "\n");
- nthreads = 1;
- }
-
- JGFInstrumentor instr = new JGFInstrumentor();
- JGFInstrumentor.printHeader(3,0,nthreads);
-
- JGFMolDynBench mold;
- mold = new JGFMolDynBench(nthreads);
- int size = 0;
- JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers);
- JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers);
-
- mold.JGFsetsize(size);
-
- JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers);
-
- JGFMolDynBench tmp;
- mold.JGFinitialise();
- JGFMolDynBench.JGFapplication(mold);
-
- /* Validate data */
- double[] refval = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dval;
- dval = mold.ek[0].d;
- double dev = Math.fabs(dval - refval[size]);
- long l = (long) refval[size] *1000000;
- long r = (long) dval * 1000000;
- if (l != r ){
- System.printString("Validation failed\n");
- System.printString("Kinetic Energy = " + (long)dval + " " + (long)dev + " " + size + "\n");
- }
-
- JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers);
- double interactions;
- interactions = mold.interactions;
-
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) interactions, instr.timers);
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers);
-
- JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers);
- JGFInstrumentor.printTimer("Section3:MolDyn:Total", instr.timers);
- System.printString("Finished\n");
- }
-}
-
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFMolDynBenchSizeB {
-
- public static void main(String argv[]){
- int nthreads;
- if(argv.length != 0 ) {
- nthreads = Integer.parseInt(argv[0]);
- } else {
- System.printString("The no of threads has not been specified, defaulting to 1\n");
- System.printString(" " + "\n");
- nthreads = 1;
- }
-
-// JGFInstrumentor instr = new JGFInstrumentor();
-// JGFInstrumentor.printHeader(3,1,nthreads);
-
- JGFMolDynBench mold;
- mold = new JGFMolDynBench(nthreads);
- int size = 0;
-// JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers);
-// JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers);
-
- mold.JGFsetsize(size);
-
-// JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers);
-
- JGFMolDynBench tmp;
- mold.JGFinitialise();
- JGFMolDynBench.JGFapplication(mold);
-
- /* Validate data */
- double[] refval = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dval;
- dval = mold.ek[0];
- double dev = Math.fabs(dval - refval[size]);
- long l = (long) refval[size] *1000000;
- long r = (long) dval * 1000000;
- if (l != r ){
- System.printString("Validation failed\n");
- System.printString("Kinetic Energy = " + (long)dval + " " + (long)dev + " " + size + "\n");
- }
-
-// JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers);
- double interactions;
- interactions = mold.interactions;
-
-// JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) interactions, instr.timers);
-// JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers);
-
-// JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers);
-// JGFInstrumentor.printTimer("Section3:MolDyn:Total", instr.timers);
-// System.printString("Finished\n");
- }
-}
-
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFMolDynBenchSizeC {
-
- public static void main(String argv[]){
- int nthreads;
- if(argv.length != 0 ) {
- nthreads = Integer.parseInt(argv[0]);
- } else {
- System.printString("The no of threads has not been specified, defaulting to 1\n");
- System.printString(" " + "\n");
- nthreads = 1;
- }
-
- JGFInstrumentor instr = new JGFInstrumentor();
- JGFInstrumentor.printHeader(3,2,nthreads);
-
- JGFMolDynBench mold;
- mold = new JGFMolDynBench(nthreads);
- int size = 2;
- JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers);
- JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers);
-
- mold.JGFsetsize(size);
-
- JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers);
-
- JGFMolDynBench tmp;
- mold.JGFinitialise();
- JGFMolDynBench.JGFapplication(mold);
-
- /* Validate data */
- /*
- double[] refval = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dval;
- dval = mold.ek[0].d;
- double dev = Math.fabs(dval - refval[size]);
- long l = (long) refval[size] *1000000;
- long r = (long) dval * 1000000;
- if (l != r ){
- System.printString("Validation failed\n");
- System.printString("Kinetic Energy = " + (long)dval + " " + (long)dev + " " + size + "\n");
- }
-
- JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers);
- double interactions;
- interactions = mold.interactions;
-
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) interactions, instr.timers);
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers);
-
- JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers);
- JGFInstrumentor.printTimer("Section3:MolDyn:Total", instr.timers);
- */
- System.printString("Finished\n");
- }
-}
-
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 1999. *
- * All rights reserved. *
- * *
- **************************************************************************/
-
-public class JGFTimer {
-
- public String name;
- public String opname;
- public double time;
- public double opcount;
- public long calls;
- public int size;
-
- private long start_time;
- private boolean on;
-
- public JGFTimer(String name, String opname){
- this.size = -1;
- this.name = name;
- this.opname = opname;
- reset();
- }
-
- public JGFTimer(String name, String opname, int size){
- this.name = name;
- this.opname = opname;
- this.size = size;
- reset();
- }
-
- public JGFTimer(String name){
- this.name = name;
- this.opname = "";
- reset();
- }
-
-
-
- public void start(){
- if (on) System.printString("Warning timer " + " was already turned on\n");
- on = true;
- start_time = System.currentTimeMillis();
- }
-
-
- public void stop(){
- time += (double) (System.currentTimeMillis()-start_time) / 1000.;
- if (!on) System.printString("Warning timer " + " wasn't turned on\n");
- calls++;
- on = false;
- }
-
- public void addops(double count){
- opcount += count;
- }
-
- public void addtime(double added_time){
- time += added_time;
- }
-
- public void reset(){
- time = 0.0;
- calls = 0;
- opcount = 0;
- on = false;
- }
-
- public double perf(){
- return opcount / time;
- }
-
- public void longprint(){
- System.printString("Timer Calls Time(s) Performance("+opname+"/s)\n");
- System.printString(name + " " + calls + " " + (long)time + " " + (long)this.perf() + "\n");
- }
-
- public void print(){
- if (opname.equals("")) {
- System.printString(name + " " + (long)time + " (s)\n");
- }
- else {
- if(size == 0) {
- System.printString(name + ":SizeA" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
- } else if (size == 1) {
- System.printString(name + ":SizeB" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
- } else if (size == 2) {
- System.printString(name + ":SizeC" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
- } else{
- System.printString(name + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
- }
- }
- }
-
-
- public void printperf(){
-
- String name;
- name = this.name;
-
- // pad name to 40 characters
- while ( name.length() < 40 ) name = name + " ";
-
- System.printString(name + "\t" + (long)this.perf() + "\t"
- + " ("+opname+"/s)\n");
- }
-
-}
+++ /dev/null
-public class MDWorker {
-
- int interacts;
- double vir;
- double epot;
- double sh_force2[][];
-
- public MDWorker(int partsize) {
- sh_force2=new double[3][partsize];
- }
-
-}
+++ /dev/null
-public class MDWrap {
- public mdRunner md;
- public MDWrap() {
- }
-
- public MDWrap(mdRunner m) {
- md=m;
- }
-}
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-
-// This implements a simple tournament-based barrier, using entirely its
-// own synchronisation. At present Yield() is called to stop busy-waiting
-// processes hogging the processor(s)!
-
-public class TournamentBarrier {
- // Array of flags indicating whether the given process and all those
- // for which it is responsible have finished. The "sense" of this
- // array alternates with each barrier, to prevent having to
- // reinitialise.
- boolean[] IsDone;
- public int maxBusyIter;
- int numThreads;
-
- public TournamentBarrier(int n) {
- numThreads = n;
- maxBusyIter = 1;
- // Superclass constructor should record the number of threads
- // and thread manager.
- //super(n);
-
- // Initialise the IsDone array. The choice of initial value is
- // arbitrary, but must be consistent!
- IsDone = new boolean[numThreads];
- for(int i = 0; i < n; i++) {
- IsDone[i] = false;
- }
- }
-
- // Uses the manager's debug function, so this can only be used after
- // construction!
- public void debug(String s) {
- //System.err.println("Debug message" + s);
- }
-
- /*
- public void setMaxBusyIter(int b) {
- maxBusyIter = b;
- }
- */
-
- public void DoBarrier(int myid) {
- int b;
- //debug("Thread " + myid + " checking in");
-
- int roundmask = 3;
- boolean donevalue = !IsDone[myid];
-
- while(((myid & roundmask) == 0) && (roundmask<(numThreads<<2))) {
- int spacing = (roundmask+1) >> 2;
- for(int i=1; i<=3 && myid+i*spacing < numThreads; i++) {
- //debug("Thread " + myid + " waiting for thread " + (myid+i*spacing));
- b = maxBusyIter;
- while(IsDone[myid+i*spacing] != donevalue) {
- b--;
- if(b==0) {
- //Thread.yield();
- b = maxBusyIter;
- }
- }
- }
- roundmask = (roundmask << 2) + 3;
- }
- //debug("Thread " + myid + " reporting done");
- IsDone[myid] = donevalue;
- b = maxBusyIter;
- while(IsDone[0] != donevalue) {
- b--;
- if(b==0) {
- //Thread.yield();
- b = maxBusyIter;
- }
- }
- //debug("Thread " + myid + " checking out");
-
- }
-}
+++ /dev/null
-public class Barrier {
- int numthreads;
- int entercount;
- boolean cleared;
-
- public Barrier(int n) {
- numthreads=n;
- cleared = false;
- }
-
- public Barrier() {
-
- }
-
- public void reset() {
- cleared = false;
- entercount = 0;
- }
-
- public static void enterBarrier(Barrier b) {
- int tmp;
- boolean retry=true;
-
- do {
- 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) {
- if (b.cleared) {
- b.entercount--;
- int count = b.entercount;
- if (count==0)
- b.cleared=false;
- return;
- }
- }
- }
-}
+++ /dev/null
-public class DoubleWrapper {
- public DoubleWrapper() {
-
- }
- double d;
-}
\ No newline at end of file
+++ /dev/null
-public class IntWrapper {
- public IntWrapper() {
-
- }
- int i;
-}
\ No newline at end of file
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 1999. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFInstrumentor{
-
- protected HashMap timers;
- protected HashMap data;
-
- public JGFInstrumentor() {
- timers = new HashMap();
- data = new HashMap();
- }
-
- public static void addTimer (String name, HashMap timers){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists\n");
- }
- else {
- timers.put(name, new JGFTimer(name));
- }
- }
-
- public static void addTimer (String name, String opname, HashMap timers){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists\n");
- }
- else {
- timers.put(name, new JGFTimer(name,opname));
- }
-
- }
-
- public static void addTimer (String name, String opname, int size, HashMap timers){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists\n");
- }
- else {
- timers.put(name, new JGFTimer(name,opname,size));
- }
-
- }
-
- public static void startTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).start();
- }
- else {
- System.printString("JGFInstrumentor.startTimer: failed - timer " + name +
- " does not exist\n");
- }
-
- }
-
- public static void stopTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).stop();
- }
- else {
- System.printString("JGFInstrumentor.stopTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void addOpsToTimer(String name, double count, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).addops(count);
- }
- else {
- System.printString("JGFInstrumentor.addOpsToTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void addTimeToTimer(String name, double added_time, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).addtime(added_time);
- }
- else {
- System.printString("JGFInstrumentor.addTimeToTimer: failed - timer " + name +
- " does not exist\n");
- }
-
-
-
- }
-
- public static double readTimer(String name, HashMap timers){
- double time;
- if (timers.containsKey(name)) {
- time = ((JGFTimer) timers.get(name)).time;
- }
- else {
- System.printString("JGFInstrumentor.readTimer: failed - timer " + name +
- " does not exist\n");
- time = 0.0;
- }
- return time;
- }
-
- public static void resetTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).reset();
- }
- else {
- System.printString("JGFInstrumentor.resetTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void printTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).print();
- }
- else {
- System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void printperfTimer(String name, HashMap timers){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).printperf();
- }
- else {
- System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
- " does not exist\n");
- }
- }
-
- public static void storeData(String name, Object obj, HashMap data){
- data.put(name,obj);
- }
-
- public static void retrieveData(String name, Object obj, HashMap data){
- obj = data.get(name);
- }
-
- public static void printHeader(int section, int size,int nthreads) {
-
- String header, base;
-
- header = "";
- base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section ";
-
- if (section == 1)
- {
- header = base + "1";
- }
- else if (section == 2)
- {
- if (size == 0)
- header = base + "2 - Size A";
- else if (size == 1)
- header = base + "2 - Size B";
- else if (size == 2)
- header = base + "2 - Size C";
- }
- else if (section == 3)
- {
- if (size == 0)
- header = base + "3 - Size A";
- else if (size == 1)
- header = base + "3 - Size B";
- else if (size == 2)
- header = base + "3 - Size C";
- }
-
- System.printString(header + "\n");
-
- if (nthreads == 1) {
- System.printString("Executing on " + nthreads + " thread\n");
- }
- else {
- System.printString("Executing on " + nthreads + " threads\n");
- }
-
- System.printString(" \n");
- }
-}
+++ /dev/null
-/**************************************************************************
- * * Java Grande Forum Benchmark Suite - Thread Version 1.0 * * produced by * *
- * Java Grande Benchmarking Project * * at * * Edinburgh Parallel Computing
- * Centre * * email: epcc-javagrande@epcc.ed.ac.uk * * * This version copyright
- * (c) The University of Edinburgh, 2001. * All rights reserved. * *
- **************************************************************************/
-public class JGFMolDynBench {
- public int ITERS;
- public double LENGTH;
- public double m;
- public double mu;
- public double kb;
- public double TSIM;
- public double deltat;
-
- public int PARTSIZE;
-
- public double[] epot;
- public double[] vir;
- public double[] ek;
-
- int size, mm;
- int[] datasizes;
-
- public int interactions;
- public int[] interacts;
-
- public int nthreads;
- public JGFInstrumentor instr;
- public int workload;
-
- public JGFMolDynBench(int nthreads,int workload) {
- this.nthreads = nthreads;
- this.workload=workload;
- }
-
- public void JGFsetsize(int size) {
- this.size = size;
- }
-
- public void JGFinitialise() {
- interactions = 0;
- datasizes = new int[3];
- datasizes[0] = 8;
- datasizes[1] = 13;
- datasizes[2] = 11;
-
- mm = datasizes[size];
- PARTSIZE = mm * mm * mm * 4;
- ITERS = 100;
- LENGTH = 50e-10;
- m = 4.0026;
- mu = 1.66056e-27;
- kb = 1.38066e-23;
- TSIM = 50;
- deltat = 5e-16;
- }
-
- public static void JGFapplication(JGFMolDynBench mold) {
- double sh_force[][];
- double sh_force2[][][];
- int partsize, numthreads;
- partsize = mold.PARTSIZE;
- numthreads = mold.nthreads;
-
- sh_force = new double[3][partsize];
- sh_force2 = new double[3][numthreads][partsize];
- mold.epot = new double[numthreads];
- mold.vir = new double[numthreads];
- mold.ek = new double[numthreads];
- mold.interacts = new int[numthreads];
- // for(int i=0;i<numthreads;i++) {
- // mold.epot[i]=new double();
- // mold.vir[i]=new double();
- // mold.ek[i]=new double();
- // mold.interacts[i]=new IntWrapper();
- // }
-
- // spawn threads
- MDWrap[] thobjects = new MDWrap[numthreads];
-
- for (int i = 0; i < numthreads; i++) {
- thobjects[i] = new MDWrap(new mdRunner(i, mold.mm, sh_force, sh_force2, mold.nthreads, mold,mold.workload));
- }
-
- /*
- * boolean waitfordone=true; while(waitfordone) { if (mybarr.done)
- * waitfordone=false; }
- */
-
- for (int i = 0; i < numthreads; i++) {
- // thobjects[i].md.start(mid[i]);
- thobjects[i].md.run();
- }
- }
-
- public void JGFvalidate() {
- double[] refval = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dev = Math.fabs(ek[0] - refval[size]);
- if (dev > 1.0e-10) {
- // System.printString("Validation failed\n");
- // System.printString("Kinetic Energy = " + (long)ek[0] + " " + (long)dev
- // + " " + size + "\n");
- }
- }
-}
-
-class mdRunner {
-
- double count;
- int id, i, j, k, lg, mm;
- double l, rcoff, rcoffs, side, sideh, hsq, hsq2, vel, velt;
- double a, r, sum, tscale, sc, ekin, ts, sp;
- double den;
- double tref;
- double h;
- double vaver, vaverh, rand;
- double etot, temp, pres, rp;
- double u1, u2, s, xx, yy, zz;
- double xvelocity, yvelocity, zvelocity;
-
- double[][] sh_force;
- double[][][] sh_force2;
-
- int ijk, npartm, iseed, tint;
- int irep;
- int istop;
- int iprint;
-
- JGFMolDynBench mymd;
- int nthreads;
- int workload;
-
- public mdRunner(int id, int mm, double[][] sh_force, double[][][] sh_force2, int nthreads,
- JGFMolDynBench mymd, int workload) {
- this.id = id;
- this.mm = mm;
- this.sh_force = sh_force;
- this.sh_force2 = sh_force2;
- this.nthreads = nthreads;
- this.mymd = mymd;
- count = 0.0;
- den = 0.83134;
- tref = 0.722;
- h = 0.064;
- irep = 10;
- istop = 19;
- iprint = 10;
- this.workload=workload;
- }
-
- public void init(particle[] one, int mdsize) {
- int id = this.id;
- for (int lg = 0; lg <= 1; lg++) {
- for (int i = 0; i < mm; i++) {
- for (int j = 0; j < mm; j++) {
- for (int k = 0; k < mm; k++) {
- one[ijk] =
- new particle((i * a + lg * a * 0.5), (j * a + lg * a * 0.5), (k * a), xvelocity,
- yvelocity, zvelocity, sh_force, sh_force2, id, one);
- ijk = ijk + 1;
- }
- }
- }
- }
-
- for (int lg = 1; lg <= 2; lg++) {
- for (int i = 0; i < mm; i++) {
- for (int j = 0; j < mm; j++) {
- for (int k = 0; k < mm; k++) {
- one[ijk] =
- new particle((i * a + (2 - lg) * a * 0.5), (j * a + (lg - 1) * a * 0.5),
- (k * a + a * 0.5), xvelocity, yvelocity, zvelocity, sh_force, sh_force2, id,
- one);
- ijk = ijk + 1;
- }
- }
- }
- }
-
- /* Initialise velocities */
-
- iseed = 0;
- double v1 = 0.0;
- double v2 = 0.0;
- random randnum = new random(iseed, v1, v2);
-
- for (int i = 0; i < mdsize; i += 2) {
- r = randnum.seed();
- one[i].xvelocity = r * randnum.v1;
- one[i + 1].xvelocity = r * randnum.v2;
- }
-
- for (int i = 0; i < mdsize; i += 2) {
- r = randnum.seed();
- one[i].yvelocity = r * randnum.v1;
- one[i + 1].yvelocity = r * randnum.v2;
- }
-
- for (int i = 0; i < mdsize; i += 2) {
- r = randnum.seed();
- one[i].zvelocity = r * randnum.v1;
- one[i + 1].zvelocity = r * randnum.v2;
- }
-
- /* velocity scaling */
-
- ekin = 0.0;
- sp = 0.0;
-
- for (int i = 0; i < mdsize; i++) {
- sp = sp + one[i].xvelocity;
- }
- sp = sp / mdsize;
-
- for (int i = 0; i < mdsize; i++) {
- one[i].xvelocity = one[i].xvelocity - sp;
- ekin = ekin + one[i].xvelocity * one[i].xvelocity;
- }
-
- sp = 0.0;
- for (int i = 0; i < mdsize; i++) {
- sp = sp + one[i].yvelocity;
- }
- sp = sp / mdsize;
-
- for (int i = 0; i < mdsize; i++) {
- one[i].yvelocity = one[i].yvelocity - sp;
- ekin = ekin + one[i].yvelocity * one[i].yvelocity;
- }
-
- sp = 0.0;
- for (int i = 0; i < mdsize; i++) {
- sp = sp + one[i].zvelocity;
- }
- sp = sp / mdsize;
-
- for (int i = 0; i < mdsize; i++) {
- one[i].zvelocity = one[i].zvelocity - sp;
- ekin = ekin + one[i].zvelocity * one[i].zvelocity;
- }
-
- ts = tscale * ekin;
- sc = h * Math.sqrt(tref / ts);
-
- for (int i = 0; i < mdsize; i++) {
-
- one[i].xvelocity = one[i].xvelocity * sc;
- one[i].yvelocity = one[i].yvelocity * sc;
- one[i].zvelocity = one[i].zvelocity * sc;
-
- }
-
- }
-
- public void doinit(int mdsize) {
- for (int j = 0; j < 3; j++) {
- double[] sh = sh_force[j];
- for (int i = 0; i < mdsize; i++) {
- sh[i] = 0.0;
- }
- }
- }
-
- public void doinit2(int mdsize) {
- for (int k = 0; k < 3; k++) {
- double[] sh = sh_force[k];
- double[][] sha = sh_force2[k];
- for (int j = 0; j < nthreads; j++) {
- double[] sha2 = sha[j];
- for (int i = 0; i < mdsize; i++) {
- sh[i] += sha2[i];
- }
- }
- }
-
- for (int k = 0; k < 3; k++) {
- double[][] sh1 = sh_force2[k];
- for (int j = 0; j < nthreads; j++) {
- double[] sh2 = sh1[j];
- for (int i = 0; i < mdsize; i++) {
-
- sh2[i] = 0.0;
- }
- }
- }
-
- for (int j = 1; j < nthreads; j++) {
- mymd.epot[0] += mymd.epot[j];
- mymd.vir[0] += mymd.vir[j];
- }
- for (int j = 1; j < nthreads; j++) {
- mymd.epot[j] = mymd.epot[0];
- mymd.vir[j] = mymd.vir[0];
- }
- for (int j = 0; j < nthreads; j++) {
- mymd.interactions += mymd.interacts[j];
- }
-
- for (int j = 0; j < 3; j++) {
- double sh[] = sh_force[j];
- for (int i = 0; i < mdsize; i++) {
- sh[i] = sh[i] * hsq2;
- }
- }
- }
-
- public void run() {
- /* Parameter determination */
-
- int mdsize;
- double tmpden;
- int movemx = 50;
- particle[] one;
- int id;
- id = this.id;
- mdsize = mymd.PARTSIZE;
- one = new particle[mdsize];
- l = mymd.LENGTH;
- tmpden = den;
- side = Math.pow((mdsize / tmpden), 0.3333333);
- rcoff = mm / 4.0;
-
- a = side / mm;
- sideh = side * 0.5;
- hsq = h * h;
- hsq2 = hsq * 0.5;
- npartm = mdsize - 1;
- rcoffs = rcoff * rcoff;
- tscale = 16.0 / (1.0 * mdsize - 1.0);
- vaver = 1.13 * Math.sqrt(tref / 24.0);
- vaverh = vaver * h;
-
- /* Particle Generation */
-
- xvelocity = 0.0;
- yvelocity = 0.0;
- zvelocity = 0.0;
- ijk = 0;
- init(one, mdsize);
-
- /* Synchronise threads and start timer before MD simulation */
-
- /* MD simulation */
-
- for (int move = 0; move < movemx; move++) {
- /* move the particles and update velocities */
- for (int i = 0; i < mdsize; i++) {
- one[i].domove(side, i);
- }
-
- if (id == 0) {
- doinit(mdsize);
- }
-
- mymd.epot[id] = 0.0;
- mymd.vir[id] = 0.0;
- mymd.interacts[id] = 0;
-
- /* compute forces */
- int numThread = nthreads;
- int lworkload = workload;
- // for (int i=0+id;i<mdsize;i+=numThread) {
- for (int i = 0 ; i < mdsize; i += lworkload) {
-
- int ilow = i;
- int iupper = i + lworkload;
- if (iupper > mdsize) {
- iupper = mdsize;
- }
- int l_size = iupper - ilow;
-
- sese parallel{
- MDWorker worker = new MDWorker(mdsize);
- for(int idx=ilow;idx<iupper;idx++){
-// one[i].force(side, rcoff, mdsize, i, xx, yy, zz, mymd, worker);
- one[idx].force(side, rcoff, mdsize, idx, xx, yy, zz, mymd, worker);
- }
- }
-
- sese serial{
- for (int k = 0; k < 3; k++) {
- for (int j = 0; j < mdsize; j++) {
- sh_force[k][j] += worker.sh_force2[k][j];
- }
- }
- mymd.epot[0] += worker.epot;
- mymd.vir[0] += worker.vir;
- mymd.interactions += worker.interacts;
- }
-
- }
-
- for (int k = 0; k < 3; k++) {
- for (int j = 0; j < mdsize; j++) {
- sh_force[k][j] = sh_force[k][j] * hsq2;
- }
- }
-
- /* update force arrays */
- // if(id == 0) {
- // doinit2(mdsize);
- // }
-
- /* scale forces, update velocities */
- sum = 0.0;
- for (int i = 0; i < mdsize; i++) {
- sum = sum + one[i].mkekin(hsq2, i);
- }
-
- ekin = sum / hsq;
-
- vel = 0.0;
- count = 0.0;
-
- /* average velocity */
-
- for (int i = 0; i < mdsize; i++) {
- velt = one[i].velavg(vaverh, h);
- if (velt > vaverh) {
- count = count + 1.0;
- }
- vel = vel + velt;
- }
-
- vel = vel / h;
-
- /* temperature scale if required */
-
- if ((move < istop) && (((move + 1) % irep) == 0)) {
- sc = Math.sqrt(tref / (tscale * ekin));
- for (int i = 0; i < mdsize; i++) {
- one[i].dscal(sc, 1);
- }
- ekin = tref / tscale;
- }
-
- /* sum to get full potential energy and virial */
-
- if (((move + 1) % iprint) == 0) {
- mymd.ek[id] = 24.0 * ekin;
- mymd.epot[id] = 4.0 * mymd.epot[id];
- etot = mymd.ek[id] + mymd.epot[id];
- temp = tscale * ekin;
- pres = tmpden * 16.0 * (ekin - mymd.vir[id]) / mdsize;
- vel = vel / mdsize;
- rp = (count / mdsize) * 100.0;
- }
-
- // if (id == 0) JGFInstrumentor.stopTimer("Section3:MolDyn:Run",
- // instr.timers);
- }
- }
-}
-
-class particle {
-
- public double xcoord, ycoord, zcoord;
- public double xvelocity, yvelocity, zvelocity;
- int part_id;
- int id;
- double[][] sh_force;
- double[][][] sh_force2;
- particle[] one;
-
- public particle(double xcoord, double ycoord, double zcoord, double xvelocity, double yvelocity,
- double zvelocity, double[][] sh_force, double[][][] sh_force2, int id, particle[] one) {
-
- this.xcoord = xcoord;
- this.ycoord = ycoord;
- this.zcoord = zcoord;
- this.xvelocity = xvelocity;
- this.yvelocity = yvelocity;
- this.zvelocity = zvelocity;
- this.sh_force = sh_force;
- this.sh_force2 = sh_force2;
- this.id = id;
- this.one = one;
- }
-
- public void domove(double side, int part_id) {
-
- xcoord = xcoord + xvelocity + sh_force[0][part_id];
- ycoord = ycoord + yvelocity + sh_force[1][part_id];
- zcoord = zcoord + zvelocity + sh_force[2][part_id];
-
- if (xcoord < 0) {
- xcoord = xcoord + side;
- }
- if (xcoord > side) {
- xcoord = xcoord - side;
- }
- if (ycoord < 0) {
- ycoord = ycoord + side;
- }
- if (ycoord > side) {
- ycoord = ycoord - side;
- }
- if (zcoord < 0) {
- zcoord = zcoord + side;
- }
- if (zcoord > side) {
- zcoord = zcoord - side;
- }
-
- xvelocity = xvelocity + sh_force[0][part_id];
- yvelocity = yvelocity + sh_force[1][part_id];
- zvelocity = zvelocity + sh_force[2][part_id];
-
- }
-
- // public void force(double side, double rcoff,int mdsize,int x, double xx,
- // double yy, double zz, JGFMolDynBench mymd) {
- public void force(double side, double rcoff, int mdsize, int x, double xx, double yy, double zz,
- JGFMolDynBench mymd, MDWorker worker) {
-
- double sideh;
- double rcoffs;
-
- double fxi, fyi, fzi;
- double rd, rrd, rrd2, rrd3, rrd4, rrd6, rrd7, r148;
- double forcex, forcey, forcez;
- int id = this.id;
- sideh = 0.5 * side;
- rcoffs = rcoff * rcoff;
-
- fxi = 0.0;
- fyi = 0.0;
- fzi = 0.0;
-
- for (int i = x + 1; i < mdsize; i++) {
- xx = this.xcoord - one[i].xcoord;
- yy = this.ycoord - one[i].ycoord;
- zz = this.zcoord - one[i].zcoord;
-
- if (xx < (-sideh)) {
- xx = xx + side;
- }
- if (xx > (sideh)) {
- xx = xx - side;
- }
- if (yy < (-sideh)) {
- yy = yy + side;
- }
- if (yy > (sideh)) {
- yy = yy - side;
- }
- if (zz < (-sideh)) {
- zz = zz + side;
- }
- if (zz > (sideh)) {
- zz = zz - side;
- }
-
- rd = xx * xx + yy * yy + zz * zz;
-
- if (rd <= rcoffs) {
- rrd = 1.0 / rd;
- rrd2 = rrd * rrd;
- rrd3 = rrd2 * rrd;
- rrd4 = rrd2 * rrd2;
- rrd6 = rrd2 * rrd4;
- rrd7 = rrd6 * rrd;
- // mymd.epot[id] += (rrd6 - rrd3);
- worker.epot += (rrd6 - rrd3);
- r148 = rrd7 - 0.5 * rrd4;
- // mymd.vir[id] += - rd*r148;
- worker.vir += -rd * r148;
- forcex = xx * r148;
- fxi = fxi + forcex;
-
- // sh_force2[0][id][i] = sh_force2[0][id][i] - forcex;
- worker.sh_force2[0][i] = worker.sh_force2[0][i] - forcex;
-
- forcey = yy * r148;
- fyi = fyi + forcey;
-
- // sh_force2[1][id][i] = sh_force2[1][id][i] - forcey;
- worker.sh_force2[1][i] = worker.sh_force2[1][i] - forcey;
-
- forcez = zz * r148;
- fzi = fzi + forcez;
-
- // sh_force2[2][id][i] = sh_force2[2][id][i] - forcez;
- worker.sh_force2[2][i] = worker.sh_force2[2][i] - forcez;
-
- // mymd.interacts[id]++;
- worker.interacts++;
- }
-
- }
-
- // sh_force2[0][id][x] = sh_force2[0][id][x] + fxi;
- // sh_force2[1][id][x] = sh_force2[1][id][x] + fyi;
- // sh_force2[2][id][x] = sh_force2[2][id][x] + fzi;
-
- worker.sh_force2[0][x] = worker.sh_force2[0][x] + fxi;
- worker.sh_force2[1][x] = worker.sh_force2[1][x] + fyi;
- worker.sh_force2[2][x] = worker.sh_force2[2][x] + fzi;
-
- }
-
- public double mkekin(double hsq2, int part_id) {
-
- double sumt = 0.0;
-
- xvelocity = xvelocity + sh_force[0][part_id];
- yvelocity = yvelocity + sh_force[1][part_id];
- zvelocity = zvelocity + sh_force[2][part_id];
-
- sumt = (xvelocity * xvelocity) + (yvelocity * yvelocity) + (zvelocity * zvelocity);
- return sumt;
- }
-
- public double velavg(double vaverh, double h) {
-
- double velt;
- double sq;
-
- sq = Math.sqrt(xvelocity * xvelocity + yvelocity * yvelocity + zvelocity * zvelocity);
-
- velt = sq;
- return velt;
- }
-
- public void dscal(double sc, int incx) {
- xvelocity = xvelocity * sc;
- yvelocity = yvelocity * sc;
- zvelocity = zvelocity * sc;
- }
-}
-
-class random {
-
- public int iseed;
- public double v1, v2;
-
- public random(int iseed, double v1, double v2) {
- this.iseed = iseed;
- this.v1 = v1;
- this.v2 = v2;
- }
-
- public double update() {
-
- double rand;
- double scale = 4.656612875e-10;
-
- int is1, is2, iss2;
- int imult = 16807;
- int imod = 2147483647;
-
- if (iseed <= 0) {
- iseed = 1;
- }
-
- is2 = iseed % 32768;
- is1 = (iseed - is2) / 32768;
- iss2 = is2 * imult;
- is2 = iss2 % 32768;
- is1 = (is1 * imult + (iss2 - is2) / 32768) % (65536);
-
- iseed = (is1 * 32768 + is2) % imod;
-
- rand = scale * iseed;
-
- return rand;
-
- }
-
- public double seed() {
-
- double s, u1, u2, r;
- s = 1.0;
- do {
- u1 = update();
- u2 = update();
-
- v1 = 2.0 * u1 - 1.0;
- v2 = 2.0 * u2 - 1.0;
- s = v1 * v1 + v2 * v2;
-
- } while (s >= 1.0);
-
- r = Math.sqrt(-2.0 * Math.log(s) / s);
-
- return r;
-
- }
-}
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFMolDynBenchSizeA {
-
- public static void main(String argv[]){
- int nthreads;
- if(argv.length != 0 ) {
- nthreads = Integer.parseInt(argv[0]);
- } else {
- System.printString("The no of threads has not been specified, defaulting to 1\n");
- System.printString(" " + "\n");
- nthreads = 1;
- }
-
- JGFInstrumentor instr = new JGFInstrumentor();
- JGFInstrumentor.printHeader(3,0,nthreads);
-
- JGFMolDynBench mold;
- mold = new JGFMolDynBench(nthreads);
- int size = 0;
- JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers);
- JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers);
-
- mold.JGFsetsize(size);
-
- JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers);
-
- JGFMolDynBench tmp;
- mold.JGFinitialise();
- JGFMolDynBench.JGFapplication(mold);
-
- /* Validate data */
- double[] refval = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dval;
- dval = mold.ek[0].d;
- double dev = Math.fabs(dval - refval[size]);
- long l = (long) refval[size] *1000000;
- long r = (long) dval * 1000000;
- if (l != r ){
- System.printString("Validation failed\n");
- System.printString("Kinetic Energy = " + (long)dval + " " + (long)dev + " " + size + "\n");
- }
-
- JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers);
- double interactions;
- interactions = mold.interactions;
-
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) interactions, instr.timers);
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers);
-
- JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers);
- JGFInstrumentor.printTimer("Section3:MolDyn:Total", instr.timers);
- System.printString("Finished\n");
- }
-}
-
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFMolDynBenchSizeB {
-
- public static void main(String argv[]){
- int nthreads;
- int workload;
- if(argv.length != 0 ) {
- nthreads = Integer.parseInt(argv[0]);
- workload=Integer.parseInt(argv[1]);
- } else {
- System.printString("The no of threads has not been specified, defaulting to 1\n");
- System.printString(" " + "\n");
- nthreads = 1;
- }
-
-// JGFInstrumentor instr = new JGFInstrumentor();
-// JGFInstrumentor.printHeader(3,1,nthreads);
-
- JGFMolDynBench mold;
- mold = new JGFMolDynBench(nthreads,workload);
- int size = 1;
-// JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers);
-// JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers);
-
- mold.JGFsetsize(size);
-
-// JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers);
-
- JGFMolDynBench tmp;
- mold.JGFinitialise();
- JGFMolDynBench.JGFapplication(mold);
-
- /* Validate data */
- double[] refval = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dval;
- dval = mold.ek[0];
- double dev = Math.fabs(dval - refval[size]);
- long l = (long) refval[size] *1000000;
- long r = (long) dval * 1000000;
- if (l != r ){
- System.printString("Validation failed\n");
- System.printString("Kinetic Energy = " + (long)dval + " " + (long)dev + " " + size + "\n");
- }
-
-// JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers);
- double interactions;
- interactions = mold.interactions;
-
-// JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) interactions, instr.timers);
-// JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers);
-
-// JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers);
-// JGFInstrumentor.printTimer("Section3:MolDyn:Total", instr.timers);
-// System.printString("Finished\n");
- }
-}
-
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-public class JGFMolDynBenchSizeC {
-
- public static void main(String argv[]){
- int nthreads;
- if(argv.length != 0 ) {
- nthreads = Integer.parseInt(argv[0]);
- } else {
- System.printString("The no of threads has not been specified, defaulting to 1\n");
- System.printString(" " + "\n");
- nthreads = 1;
- }
-
- JGFInstrumentor instr = new JGFInstrumentor();
- JGFInstrumentor.printHeader(3,2,nthreads);
-
- JGFMolDynBench mold;
- mold = new JGFMolDynBench(nthreads);
- int size = 2;
- JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers);
- JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers);
-
- mold.JGFsetsize(size);
-
- JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers);
-
- JGFMolDynBench tmp;
- mold.JGFinitialise();
- JGFMolDynBench.JGFapplication(mold);
-
- /* Validate data */
- /*
- double[] refval = new double[2];
- refval[0] = 1731.4306625334357;
- refval[1] = 7397.392307839352;
- double dval;
- dval = mold.ek[0].d;
- double dev = Math.fabs(dval - refval[size]);
- long l = (long) refval[size] *1000000;
- long r = (long) dval * 1000000;
- if (l != r ){
- System.printString("Validation failed\n");
- System.printString("Kinetic Energy = " + (long)dval + " " + (long)dev + " " + size + "\n");
- }
-
- JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers);
- double interactions;
- interactions = mold.interactions;
-
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) interactions, instr.timers);
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers);
-
- JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers);
- JGFInstrumentor.printTimer("Section3:MolDyn:Total", instr.timers);
- */
- System.printString("Finished\n");
- }
-}
-
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 1999. *
- * All rights reserved. *
- * *
- **************************************************************************/
-
-public class JGFTimer {
-
- public String name;
- public String opname;
- public double time;
- public double opcount;
- public long calls;
- public int size;
-
- private long start_time;
- private boolean on;
-
- public JGFTimer(String name, String opname){
- this.size = -1;
- this.name = name;
- this.opname = opname;
- reset();
- }
-
- public JGFTimer(String name, String opname, int size){
- this.name = name;
- this.opname = opname;
- this.size = size;
- reset();
- }
-
- public JGFTimer(String name){
- this.name = name;
- this.opname = "";
- reset();
- }
-
-
-
- public void start(){
- if (on) System.printString("Warning timer " + " was already turned on\n");
- on = true;
- start_time = System.currentTimeMillis();
- }
-
-
- public void stop(){
- time += (double) (System.currentTimeMillis()-start_time) / 1000.;
- if (!on) System.printString("Warning timer " + " wasn't turned on\n");
- calls++;
- on = false;
- }
-
- public void addops(double count){
- opcount += count;
- }
-
- public void addtime(double added_time){
- time += added_time;
- }
-
- public void reset(){
- time = 0.0;
- calls = 0;
- opcount = 0;
- on = false;
- }
-
- public double perf(){
- return opcount / time;
- }
-
- public void longprint(){
- System.printString("Timer Calls Time(s) Performance("+opname+"/s)\n");
- System.printString(name + " " + calls + " " + (long)time + " " + (long)this.perf() + "\n");
- }
-
- public void print(){
- if (opname.equals("")) {
- System.printString(name + " " + (long)time + " (s)\n");
- }
- else {
- if(size == 0) {
- System.printString(name + ":SizeA" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
- } else if (size == 1) {
- System.printString(name + ":SizeB" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
- } else if (size == 2) {
- System.printString(name + ":SizeC" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
- } else{
- System.printString(name + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
- }
- }
- }
-
-
- public void printperf(){
-
- String name;
- name = this.name;
-
- // pad name to 40 characters
- while ( name.length() < 40 ) name = name + " ";
-
- System.printString(name + "\t" + (long)this.perf() + "\t"
- + " ("+opname+"/s)\n");
- }
-
-}
+++ /dev/null
-public class MDWorker {
-
- int interacts;
- double vir;
- double epot;
- double sh_force2[][];
-
- public MDWorker(int partsize) {
- sh_force2=new double[3][partsize];
-// for(int i=0;i<3;i++){
-// for(int j=0;j<partsize;j++){
-// sh_force2[i][j]=0;
-// }
-// }
- }
-
-}
+++ /dev/null
-public class MDWrap {
- public mdRunner md;
- public MDWrap() {
- }
-
- public MDWrap(mdRunner m) {
- md=m;
- }
-}
+++ /dev/null
-/**************************************************************************
- * *
- * Java Grande Forum Benchmark Suite - Thread Version 1.0 *
- * *
- * produced by *
- * *
- * Java Grande Benchmarking Project *
- * *
- * at *
- * *
- * Edinburgh Parallel Computing Centre *
- * *
- * email: epcc-javagrande@epcc.ed.ac.uk *
- * *
- * *
- * This version copyright (c) The University of Edinburgh, 2001. *
- * All rights reserved. *
- * *
- **************************************************************************/
-
-// This implements a simple tournament-based barrier, using entirely its
-// own synchronisation. At present Yield() is called to stop busy-waiting
-// processes hogging the processor(s)!
-
-public class TournamentBarrier {
- // Array of flags indicating whether the given process and all those
- // for which it is responsible have finished. The "sense" of this
- // array alternates with each barrier, to prevent having to
- // reinitialise.
- boolean[] IsDone;
- public int maxBusyIter;
- int numThreads;
-
- public TournamentBarrier(int n) {
- numThreads = n;
- maxBusyIter = 1;
- // Superclass constructor should record the number of threads
- // and thread manager.
- //super(n);
-
- // Initialise the IsDone array. The choice of initial value is
- // arbitrary, but must be consistent!
- IsDone = new boolean[numThreads];
- for(int i = 0; i < n; i++) {
- IsDone[i] = false;
- }
- }
-
- // Uses the manager's debug function, so this can only be used after
- // construction!
- public void debug(String s) {
- //System.err.println("Debug message" + s);
- }
-
- /*
- public void setMaxBusyIter(int b) {
- maxBusyIter = b;
- }
- */
-
- public void DoBarrier(int myid) {
- int b;
- //debug("Thread " + myid + " checking in");
-
- int roundmask = 3;
- boolean donevalue = !IsDone[myid];
-
- while(((myid & roundmask) == 0) && (roundmask<(numThreads<<2))) {
- int spacing = (roundmask+1) >> 2;
- for(int i=1; i<=3 && myid+i*spacing < numThreads; i++) {
- //debug("Thread " + myid + " waiting for thread " + (myid+i*spacing));
- b = maxBusyIter;
- while(IsDone[myid+i*spacing] != donevalue) {
- b--;
- if(b==0) {
- //Thread.yield();
- b = maxBusyIter;
- }
- }
- }
- roundmask = (roundmask << 2) + 3;
- }
- //debug("Thread " + myid + " reporting done");
- IsDone[myid] = donevalue;
- b = maxBusyIter;
- while(IsDone[0] != donevalue) {
- b--;
- if(b==0) {
- //Thread.yield();
- b = maxBusyIter;
- }
- }
- //debug("Thread " + myid + " checking out");
-
- }
-}