Question: Write a C program that perform the dot product of two matrices, A x B= C. The first one is 2 3 and the
Write a C program that perform the dot product of two matrices, A x B= C. The first one is 2 3 and the second one is 3 x 2. The result will be stored in a file. [an [a11 a12 a13] La21 a22 a23- columns-3 rows-2 1 2 3 456 = [b11 b12 xb21 b22 = b13 b23 1. Write the program as serial program. Compute the serial time, ts, to find the output and then print the result. 2. Write the program as multi thread program. You need to create 4 threads. Each thread will calculate a one item of the result. Matrix A and B are shared resources between all threads. You can pass the row and the column of the task. Also compute the total time, tp, to obtain the result. For example, First matrix thread 0 will calculate the first item C1 = a11b11 + a12b12 + a13b13 thread 1 will calculate the first item C2 = a11b12 + a12b22 + a13b23 thread 2 will calculate the first item C21 = a21b11 + a22b12 + a23b13 thread 3 will calculate the first item C22=a21b12 + a22b22+ a23b23 X dot product C11 C127 22. LC columns 2 8 10 rows 3 12 Second matrix Y 58 64 139 154 4] Product (1, 2, 3) (7, 8, 9) = 1x7 +2x9 +3*11 = 58 Hint: you may calculate the results based on the thread ID or you may pass row and column to the thread. The A. B and C are shared data. Don't pass this data to the thread. They should be kept in the memory.
Step by Step Solution
There are 3 Steps involved in it
Heres an example of a C program that performs the dot product of two matrices first as a serial prog... View full answer
Get step-by-step solutions from verified subject matter experts
