Question: 1. Implement a simple matrix multiplication program in C or C++. Matrix multiplication of C = AX B where A, B and C are

1. Implement a simple matrix multiplication program in C or C++. Matrix

1. Implement a simple matrix multiplication program in C or C++. Matrix multiplication of C = AX B where A, B and C are matrices of size NX N (N rows and N columns) and both A and B are initialised with random values. At the end of the program, You should writ your output to a file. How matrix multiplication works? Please see here (https://en.wikipedia.org/wiki/Matrix_multiplication). Simply to calculate Ci,j (row i, column j), you multiply every element in matrix A row i by every element in matrix B column j. This is simply a three nested loops. 2. At the end of the program, please print the execution time - time taken to calculate the matrix multiplication - not including initialisation of matrices or writing results to file. 3. Once you have completed and tested the program, please review your code and develop a roadmap to parallelise your code. You should start with decomposition of the program/problem into sub-tasks - i.e. partioning data/tasks. Document your list of sub-tasks or activities you plan to do in parallel vs activities that need to be in sequence. 4. Implement your parallel algorithm in C or C++ using pthread library. 5. Evaluate the performance of your program (using execution time as a metric), to assess the speed up achieved. Reflect on different sizes of the input matrices and also number of threads you used in your program - vary from 2 to MAX number of threads. Compare the results with the sequential program. 6. Modify your sequential program to use OpenMP to achieve parallelism 1/2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 Simple Matrix Multiplication Program in C cpp include include include include const int N 1000 size of matrices int main Initialize matrices stdrandomdevice rd stdmt19937 genrd stduniformrealdistrib... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!