A base program performing matrix multiplication is provided, along with a build file and script to enable
execution of a range of experiments. This code is written in C, and has been prepared to compile with
1
the gcc compiler on Linux. There are no restrictions about the underlying hardware that can be used
for this exercise, however there may be certain stages which are not available on particular systems. The
code has been tested on the machines in Kilburn 1.10, which contain an Intel Core i7-8700 CPU, and can
be booted into Linux.
main.c
The provided code performs matrix multiplication, generating two matrices A and B of dimensions: A(L
rows, M columns), and B(M rows, N columns), resulting in a matrix C with dimensions (L rows, N
columns). After initialising the matrix data structures, a series of matrix multiplication functions are
included providing the base functionality from Secs. 1.2-1.7. The program can be compiled using the
makefile discussed below, and then executed from the command line using:
./matrix [login to view URL] <L> <M> <N> <seed>
Where L, M, and N define the dimensions of A and B, and seed is used to configure the random number
generator used to populate A and B with data (double precision values are initialised between 0 and 1).
Note that the variable PRINT MATRICES is included to enable printing of the different data structures to
the command line: setting this to 1 enables printing, while setting this to 0 causes the application to
report only timing data.
makefile
The simple makefile provided enables compilation of matrix [login to view URL], and also creates the assembly language version of the code in main.s, which can help in understanding how the specific optimisations
are converted into instruction code. The build process can be executed using the ‘make’ command (it’s
recommended to run ‘make clean’ beforehand to remove files from the previous build).
square mm [login to view URL]
This script file: square mm [login to view URL], is provided to automate execution of the matrix multiplication
program on multiple matrices of different dimensions. For simplicity, this assignment will only consider
the case of square matrices where L = M = N, i.e. where matrices A, B, and C all have dimensions
N × N. This script therefore executes the application matrix [login to view URL] using a range of matrix
dimensions, to demonstrate operation. Experiments should be adapted to explore the architecture of the
underlying system, e.g. selecting different initial matrix dimensions ($N) and increment sizes ($dN), and
total number of sizes explore ($NUM TESTS), to explore the full range of system performance.