6CS005 High Performance Computing
Task:
Assessment overview
This portfolio is split up into 4 separate tasks which will test your knowledge of advanced multithreading and GPGPU programming using CUDA. Each task should be zipped up into a single zip folder containing all C/CUDA and resource files for the submission on Canvas. All questions below
1. Matrix Multiplication using multithreading
You will create a matrix multiplication program which uses multithreading. Matrices are often twodimensional arrays varying in sizes, for your application, you will only need to multiply twodimensional ones. Your program will read in the matrices from a supplied file (txt), store them appropriately using dynamic memory allocation features and multiply them by splitting the tasks across “n” threads (any amount of threads). You should use command line arguments (argv) to allow the user to enter the amount of threads to use. You should check the value for sensible limits, eg. Greater than zero and less than 1000. If the number of threads requested by the user is greater than the biggest dimension of the matrices to be multiplied, the actual number of threads used in the calculation should be limited to the maximum dimension of the matrices.
The matrix data file will be supplied to you, and it will be unique to you. Your program should be able to take “any” size matrices and multiply them depending on the data found within the file, so you should ensure your submission works with any size matrices. Some sizes of matrices cannot be multiplied together, for example, if Matrix A is 3x3 and Matrix B is 2x2, you cannot multiply them. If Matrix A is 2x3 and Matrix B is 3x2, then this can be multiplied. You will need to research how to multiply matrices, this will also be covered in the lectures. If the matrices cannot be multiplied, your program should output an error message notifying the user, and move on to the next pair of matrices. Your program
should store the results of your successful matrix multiplications in a text file called “matrixresults1234567.txt” with your student ID replacing the “1234567” bit, in exactly the same format as the supplied input data file. This file will also have to be submitted along with your program files and it will be tested for correct formatting. As a minimum, you are expected to use the standard C file handling functions: fopen(), fclose(), fscanf(), and fprintf(), to read and to write your files. stdin and stdout redirection will not be acceptable.