CS 2734 Computer Organization II

Laboratory 6

Laboratory 6 will meet in the Sun laboratory. Prior to the laboratory write a Sparc function to compute the positive dot product of two vectors:

int posdot_product(int a[], int b[], int n)
{
int sum;
int i;
sum = 0;
for (i = 0; i < n; i++) {
if (a[i] > 0 && b[i] > 0)
sum += a[i]*b[i];
}
return sum;
}

Write a C calling program that reads n and c from the command line and malloc's two integer arrays, x and y, of size n. It should the initialize x[i] = 2(i - c) and y[i] = 2(i-c)+1 for i in [0 .. n-1]. Call posdot_product(x, y, n) and output the result.
Use a makefile. Hand in all source code and your makefile when your get the lab checked off.