1. Implement a simple matrix multiplication program in C or C++. Matrix multiplication of C =...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
In problem 3.1 at the end of Chapter 3, you calculated measures of central tendency for six variables for freshman and seniors. Three of those variables are reproduced here. Calculate the mean (if...
-
In problem 3.5 at the end of Chapter 3, you calculated measures of central tendency for four variables for 15 respondents. Two of those variables are reproduced here. Calculate the mean (if...
-
At the end of the month, you have only $10 left in your checking account. You deposit your $200 paycheck from your part-time waitressing job, but the restaurant is not doing well and your paycheck...
-
Hemming Co. reported the following current year purchases and sales for its only product. Required Hemming uses a perpetual inventory system. Determine the costs assigned to ending inventory and to...
-
You have been assigned the responsibility of developing a purchasing module for a retail company. Required Identify the tables that you think would be necessary as part of a relational database that...
-
Describe the concept of persistent memory and how it differs from traditional volatile memory. What are the implications of persistent memory for system crash recovery, data consistency, and...
-
As shown in V9.25 and Fig. P9.105, a spoiler (i.e., an upside-down airfoil) is mounted above the rear wheels of a race car to produce negative lift (i.e., downforce), thereby improving tractive...
-
The Earth Group carries on business as a distributor of warehouse equipment and importer of fruits into the country. Earth was incorporated in 2011 to distribute warehouse equipment. It diversified...
-
Your health facility, the Lakeland Medical Clinic was opened to serve area residents. The first two months of operation saw strong patient volume after which the numbers dropped off dramatically....
-
Cardinal Company is considering a five-year project that would require a $2,975,000 investment in equipment with a useful life of five years and no salvage value . The company's discount rate is 14%....
-
11:42 Tittarpur potage & LIND/Orte above urugram. In your group, you will need to submit the following for the above-given ER diagram: 1. The given ER diagram has M:N relationship. Resolve the M:N...
-
Solve the following Volterra Integral Equations using 1. Laplace transform 2. Variational Iterationl Method a) Volterra integral equation with weakly singular kernel u(x)=x+1+ xt-1 u(t)dt the exact...
-
The table below gives the distances in kilometres between seven localities, A, B, C, D, E, F, G. Find a minimum weight spanning tree joining these localities and give its weight. A B C D EFG A B C D...
-
Alter Company Ltd. and Bounder Company Ltd. manufacture the same product, each under their own brand name. Alter Company Ltd.'s product represents 20% of the domestic market, and Bounder Company...
-
James Johnson is a sole practitioner. His office is about an hour's drive from the federal district's court at which he files many lawsuits. He used to talk on his cell phone to clients as he...
-
Annie was a cyber security expert and had her own consulting business. Super Nice Co was one of Annie's regular clients. Shortly after entering into a contract with Super Nice Co. to provide advice...
-
Let f(x) = 5x 2, (x) = 5x 3x 2, (x) = 10x + 3x + 5, and 4(x) = 4x 8. Suppose a f(x) + b2(x) + c3(x) + d(x) = 0. Differentiate to produce another equation that is satisfied by a, b, c, d....
-
The test statistic in the NeymanPearson Lemma and the likelihood ratio test statistic K are intimately related. Consider testing H 0 : = 0 versus H a : = a , and let * denote the test statistic...
-
Professors Skelton and Baron are concerned that at the start of case 1 of RB-DELETE-FIXUP, the node x.p might not be black. If the professors are correct, then lines 5-6 are wrong. Show that x.p must...
-
How many people should be invited to a party in order to make it likely that there are three people with the same birthday?
-
Illustrate the operation of HEAP-EXTRACT-MAX on the heap A = 15, 13, 9, 5, 12, 8, 7, 4, 0, 6, 2, 1.
-
Describe what sexual harassment is and what forms it can take.
-
Explain public policies that protect employees from unlawful discharge.
-
Discuss under what conditions unemployment compensation can be denied to a claimant.
Study smarter with the SolutionInn App