High Performance Scientific Computing   AMath 483/583 Class Notes   Spring Quarter, 2013

#### Previous topic

Lab 9: Tuesday April 29, 2014

#### Next topic

Lab 11: Tuesday May 6, 2014

# Lab 10: Tuesday May 1, 2014¶

## Programming problem¶

Work on this in groups!

1. The OpenMP code $UWHPSC/labs/lab10/array_omp.f90 contains some bugs. Find the bugs and fix them so that it runs and gives output like this: $ gfortran -fopenmp array_omp.f90
\$ ./a.out
b and bt should be equal
b=
0.270000D+02
0.330000D+02
0.390000D+02
0.450000D+02
0.510000D+02
bt=
0.270000D+02
0.330000D+02
0.390000D+02
0.450000D+02
0.510000D+02

2. If $$A$$ is an $$n \times n$$ matrix and $$x$$ is a vector of length $$n$$, then $$x^TAx$$ is a scalar, a “quadratic form” since it is the sum of terms of the form $$a_{ij}x_ix_j$$ that are quadratic in the elements of $$x$$ .

Write an OpenMP code to compute this for a given matrix and vector. Write out the matrix-vector multiplies as loops and use “omp parallel do” loops to compute first the vector $$Ax$$ and then the inner product of this with the vector x. Test your code using the $$10 \times 10$$ identity matrix for $$A$$ and $$x_i = i$$, in which case the correct answer can be determined to be 385 from the formula

$$\sum_{i=1}^n i^2 = \frac{n(n+1)(2n+1)}6.$$

3. There is a quiz for this lab.