 ### High performance computation of Pi (continued) and Matrix-matrix multiplication

• Complete your program for computation of Pi from the last lab by using OpenMP reduction (we have discussed this in last week's lecture). Analyze the difference in performance between the two versions of the Pi program that you have written, using for loop and using reduction, for large values of numSteps
• Write a sequential program for matrix-matrix multiplication. Watch this video for understanding matrix-matrix multiplication. It is very easy, requires only a few lines of C code. Declare a two-dimensional array:
matrix1[ROW][COL];
#define the two constants ROW and COL so that you can change them easily. Of course, we need two matrices for matrix-matrix multiplication, so we need another two-dimensional array:
matrix2[COL][ROW];
and another matrix to store the result
result[ROW][ROW];
• Now fill matrix1 and matrix2 with random elements between 0 and 1 and then write a sequential program using three for loops for multiplying the matrices and storing the result in the result matrix.
• Parallelize your program using OpenMP. You can parallelize all the for loops or some of them. Evaluate the performance of your program for large matrices. Measure the speed-up against the sequential program.

Amitava Datta
September 2016 School of Computer Science & Software Engineering The University of Western Australia Crawley, Western Australia, 6009. Phone: +61 8 9380 2716 - Fax: +61 8 9380 1089. CRICOS provider code 00126G 