CS3014 Lab 1: Parallel matrix multiplication
9th February 2015
Complex matrix times matrix multiplication is one of the most important and commonly-performed operations in computational science. The purpose of this labs is to better understand vectorization, code optimiation and parallelization by writing an efficient matrix multiplication routine.
The machine is stoker.scss.tcd.ie. This machine has four processors. Each processor has eight out-of-order pipelined, superscalar cores. And each core has two-way simultaneous multithreading.
To compile with SSE on stoker you should:
- #include<x86intrin.h> in your C/C++ code
- compile your program with: gcc -O3 -msse4 file.c To comile with OpenMP, add the flag -fopenmp.
To write an efficient matrix multiplication routine you will need an efficient basic algorithm, but it is also important that you take account of issues such as locality of data access and multiple available processor cores.
Your routine should be written in C/C++, and multiply arrays of double-precision numbers. You may consult books, papers and online sources, but all sources should be acknowledged in your submission. All the submitted code should be your own, however.
Your routine will work on matrices of the following type: struct complex { float real; float imag; };
Your routine should have the following prototype: void matmul(struct complex ** A, struct complex ** B, struct complex ** C, int a_dim1, int a_dim2, int b_dim2)
Where A, B and C are two dimensional arrays of complex numbers with dimensions that make them compatible for multiplication (that is a_dim2 == b_dim1).
The work for this lab should be carried out in pairs, and each pair of students will make a joint submission. The submission should take the form of a working, well-written, commented piece of code, and a 1-2 page docuement descirbing the efforts made to make the code efficient. Both members of the team should be able to fully explain all the code, and should be prepared to stand up in front of the class and speak about their solution.
Your routine should be capable of operating efficiently on a range of matrix sizes and shapes. You must use the following test harness to test and time your code: https://www.scss.tcd.ie/David.Gregg/cs3014/labs/complex-matmul-harness.c
The marks you get for this lab will depend on two things. First, the mark will depend on the code itself --- its correctness, quality and the optimization ideas it contains. Secondly your make will depend on the running time of the code. The faster your code compared to that of other teams, the higher the mark you will get.
Submission details will be agreed after discussion in class.