Some Computational Experiments

A matrix multiply code (mmbm.c)


#include <stdio.h>
#include <stdlib.h>
#define N 513

main()
{
double a[N][N],b[N][N],c[N][N];
int i,j,k;
srand(1);
for(i=0;i<N;i++)
   {
   for(j=0;j<N;j++)
     {
     a[i][j] = (double)(rand()/1000);
     b[i][j] = (double)(rand()/1000);
     c[i][j] = 0;
     }
   }
for(i=0;i<N;i++)
   {
   for(j=0;j<N;j++)
     {
     for(k=0;k<N;k++)
       {
       c[i][j] = c[i][j] + a[i][k]*b[k][j];
       }
     }
   }
i = rand()%N;
j =  rand()%N;
printf("c[%d][%d] = %f\n",i,j,c[i][j]);
return(0);
}
 



xlc -O mmbm.c
time ./a.out
Some RS6000 runs...

Use bsub to gain access to an uncrowded machine:

1.  log onto lamar.acns.colostate.edu
2.  make a file, here called job1, that looks like
 
xlc -O mmbm.c
time ./a.out

3.  type

%bsub -out out1 -err out1 job1

to submit your job1.

4. use

%more out1

to see your results

Here are some timings
 
 
N 256 257 512 513
Time 4.8u  0.5u 38.2u 4.5u

Now modify the matrix multiply to read:


for(k=0;k<N;k++)
   {
   for(i=0;i<N;i++)
     {
     for(j=0;j<N;j++)
       {
       c[i][j] = c[i][j] + a[i][k]*b[k][j];
       }
     }
   }



 
 
N 256 257 512 513
Time 1.0u 1.0u 8.1u 8.0u

sd