(Part b)
By:
Shahrzad Abedi
Professor: Dr. Haj Seyed Javadi
MATRIX Multiplication
• SIMD
• MIMD
– Multiprocessors
– Multicomputers
Chapter 7: Matrix Multiplication , Parallel Computing :Theory and Practice, Michael J. Quinn
2
Matrix Multiplication Algorithms for Multiprocessors p1 p2 p3 p4 p1 p2
Chapter 7: Matrix Multiplication , Parallel Computing :Theory and Practice, Michael J. Quinn
p3
p4
3
Matrix Multiplication Algorithm for a UMA Multiprocessor
p1 p2 p3 p4 Chapter 7: Matrix Multiplication , Parallel Computing :Theory and Practice, Michael J. Quinn
4
Matrix Multiplication Algorithm for a UMA Multiprocessor
Example:
n= 8 , P=2
C
n/p= 4
A
B
p1
p2
n/p times
We must read n/p rows of A and we must read every element of B, n/p times
Chapter 7: Matrix Multiplication , Parallel Computing :Theory and Practice, Michael J. Quinn
5
Matrix Multiplication Algorithms for Multiprocessors
• Question : Which Loop should be made parallel in the sequential Matrix multiplication algorithm? • Grain Size :
– Amount of work performed between processor interactions – Ratio of Computation time to Communication
Time : Computation time / Communication time
Chapter 7: Matrix Multiplication , Parallel Computing :Theory and Practice, Michael J. Quinn
6
Sequential Matrix Multiplication
Algorithm
Chapter 7: Matrix Multiplication , Parallel Computing :Theory and Practice, Michael J. Quinn
7
Matrix Multiplication Algorithms for Multiprocessors
• Design Strategy If load balancing is not a problem maximize grain size
• Question : Which Loop should be made parallel ? i or j or k ?
• K has data dependency X
• If j Grain-size = O(n3/np)= O(n2/p)
• If i Grain-size = O(n3/p)
Chapter 7: Matrix Multiplication , Parallel Computing :Theory and Practice, Michael J. Quinn
8
Matrix Multiplication Algorithm for a UMA Multiprocessor