/* !-------------------------------------------------------------------------! ! ! ! N A S P A R A L L E L B E N C H M A R K S 3.0 ! ! ! ! J A V A V E R S I O N ! ! ! ! B T B a s e ! ! ! !-------------------------------------------------------------------------! ! ! ! BTbase implements base class for BT benchmark. ! ! ! ! Permission to use, copy, distribute and modify this software ! ! for any purpose with or without fee is hereby granted. We ! ! request, however, that all derived work reference the NAS ! ! Parallel Benchmarks 3.0. This software is provided "as is" ! ! without express or implied warranty. ! ! ! ! Information on NPB 3.0, including the Technical Report NAS-02-008 ! ! "Implementation of the NAS Parallel Benchmarks in Java", ! ! original specifications, source code, results and information ! ! on how to submit new results, is available at: ! ! ! ! http://www.nas.nasa.gov/Software/NPB/ ! ! ! ! Send comments or suggestions to npb@nas.nasa.gov ! ! ! ! NAS Parallel Benchmarks Group ! ! NASA Ames Research Center ! ! Mail Stop: T27A-1 ! ! Moffett Field, CA 94035-1000 ! ! ! ! E-mail: npb@nas.nasa.gov ! ! Fax: (650) 604-3957 ! ! ! !-------------------------------------------------------------------------! ! Translation to Java and to MultiThreaded Code: ! ! Michael A. Frumkin ! ! Mathew Schultz ! !-------------------------------------------------------------------------! */ package NPB_JAV.BTThreads; import NPB_JAV.BT; import NPB_JAV.*; public class BTBase extends Thread{ public static final String BMName="BT"; public char CLASS = 'S'; //npb class parameters protected int IMAX=0, JMAX=0, KMAX=0,problem_size=0; protected int grid_points[] = {0,0,0}; protected int niter_default=0; protected double dt_default=0.0; //array declarations from header.h protected double us[],vs[],ws[], qs[],rho_i[],square[]; protected int jsize1, ksize1; protected double forcing[],u[],rhs[], cv[], cuf[],q[]; protected int isize2,jsize2,ksize2; protected double ue[], buf[]; protected int jsize3; //here 5 are the dimensions of the CFD vector //(density,x_impuls,y_impuls,z_impuls,energy) protected static final int isize4=5,jsize4=5*5, ksize4=5*5*3; protected static final int aa=0, bb=1, cc=2, BLOCK_SIZE=5; // constants protected static double tx1,tx2,tx3,dt, ty1,ty2,ty3, tz1,tz2,tz3, dx1,dx2,dx3,dx4,dx5, dy1,dy2,dy3,dy4,dy5, dz1,dz2,dz3,dz4,dz5, dssp,dxmax,dymax,dzmax, xxcon1,xxcon2,xxcon3,xxcon4,xxcon5, dx1tx1, dx2tx1,dx3tx1,dx4tx1,dx5tx1, yycon1,yycon2,yycon3,yycon4,yycon5, dy1ty1,dy2ty1,dy3ty1,dy4ty1,dy5ty1, zzcon1,zzcon2,zzcon3,zzcon4,zzcon5, dz1tz1,dz2tz1,dz3tz1,dz4tz1,dz5tz1, dnxm1,dnym1,dnzm1, c1c2, c1c5, c3c4, c1345, conz1, c1, c2, c3, c4, c5, c4dssp, c5dssp, dtdssp, dttx1, dttx2, dtty1, dtty2, dttz1, dttz2, c2dttx1, c2dtty1, c2dttz1, comz1, comz4, comz5, comz6,c3c4tx3, c3c4ty3, c3c4tz3, c2iv, con43, con16; protected static double ce[] = { 2.0, 1.0, 2.0, 2.0, 5.0, 0.0, 0.0, 2.0, 2.0, 4.0, 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 0.0, 2.0, 5.0, 1.0, 0.0, 0.0, 0.1, 3.0, 2.0, 2.0, 2.0, 0.4, 0.5, 3.0, 3.0, 3.0, 0.3, 0.02, 0.01, 0.04, 0.03, 0.05, 0.01, 0.03, 0.03, 0.05, 0.04, 0.03, 0.02, 0.05, 0.04, 0.03, 0.5, 0.4, 0.3, 0.2, 0.1, 0.4, 0.3, 0.5, 0.1, 0.3, 0.3, 0.5, 0.4, 0.3, 0.2}; //timer constants public boolean timeron=false; public static final int t_rhsx=2, t_rhsy=3, t_rhsz=4, t_xsolve=6,t_ysolve=7,t_zsolve=8, t_rdis1=9,t_rdis2=10,t_add=11, t_rhs=5,t_last=11,t_total=1; public Timer timer = new Timer(); public BTBase(){} public BTBase(char clss,int np){ CLASS = clss; num_threads = np; switch (clss){ case 'S': problem_size = IMAX = JMAX = KMAX = grid_points[0] = grid_points[1] = grid_points[2] = 12; dt_default=.01; niter_default=60; CLASS='S'; break; case 'W': problem_size = IMAX = JMAX = KMAX = grid_points[0] = grid_points[1] = grid_points[2] = 24; dt_default=.0008; niter_default=200; CLASS='W'; break; case 'A': problem_size = IMAX = JMAX = KMAX = grid_points[0] = grid_points[1] = grid_points[2] = 64; dt_default=.0008; niter_default=200; CLASS='A'; break; case 'B': problem_size = IMAX = JMAX = KMAX = grid_points[0] = grid_points[1] = grid_points[2] = 102; dt_default=.0003; niter_default=200; CLASS='B'; break; case 'C': problem_size = IMAX = JMAX = KMAX = grid_points[0] = grid_points[1] = grid_points[2] = 162; dt_default=.0001; niter_default=200; CLASS='C'; break; } // set up arrays and array strides jsize1=IMAX/2*2+1; ksize1=(JMAX/2*2+1)*(IMAX/2*2+1); us = new double[(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; vs = new double[(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; ws = new double[(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; qs = new double[(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; rho_i = new double[(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; square = new double[(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; isize2=5; jsize2=5*(IMAX/2*2+1); ksize2=5*(IMAX/2*2+1)*(JMAX/2*2+1); forcing = new double[5*(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; u = new double[5*(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; rhs = new double[5*(IMAX/2*2+1)*(JMAX/2*2+1)*KMAX]; cv = new double[problem_size+2]; cuf = new double[problem_size+2]; q = new double[problem_size+2]; jsize3=(problem_size+2); ue = new double[(problem_size+2)*5]; buf = new double[(problem_size+2)*5]; } // thread variables protected Thread master = null; protected int num_threads; protected RHSCompute rhscomputer[]; protected XSolver xsolver[]; protected YSolver ysolver[]; protected ZSolver zsolver[]; protected RHSAdder rhsadder[]; public void setupThreads(BT bt){ master = bt; if(num_threads>problem_size-2) num_threads=problem_size-2; int interval1[]=new int[num_threads]; int interval2[]=new int[num_threads]; set_interval(problem_size, interval1); set_interval(problem_size-2, interval2); int partition1[][] = new int[interval1.length][2]; int partition2[][] = new int[interval2.length][2]; set_partition(0,interval1,partition1); set_partition(1,interval2,partition2); rhscomputer = new RHSCompute[num_threads]; xsolver = new XSolver[num_threads]; ysolver = new YSolver[num_threads]; zsolver = new ZSolver[num_threads]; rhsadder = new RHSAdder[num_threads]; // create and start threads for(int ii=0;ii