Question: In this assignment you will investigate how multiprocessing in Python can speedup matrix multiplication. Recall if A is an m n matrix and B is
In this assignment you will investigate how multiprocessing in Python can speedup matrix multiplication. Recall if
is an matrix and is an matrix, given by
then the matrix product is the matrix
where each element of is the inner product
cdots
for dots, and dots,
The computational complexity of the classic algorithm is therefore
for range:
for range :
sum
for range:
sum
sum
Based on the
mppy code demonstrated in class, develop a Python code py file using Sublime Text or other
editor to serially multiply two matrices using the classic algorithm and report elapsed runtime. Then implement a
parallel approach using the Python multiprocessing Pool.map facility. Observe each entry is an inner
product that can be computed independently by a separate thread. Report elapsed runtime of your parallel
implementation. Do not include the pool construction in the timing ie do not include time to execute
statement pool mpPoolprocessesthreads
Choose your own values for and Initialize matrices A and with random values using
andom rand
andom. rand
Add an assert statement to verify the serially computed matrix is equal to the parallelly computed matrix.
Finally, answer the question: for what value of does your parallel implementation outperform your
serial?
Code In Python
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
