CS计算机代考程序代写 Homework 3

Homework 3

Matrix Multiplication

You have been tasked with conducting a performance analysis of the following function. You will
need to construct a suite of test cases along with a report. Use the information and tools you have
learned from the previous lectures and tutorials to analyse the performance of the matrix
multiplication function.

void multiply(const float* mata, size_t mata_width, size_t mata_height,
const float* matb, size_t matb_width, size_t matb_height,
float** result_mat, size_t* res_width, size_t* res_height) {

if(result_mat) {
*res_width = matb_width;
*res_height = mata_height;
*result_mat = calloc(mata_height * matb_width, sizeof(float));

for(size_t y = 0; y < mata_height; y++) { for(size_t x = 0; x < matb_width; x++) { for(size_t k = 0; k < mata_width; k++) { (*result_mat)[(y * matb_width) + x] += (mata[(y * mata_width) + k] * matb[(k * matb_width) + x]); } } } } } Given the above matrix multiplication function, you must do the following as part of your analysis and testing. Construct a set of test cases of di�erent sizes (try 32x32, 64x64, 128x128) and larger Using the test cases, measure and record the execution of the function above Record these results and use gnuplot (or some other tool) to graph the data Using techniques from the previous lectures and tutorials, apply them, benchmark, graph and compare. You will need to at least provide one alteration that improves upon the given implementation. Write a conclusion and explain your observations You will need to consider how you could reorder the access of memory in the function and utilise techniques such as unrolling and tiling. Explain if your changes increase or decrease the computation time. For your submission, Your code submission must via this git repository and your report must be submitted to canvas via TurnitIn. You must submit your report to canvas portal by 11:59pm, 29th September, 2020