Question: Write a code in C using OpenMP and parallel programming to compute matrix multiplication: C=B*A where A, B, and C are matrices and * is
Write a code in C using OpenMP and parallel programming to compute matrix multiplication: C=B*A where A, B, and C are matrices and * is matrix multiplication. You may assume the matrices are all square with N rows and N columns. The method to use would be static mapping which the details are listed below:
For Static mapping: Assume there are K threads performing the computation. In this approach, each thread is statically assigned a set of rows of the result matrix C for which it is responsible for computing results. Specifically, thread 0 is responsible for computing values for rows 0, K, 2K, of C. Thread 1 computes values for rows 1, K+1, 2K+1, In other words, the rows of the matrix are assigned in round robin fashion to the different threads.
Lastly, print out the performance of this code, i.e., the execution time. Define a small matrix as one with 50 rows and 50 columns. Define a large matrix by setting the number of rows and columns (N) to a value where the execution of the sequential code is, say approximately 10 or 20 seconds. Your code should fill the matrix with random numbers in the interval [0.0, 1.0]. All values should be double precision floating point numbers.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
