/* !-------------------------------------------------------------------------! ! ! ! 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 ! ! ! ! S P B a s e ! ! ! !-------------------------------------------------------------------------! ! ! ! SPbase implements base class for SP 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.SPThreads; import NPB_JAV.*; import NPB_JAV.SP; public class SPBase extends Thread{ public static final String BMName="SP"; public char CLASS = 'S'; protected int IMAX=0, JMAX=0, KMAX=0, problem_size=0, nx2=0, ny2=0, nz2=0; protected int grid_points[] = {0,0,0}; protected int niter_default=0; protected double dt_default=0.0; protected double u[], rhs[], forcing[]; protected int isize1, jsize1, ksize1; protected double us[], vs[], ws[], qs[], rho_i[], speed[], square[]; protected int jsize2, ksize2; protected double ue[], buf[]; protected int jsize3; protected double lhs[], lhsp[], lhsm[]; protected int jsize4; protected double cv[], rhon[], rhos[], rhoq[], cuf[], q[]; protected static double tx1, tx2, tx3, ty1, ty2, ty3, tz1, tz2, tz3, dx1, dx2, dx3, dx4, dx5, dy1, dy2, dy3, dy4, dy5, dz1, dz2, dz3, dz4, dz5, dssp, dt, 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, bt, dttx2, dtty1, dtty2, dttz1, dttz2, c2dttx1, c2dtty1, c2dttz1, comz1, comz4, comz5, comz6, c3c4tx3, c3c4ty3, c3c4tz3, c2iv, con43, con16; protected 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}; public boolean timeron = false; public Timer timer = new Timer(); public static final int t_total = 1, t_rhsx = 2, t_rhsy = 3,t_rhsz = 4, t_rhs = 5, t_xsolve = 6, t_ysolve = 7, t_zsolve = 8, t_rdis1 = 9, t_rdis2 = 10, t_txinvr = 11, t_pinvr = 12, t_ninvr = 13, t_tzetar = 14, t_add = 15, t_last = 15; public SPBase(){} public SPBase(char clss, int np){ CLASS = clss; num_threads = np; switch(clss){ case 'S': IMAX=JMAX=KMAX=problem_size =grid_points[0]=grid_points[1]=grid_points[2]=12; dt_default = .015; niter_default = 100; break; case 'W': IMAX=JMAX=KMAX=problem_size =grid_points[0]=grid_points[1]=grid_points[2]=36; dt_default = .0015; niter_default = 400; break; case 'A': IMAX=JMAX=KMAX=problem_size=grid_points[0]= grid_points[1]=grid_points[2]=64; dt_default = .0015; niter_default = 400; break; case 'B': IMAX=JMAX=KMAX=problem_size=grid_points[0]= grid_points[1]=grid_points[2]=102; dt_default = .001; niter_default = 400; break; case 'C': IMAX=JMAX=KMAX=problem_size=grid_points[0]= grid_points[1]=grid_points[2]=162; dt_default = .00067; niter_default = 400; break; } isize1 = 5; jsize1 = 5*(IMAX+1); ksize1 = 5*(IMAX+1)*(JMAX+1); u = new double[5*(IMAX+1)*(JMAX+1)*KMAX]; rhs = new double[5*(IMAX+1)*(JMAX+1)*KMAX]; forcing = new double[5*(IMAX+1)*(JMAX+1)*KMAX]; jsize2 = (IMAX+1); ksize2 = (IMAX+1)*(JMAX+1); us = new double[(IMAX+1)*(JMAX+1)*KMAX]; vs = new double[(IMAX+1)*(JMAX+1)*KMAX]; ws = new double[(IMAX+1)*(JMAX+1)*KMAX]; qs = new double[(IMAX+1)*(JMAX+1)*KMAX]; rho_i = new double[(IMAX+1)*(JMAX+1)*KMAX]; speed = new double[(IMAX+1)*(JMAX+1)*KMAX]; square = new double[(IMAX+1)*(JMAX+1)*KMAX]; jsize3 = problem_size; ue = new double[problem_size*5]; buf = new double[problem_size*5]; jsize4 = 5; lhs = new double[5*(problem_size+1)]; lhsp = new double[5*(problem_size+1)]; lhsm = new double[5*(problem_size+1)]; cv = new double[problem_size]; rhon = new double[problem_size]; rhos = new double[problem_size]; rhoq = new double[problem_size]; cuf = new double[problem_size]; q = new double[problem_size]; } protected Thread master=null; protected int num_threads; protected RHSCompute rhscomputer[]; protected TXInverse txinverse[]; protected XSolver xsolver[]; protected YSolver ysolver[]; protected ZSolver zsolver[]; protected RHSAdder rhsadder[]; public void setupThreads(SP sp){ master = sp; 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]; txinverse = new TXInverse[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