Question
Using OpenMP and C Programming, use the concept of parallel programming to compute matrix multiplication. Compute C=B*A where A, B, and C are matrices and
Using OpenMP and C Programming, use the concept of parallel programming to compute matrix multiplication. Compute 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. Two versions should be created, one using static mapping and the other using dynamic mapping.
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.
For Dynamic Mapping: create K threads to perform the computation. Each worker thread repeatedly accesses a global data structure to allocate a single row of the result matrix to compute. It then performs this computation, and then goes back to the global data structure to allocate another piece of work to do. This process continues until the entire matrix computation is complete. It Executes the following loop:
While (rows of the result matrix have not been computed) { Allocate a row of the result matrix to compute Compute results for this row of the result matrix }
Then, compare the performance of each version by comparing the execution times. 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started