Commit 099699b9 authored by Gaurav Kukreja's avatar Gaurav Kukreja

Sequential Optimization of Gauss

 * residual interleaving
Signed-off-by: 's avatarGaurav Kukreja <mailme.gaurav@gmail.com>
parent c083da69
# Intel compiler # Intel compiler
CC = icc CC = icc
CFLAGS = -g CFLAGS = -g -O3
MPICC = mpicc MPICC = mpicc
......
...@@ -128,12 +128,14 @@ int main( int argc, char *argv[] ) ...@@ -128,12 +128,14 @@ int main( int argc, char *argv[] )
case 1: // GAUSS case 1: // GAUSS
relax_gauss(param.u, np, np); residual = relax_gauss_return_residual(param.u, np, np);
residual = residual_gauss( param.u, param.uhelp, np, np); // residual = residual_gauss( param.u, param.uhelp, np, np);
break; break;
} }
if(param.algorithm == 0)
iter = iter + Interleaving_Count; iter = iter + Interleaving_Count;
else
iter++;
// solution good enough ? // solution good enough ?
if (residual < 0.000005) break; if (residual < 0.000005) break;
...@@ -146,7 +148,7 @@ int main( int argc, char *argv[] ) ...@@ -146,7 +148,7 @@ int main( int argc, char *argv[] )
} }
// Flop count after <i> iterations // Flop count after <i> iterations
flop = iter * 11.0 * param.act_res * param.act_res; flop = iter * 7.0 * param.act_res * param.act_res;
// stopping time // stopping time
runtime = wtime() - runtime; runtime = wtime() - runtime;
......
...@@ -55,12 +55,14 @@ int coarsen(double *uold, unsigned oldx, unsigned oldy , ...@@ -55,12 +55,14 @@ int coarsen(double *uold, unsigned oldx, unsigned oldy ,
double residual_gauss( double *u, double *utmp, double residual_gauss( double *u, double *utmp,
unsigned sizex, unsigned sizey ); unsigned sizex, unsigned sizey );
#endif #endif
void relax_gauss( double *u, double relax_gauss_return_residual( double *u,
unsigned sizex, unsigned sizey ); unsigned sizex, unsigned sizey );
// Jacobi: relax_jacobi.c // Jacobi: relax_jacobi.c
#if 0
double residual_jacobi( double *u, double residual_jacobi( double *u,
unsigned sizex, unsigned sizey ); unsigned sizex, unsigned sizey );
#endif
double relax_jacobi_return_residual( double *u, double *utmp, double relax_jacobi_return_residual( double *u, double *utmp,
unsigned sizex, unsigned sizey, int Interleaving_Count ); unsigned sizex, unsigned sizey, int Interleaving_Count );
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "heat.h" #include "heat.h"
#if 0
/* /*
* Residual (length of error vector) * Residual (length of error vector)
* between current solution and next after a Gauss-Seidel step * between current solution and next after a Gauss-Seidel step
...@@ -47,27 +49,32 @@ double residual_gauss( double *u, double *utmp, ...@@ -47,27 +49,32 @@ double residual_gauss( double *u, double *utmp,
return sum; return sum;
} }
#endif
/* /*
* One Gauss-Seidel iteration step * One Gauss-Seidel iteration step
* *
* Flop count in inner body is 4 * Flop count in inner body is 4
*/ */
void relax_gauss( double *u, double relax_gauss_return_residual( double *u,
unsigned sizex, unsigned sizey ) unsigned sizex, unsigned sizey )
{ {
unsigned i, j; unsigned i, j;
double temp, diff, residual;
residual =0;
for( i=1; i<sizey-1; i++ ) for( i=1; i<sizey-1; i++ )
{ {
for( j=1; j<sizex-1; j++ ) for( j=1; j<sizex-1; j++ )
{ {
temp = u[i*sizex+j];
u[i*sizex+j]= 0.25 * (u[ i*sizex + (j-1) ]+ u[i*sizex+j]= 0.25 * (u[ i*sizex + (j-1) ]+
u[ i*sizex + (j+1) ]+ u[ i*sizex + (j+1) ]+
u[ (i-1)*sizex + j ]+ u[ (i-1)*sizex + j ]+
u[ (i+1)*sizex + j ]); u[ (i+1)*sizex + j ]);
diff = u[i*sizex+j] - temp;
residual += diff*diff;
} }
} }
return residual;
} }
50 # iterations 1024 # iterations
100 # initial resolution 256 # initial resolution
2900 # max resolution (spatial resolution) 4096 # max resolution (spatial resolution)
200 # resolution step size 3840 # resolution step size
0 # Algorithm 0=Jacobi 1=Gauss 1 # Algorithm 0=Jacobi 1=Gauss
2 # number of heat sources 2 # number of heat sources
0.0 0.0 1.0 1.0 # (x,y), size temperature 0.0 0.0 1.0 1.0 # (x,y), size temperature
1.0 1.0 1.0 0.5 1.0 1.0 1.0 0.5
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment