int main(int argc,char *argv[]) { double *A0_naive, *A0_test; double *Anext_naive, *Anext_test; double *Afinal_naive, *Afinal_test; int nx,ny,nz,tx,ty,tz,timesteps; int i,j; ticks t1, t2; double spt; /* parse command line options */ if (argc < 8) { printf("\nUSAGE:\n%s <grid x> <grid y> <grid z> <block x> <block y> <block z> <timesteps>\n", argv[0]); printf("\nTIME SKEWING CONSTRAINTS:\nIn each dimension, <grid size - 2> should be a multiple of <block size>.\n"); printf("\nCIRCULAR QUEUE CONSTRAINTS:\n<grid y - 2> should be a multiple of <block y>. The block sizes in the other dimensions are ignored.\n\n"); return EXIT_FAILURE; } nx = atoi(argv[1]); ny = atoi(argv[2]); nz = atoi(argv[3]); tx = atoi(argv[4]); ty = atoi(argv[5]); tz = atoi(argv[6]); timesteps = atoi(argv[7]); printf("%dx%dx%d, blocking: %dx%dx%d, timesteps: %d\n", nx,ny,nz,tx,ty,tz,timesteps); #ifdef HAVE_PAPI PAPI_library_init(PAPI_VER_CURRENT); #endif /* find conversion factor from ticks to seconds */ spt = seconds_per_tick(); // allocate arrays A0_naive=(double*)malloc(sizeof(double)*nx*ny*nz); A0_test=(double*)malloc(sizeof(double)*nx*ny*nz); Anext_naive=(double*)malloc(sizeof(double)*nx*ny*nz); Anext_test=(double*)malloc(sizeof(double)*nx*ny*nz); // Run Naive Code StencilInit(nx,ny,nz,A0_naive); StencilInit(nx,ny,nz,Anext_naive); StencilProbe_naive(A0_naive, Anext_naive, nx, ny, nz, tx, ty, tz, timesteps); if (timesteps%2 == 0) { Afinal_naive = A0_naive; } else { Afinal_naive = Anext_naive; } printf("USING TIMER: %s \t SECONDS PER TICK:%g \n", TIMER_DESC, spt); // Test Rivera Blocking StencilInit(nx,ny,nz,A0_test); StencilInit(nx,ny,nz,Anext_test); printf("Checking Rivera (single-timestep) blocking...\n"); StencilProbe_rivera(A0_test, Anext_test, nx, ny, nz, tx, ty, tz, timesteps); if (timesteps%2 == 0) { Afinal_test = A0_test; } else { Afinal_test = Anext_test; } check_vals(Afinal_naive, Afinal_test, nx, ny, nz); // Test Cache-Oblivious Blocking StencilInit(nx,ny,nz,A0_test); StencilInit(nx,ny,nz,Anext_test); printf("Checking Cache-Oblivious blocking...\n"); StencilProbe_oblivious(A0_test, Anext_test, nx, ny, nz, tx, ty, tz, timesteps); if (timesteps%2 == 0) { Afinal_test = A0_test; } else { Afinal_test = Anext_test; } check_vals(Afinal_naive, Afinal_test, nx, ny, nz); // Test Time-Skewed Blocking StencilInit(nx,ny,nz,A0_test); StencilInit(nx,ny,nz,Anext_test); printf("Checking Time-Skewed blocking...\n"); StencilProbe_timeskew(A0_test, Anext_test, nx, ny, nz, tx, ty, tz, timesteps); if (timesteps%2 == 0) { Afinal_test = A0_test; } else { Afinal_test = Anext_test; } check_vals(Afinal_naive, Afinal_test, nx, ny, nz); // Test Circular-Queue Blocking StencilInit(nx,ny,nz,A0_test); StencilInit(nx,ny,nz,Anext_test); if (timesteps > 1) { CircularQueueInit(nx, ty, timesteps); } printf("Checking Circular-Queue blocking...\n"); StencilProbe_circqueue(A0_test, Anext_test, nx, ny, nz, tx, ty, tz, timesteps); Afinal_test = Anext_test; check_vals(Afinal_naive, Afinal_test, nx, ny, nz); /* free arrays */ free(Anext_naive); free(A0_naive); free(Anext_test); free(A0_test); return EXIT_SUCCESS; }
int main(int argc,char *argv[]) { float* vx0; float* vy0; float* vz0; float* txx0; float* tyy0; float* tzz0; float* txy0; float* txz0; float* tyz0; float* fx; float* fy; float* fz; int nx,ny,nz,tx,ty,tz,timesteps; int i,j,k; float spt; int block; uint64_t start, exec_time; /* parse command line options */ nx = atoi(argv[1]); ny = atoi(argv[2]); nz = atoi(argv[3]); tx = 1; ty = 1; tz = 1; timesteps = atoi(argv[4]); // printf("%dx%dx%d, blocking: %dx%dx%d, timesteps: %d\n", // nx,ny,nz,tx,ty,tz,timesteps); /* allocate arrays */ vx0=(float*)malloc(sizeof(float)*nx*ny*nz); vy0=(float*)malloc(sizeof(float)*nx*ny*nz); vz0=(float*)malloc(sizeof(float)*nx*ny*nz); txx0=(float*)malloc(sizeof(float)*nx*ny*nz); tyy0=(float*)malloc(sizeof(float)*nx*ny*nz); tzz0=(float*)malloc(sizeof(float)*nx*ny*nz); txy0=(float*)malloc(sizeof(float)*nx*ny*nz); txz0=(float*)malloc(sizeof(float)*nx*ny*nz); tyz0=(float*)malloc(sizeof(float)*nx*ny*nz); fx=(float*)malloc(sizeof(float)*nx*ny*nz); fy=(float*)malloc(sizeof(float)*nx*ny*nz); fz=(float*)malloc(sizeof(float)*nx*ny*nz); /* initialize arrays to all ones */ StencilInit(nx,ny,nz,vx0); StencilInit(nx,ny,nz,vy0); StencilInit(nx,ny,nz,vz0); StencilInit(nx,ny,nz,txx0); StencilInit(nx,ny,nz,tyy0); StencilInit(nx,ny,nz,tzz0); StencilInit(nx,ny,nz,txy0); StencilInit(nx,ny,nz,txz0); StencilInit(nx,ny,nz,tyz0); StencilInit(nx,ny,nz,fx); StencilInit(nx,ny,nz,fy); StencilInit(nx,ny,nz,fz); start = get_time(); /* stencil function */ StencilProbe( vx0, vy0, vz0, txx0, tyy0, tzz0, txy0, txz0, tyz0, fx, fy, fz, nx, ny, nz, tx, ty, tz, timesteps); exec_time = diff_time(start, get_time()); //printf("#call of pair of stencil(prev/next) :%d \n",timesteps/2); printf ("%d;%d;%d;%d;%d;" "%" PRIu64, nx, ny, nz, timesteps, omp_thread_count(), exec_time); //printf ("%d " "%" PRIu64, omp_thread_count(), exec_time/1000/1000); /* for (k = 2; k < nz - 2; k++) { for (j = 2; j < ny - 2; j++) { for (i = 2; i < nx - 2; i++) { */ #ifdef PROUT i=13; j=15; k=37; printf("\n"); printf("i=%d - j=%d - k=%d - %f - %f \n",i,j,k,vx0[Index3D (nx, ny, i, j, k)],txx0[Index3D (nx, ny, i, j, k)]); #endif /* } } } */ /* free arrays */ free(vx0); free(vy0); free(vz0); free(fx); free(fy); free(fz); free(txx0); free(tyy0); free(tzz0); free(txy0); free(txz0); free(tyz0); }
int main(int argc,char *argv[]) { double *Anext; double *A0; int nx,ny,nz,tx,ty,tz,timesteps; int i; ticks t1, t2; double spt; /* parse command line options */ if (argc < 8) { printf("\nUSAGE:\n%s <grid x> <grid y> <grid z> <block x> <block y> <block z> <timesteps>\n", argv[0]); printf("\nTIME SKEWING CONSTRAINTS:\nIn each dimension, <grid size - 2> should be a multiple of <block size>.\n"); printf("\nCIRCULAR QUEUE CONSTRAINTS:\n<grid y - 2> should be a multiple of <block y>. The block sizes in the other dimensions are ignored.\n\n"); return EXIT_FAILURE; } nx = atoi(argv[1]); ny = atoi(argv[2]); nz = atoi(argv[3]); tx = atoi(argv[4]); ty = atoi(argv[5]); tz = atoi(argv[6]); timesteps = atoi(argv[7]); printf("%dx%dx%d, blocking: %dx%dx%d, timesteps: %d\n", nx,ny,nz,tx,ty,tz,timesteps); #ifdef HAVE_PAPI PAPI_library_init(PAPI_VER_CURRENT); #endif /* find conversion factor from ticks to seconds */ spt = seconds_per_tick(); /* allocate arrays */ Anext=(double*)malloc(sizeof(double)*nx*ny*nz); A0=(double*)malloc(sizeof(double)*nx*ny*nz); printf("USING TIMER: %s \t SECONDS PER TICK:%g \n", TIMER_DESC, spt); for (i=0;i<NUM_TRIALS;i++) { /* initialize arrays to all ones */ StencilInit(nx,ny,nz,Anext); StencilInit(nx,ny,nz,A0); #ifdef CIRCULARQUEUEPROBE if (timesteps > 1) { CircularQueueInit(nx, ty, timesteps); } #endif // clear_cache(); t1 = getticks(); /* stencil function */ StencilProbe(A0, Anext, nx, ny, nz, tx, ty, tz, timesteps); t2 = getticks(); printf("elapsed ticks: %g time:%g \n", elapsed(t2, t1), spt * elapsed(t2,t1)); #ifdef COMPUTECHECKSUM extern double CheckSum(int, int, int, double*); double r1=CheckSum(nx, ny, nz, A0); double r2=CheckSum(nx, ny, nz, Anext); printf("Checksums: A0=%g, Anext=%g\n", r1, r2); #endif } /* free arrays */ free(Anext); free(A0); return EXIT_SUCCESS; }