This is a simple assignment for EE599 students only. Rewrite the following code so the same operations are performed, but not necessarily in the same order or with the same memory layout. You should be able to see a significant speedup.
Here's the code:
static int tbegin; #define TBEGIN \ tbegin = clock(); #define TEND \ printf("%d\n", (clock() - tbegin)); #define DIM 256 double a[DIM][DIM]; struct { double b, c, d, e, f, g, h; } cdehbgf[DIM][DIM]; #define a(x,y) a[x][y] #define b(x,y) cdehbgf[x][y].b #define c(x,y) cdehbgf[x][y].c #define d(x,y) cdehbgf[x][y].d #define e(x,y) cdehbgf[x][y].e #define f(x,y) cdehbgf[x][y].f #define g(x,y) cdehbgf[x][y].g #define h(x,y) cdehbgf[x][y].h main() { int i, j, k; TBEGIN for (i=0; i<DIM; ++i) { for (j=0; j<DIM; ++j) { c(i,j) = 0.0; for (k=0; k<DIM; ++k) { c(i,j) += a(i,k) * f(k,j); } d(i,j) = e(i,j) + h(i,j); g(j,i) += b(j,i); } } TEND exit(0); }
This project is due by 11:59PM, Friday, April 18, 2003. Submit the following: