Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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