Write a C program that perform the dot product of two matrices, A x B= C....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 C₁1 = a11b11 + a12b12 + a13b13 thread 1 will calculate the first item C₁2 = 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. 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 C₁1 = a11b11 + a12b12 + a13b13 thread 1 will calculate the first item C₁2 = 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.
Expert Answer:
Answer rating: 100% (QA)
Heres an example of a C program that performs the dot product of two matrices first as a serial prog... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these operating system questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Consider the following two algorithms that navely compute the sum and product of two n x n matrices. product(A,B): sum (A,B): for i= [0, n): for j [0, n): for i = [0,n): C[i,j] A[i, j]+ Bli, j] end...
-
Juanita Torres is 35-years old and lately has been working with her financial planner. She is attempting develop a long-term savings and investment program. She has been thinking about all the major...
-
Repeat Problem 998 using constant specific heats at room temperature.
-
Figure shows the response of a system to a step input of magnitude 1000 N. The equation of motion is m + c + kx = f(t) Estimate the values of m, c, and k. 0.04 0.036 0.032 0.028 0.024 E 0.02 0.016...
-
Andrew Reitz established a trust in 2000, naming his sons, James and John, as sole beneficiaries and himself as trustee. Upon Andrews death, Hal Rachal Jr., the attorney who drafted the trust, became...
-
Jefferson Animal Rescue is a private not-for-profit clinic and shelter for abandoned domesticated animals, chiefly dogs and cats. At the end of 2011, the organization had the following account...
-
What sql commands are used in RDBMS? What are the 5 basic SQL queries?
-
Ye Olde Creamery, a popular ice cream store on campus, has one line for its tasty treats. Students arrive at the Creamery about one every minute. Because of the new automated Wave N Pay payment...
-
This is from Central Bank of Turkey's recriutment questions in 2015. Let the production function be: and capital's law of motion is dk dt where s is the saving rate, and d = what s? Y = K/2 =SxY-dx K...
-
ODonnell & Joyce purchases components from three suppliers. Components purchased from Supplier A are priced at 7 each and used at the rate of 18,000 units per month. Components purchased from...
-
Weekly demand for jeans at a Zara store is normally distributed, with a mean of 170 and a standard deviation of 85. The supply plant takes two weeks to supply a Zara order. The store manager monitors...
-
Weekly demand for smartphones at an Apple store is normally distributed, with a mean of 500 and a standard deviation of 300. Foxconn, the assembler, takes four weeks to supply an Apple order. Apple...
-
Reconsider the Best Buy store in Exercise 3. The store manager has decided to follow a periodic review policy to manage inventory of cell phones. She plans to order every three weeks. Given a desired...
-
Motorola obtains cell phones from its contract manufacturer located in China to supply the U.S. market, which is served from a warehouse located in Memphis, Tennessee. Daily demand at the Memphis...
-
Which type of takeover activity is least likely to be successful? O A. Horizontal acquisition O B. Forwards vertical acquisition OC. Conglomerate merger OD. Backwards vertical acquisition O E...
-
Find the radius of convergence of? 1.2.3 1.3.5 (2n-1) r2n+1 -1
-
Find the first ten numbers with 50 decimal digits that are divisible by 2 or 3.
-
Write a program that prompts the user to enter the number of students, the students names, and their scores, and prints student names in decreasing order of their scores.
-
Write a method that returns the sum of all the elements in a specified column in a matrix using the following header:public static double?sumColumn(double[][] m,?int?columnIndex)Write a test program...
-
Determine the equivalent resistance \(R_{\text {eq }}\) for the circuit shown in Figure 6.9. FIGURE 6.9 Problem 2. +O V www R ww R3
-
Determine the equivalent resistance \(R_{\text {eq }}\) for the circuit shown in Figure 6.8. FIGURE 6.8 Problem 1. W R1 ev
-
A potentiometer is a variable resistor with three terminals. Figure 6.12a shows a potentiometer connected to a voltage source. The two end terminals are labeled as 1 and 2, and the adjustable...
Study smarter with the SolutionInn App