SlideShare a Scribd company logo
Abstract Problem definition: Parallel computing is a form of computing which many instructions carried out on the principle that large problems can almost always be divided into smaller ones, which may be carried out concurrently ("in parallel").  Principles of  Parallel Algorithm Design Identifying concurrent tasks   Mapping tasks onto multiple processes Distributing input, output, intermediate data Managing access to shared data Synchronizing processors   In this section we are going to see how to multiply two matrixes by using parallel programming in a unique and efficient way. There are many different way to carry out matrix multiplication by using parallel computing.
In this section we are going to see how to multiply two matrixes by using parallel programming in a unique and efficient way. There are many different way to carry out matrix multiplication by using parallel computing. Previous approach: By creating thread for each computation, Cannon’s algorithm, strassen’s multiplication .  But we all know that strassen’s multiplication is quite difficult to implement and it is more restrictive also.  Proposed Approach:  There are two different approaches to compute matrix multiplication: By dividing matrix in the as many no. of process as required and solving all of them concurrently. This algorithm works well for all the value of size n.  By dividing the matrix in terms of matrix of small size using recursion and solving the terminating condition of recursion by using strassen’s multiplication. This algorithm also works well for all the value of size n.   
General introduction Basic Matrix Multiplication Suppose we want to multiply two matrices of size  N  x  N : for example  A  x  B = C . C 11  = a 11 b 11  + a 12 b 21   C 12  = a 11 b 12  + a 12 b 22   C 21  = a 21 b 11  + a 22 b 21   C 22  = a 21 b 12  + a 22 b 22 2x2 matrix multiplication can be accomplished in  8 multiplication. (2 log 2 8  =2 3 )
Time analysis   Strassens’s Matrix Multiplication   P 1  = (A 11 + A 22 )(B 11 +B 22 )  P 2  = (A 21  + A 22 ) * B 11   P 3  = A 11  * (B 12  - B 22 )  P 4  = A 22  * (B 21  - B 11 )  P 5  = (A 11  + A 12 ) * B 22   P 6  = (A 21  - A 11 ) * (B 11  + B 12 )  P 7  = (A 12  - A 22 ) * (B 21  + B 22 )
C 11  = P 1  + P 4  - P 5  + P 7 C 12  = P 3  + P 5   C 21  = P 2  + P 4   C 22  = P 1  + P 3  - P 2  + P 6   Time analysis
Proposed approach 1: Matrix multiplication by using recursion to divide the problem in terms of sub problems and solving the terminating condition of recursion by using  Strassens’s Matrix Multiplication.  Steps involved in this approach are: Step 1.  Divide the matrix in  4  different parts by using divide and concur technique. Step  2 .  Multiply  each part by using recursion . Step   3 .  S olve the terminating condition of the recursion  by using  Strassens’s Matrix Multiplication. Divide-and-Conquer  Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data  S  in two or more disjoint subsets  S 1 , S 2 , … Recur: solve the subproblems recursively Conquer: combine the solutions for  S 1 ,   S 2 , …, into a solution for  S The base case for the recursion are subproblems of constant size Analysis can be done using  recurrence equations
ALGORITHM  Matmul(A[n]n],B[n][n],C[n][n]) //The algorithm implements matrix multiplication by dividing matrix in to sub matrix A0,A1,A2,A3…. B0,B1,B2,B3…. And multiplying each of them recursively. //Input: Two matrixes A and B of dimension n  //Output: A matrix  C of dimension n  if (n==2) Multiply the two input matrix by using  Strassens’s Matrix else Divide the matrix in the  sub matrix of dimension n/2  and solve recursively. Divide matrices into sub-matrices: A 0  , A 1 , A 2  etc  Use blocked matrix multiply equations Recursively multiply sub-matrices
* Consider Multiplication of 4x4 matrix: A11 A12 A13 A14 A21 A22 A23 A24 A31 A32 A33 A34 A41 A42 A43 A44 B11 B12 B13 B14 B21 B22 B23 B24 B31 B32 B33 B34 B41 B42 B43 B44 C11 C12 C13 C14 C21 C22 C23 C24 C31 C32 C33 C34 C41 C42 C43 C44
 = The sub matrix of size 2x2 can be computed as follows: Now c11 ,c12, c21,c22 can be computed as follows: C 11  = P 1  + P 4  - P 5  + P 7 C 12  = P 3  + P 5   C 21  = P 2  + P 4   C 22  = P 1  + P 3  - P 2  + P 6   P 1  = (A 11 + A 22 )(B 11 +B 22 )  P 2  = (A 21  + A 22 ) * B 11   P 3  = A 11  * (B 12  - B 22 )  P 4  = A 22  * (B 21  - B 11 )  P 5  = (A 11  + A 12 ) * B 22   P 6  = (A 21  - A 11 ) * (B 11  + B 12 )  P 7  = (A 12  - A 22 ) * (B 21  + B 22 )  A11 A12 A21 A22 B11 B12 B21 B22 C11 C12 C21 C22
In similar way we can calculate all the multiplications. And same steps we can perform on any dimension of matrix. Results : Input  Size(n) No.  of multiplication In sequential algo. No. of multiplication In the implemented algo. No. of multiplication In  Strassen’s 2 8 7 7 4 64 56 49 8 512 448 343 16 4096 3584 2401 . . . . . . . . p p 3 (7/8)*p 3 n 2.807
Applying above algorithm when size is not in the power of 2 Steps required is as follows Step 1) Make the size to nearest power of  2 Step 2) Make the value of all extra rows to be zero Step 3) Make the value of all extra columns to be zero Step 4) Then apply above algorithm Suppose the dimension of given matrix is 3 then Nearest of 3 is 4 which is power of  2  Hence matrix becomes A11 A12 A13 0 A21 A22 A23 0 A31 A32 A33 0 0 0 0 0
Efficiency calculation: Time analysis : If the value of dimension is not in the power of 2 then first make it  to the nearest power of 2 then start proceeding…… T(2)=7  ( from base condition of strassen’s multiplication) T(N)= (7/8)*N 3 Hence total no. of multiplication required is =  (7 * n 3 )/8 Which is less then (n 3 ).
Proposed Approach 2: Matrix multiplication by creating process for each computation is as follows: A matrix can be divided in to number of parts and each part can be multiply by creating a separate process.  A new process can be created by using fork  ()  system call. Different steps involved in this approach are Step 1 : Partitioning a) Divide matrices into rows b) Each primitive task has corresponding rows of three matrices  Step 2 : Communication a) Each task must eventually see every row of B b) Organize tasks into a ring Step 3: Agglomeration and mapping a) Fixed number of tasks, each requiring same amount of computation b) Regular communication among tasks c) Strategy: Assign each process a contiguous group of rows
Examples: Let in the first case total no. of process to be created is equal to total no. of rows in the matrix i.e. total no. of process = n where n is the dimension of matrix. Task1 Task2 Task3 Task4 A11 A12 A13 A14 A21 A22 A23 A24 A31 A32 A33 A34 A41 A42 A43 A44
Let in the second case total no. of process to be created is n/2. Task1 Task2 Task3 Task4
Process creation In parallel program,  main program  becomes the first program main program consists of  general statements such as assignments, loops, conditionals, I/O statements and  a special statement :  process creation  statements FORALL parallel process creation statement a parallel form of a FOR loop in which all the loop iterations are executed in parallel rather than sequentially each iteration (block) is executed in a separate process
Parent process Child process 1 Child process 2 Child process 3 Child process 4  Child process p Fork  Fork  Fork  Fork  Fork
for (i = d; i < n; i += p)  for (j = 0; j < n; ++j) for (k = 0; k < n; ++k)  c[i][j] += a[i][k] * b[k][j]; for (i = d; i < n; i += p)  for (j = 0; j < n; ++j) for (k = 0; k < n; ++k)  c[i][j] += a[i][k] * b[k][j]; for (i = d; i < n; i += p)  for (j = 0; j < n; ++j) for (k = 0; k < n; ++k)  c[i][j] += a[i][k] * b[k][j]; Parent process BEGIN … FORALL  i:=1 TO p DO pid=fork()… if(pid==0) call child process END. Child process1 Child process 2 Child process p ...
Prototype for process creation: Prototype for process control: #include <sys/types.h> #include <unistd.h> pid_t fork(void); Returns: 0 in child, process ID of child in parent, -1 on error.  #include <sys/wait.h> pid_t wait(int * status_p );  pid_t waitpid(pid_t  child _ pid , int * status _ p , int  options );  Returns: process ID if OK, 0 (for some variations of wait), -1 on error .
Efficiency: In the first case since we are creating a new process to multiply a row of 1 st  matrix to all columns of 2 nd  matrix. And same operation is performing for all row of 1 st  matrix. Hence we are achieving concurrent programming. Hence efficiency increases much more. In the second case we are creating a new process to multiply two rows of 1 st  matrix to all columns of 2 nd  matrix one by one. And same operation is performing for all sets of 2 rows. Hence here also we are achieving concurrent programming. Hence efficiency increases rapidly.
CONCLUSION We know that strassen’s matrix multiplication has much more higher efficiency then the approach, but implementing strassen’s is quite difficult. There is several advantage of implementing the divide and concur method  for matrix multiplication Its efficiency class is lies in between sequential matrix multiplication and strassen’s matrix multiplication. 2) We can use this method to multiply two matrix of any size but  in the case of  strassen’s we can multiply two matrix of size in the  power of 2 only. 3) It is quite simple and more understandable.
There is several advantage of implementing matrix multiplication by using process creation for each calculation. By creating process for each calculation, it’s a simple way to implement concurrent programming. 2) It may be much more faster then all algorithm 3) Data concurrency is much more control fashion so no need to apply concurrency control algorithm for data control. 4) Dividing the problem in terms of sub problem of smaller size and assigning to different process is also simple. 5) This algorithm performs with equal efficiency for all dimensions of the matrix.
LIMITATIONS Implementation of matrix multiplication by divide and concur is applicable to multiply two square matrix only i.e. it is possible to multiply (n*n) matrix. It’s not possible to multiply two matrix of dimension (m*n).      In the Implementation of matrix multiplication by  process creation  we require an algorithm which control the process.   FUTHER ENHANCEMENTS Make both implementation applicable for the matrix of dimension (m*n). 2) Need  an process control algorithm. 3) Make the multiplication faster then implemented above.
BIBLIOGRAPHY  1)Unix system programming using c++ - Terrence Chan 2) Introduction to the design & analysis of algorithms –  Anany Levitin 3) The C Programming Language  - Brian W.Kernighan && Dennnis M.Ritchie, 2 nd  edition
THANK YOU Presented By –PRAMIT KUMAR

More Related Content

PDF
Hidden Markov Models
PDF
Wiener Filter
PPTX
Flowshop scheduling
PPTX
Markov Chain and its Analysis
PDF
Lu decomposition
PPTX
Markov chain
PPTX
Properties of Fourier transform
PPT
Bayseian decision theory
Hidden Markov Models
Wiener Filter
Flowshop scheduling
Markov Chain and its Analysis
Lu decomposition
Markov chain
Properties of Fourier transform
Bayseian decision theory

What's hot (20)

PPTX
Markov chain-model
PPT
Longest Common Subsequence
PPT
Markov analysis
PDF
Singular Value Decompostion (SVD)
PPTX
MATRICES
PPTX
Transportation Problem
PDF
Quadratic programming (Tool of optimization)
PPT
Graph colouring
PDF
Lesson 11: Markov Chains
PDF
Multivariate decision tree
PPTX
Fuzzy sets
PPTX
Tsp branch and-bound
PPT
markov chain.ppt
PPTX
Classical Sets & fuzzy sets
PDF
Lecture 14 Properties of Fourier Transform for 2D Signal
PPT
Properties of relations
PPTX
Block Truncation Coding
PDF
P1 . norm vector space
Markov chain-model
Longest Common Subsequence
Markov analysis
Singular Value Decompostion (SVD)
MATRICES
Transportation Problem
Quadratic programming (Tool of optimization)
Graph colouring
Lesson 11: Markov Chains
Multivariate decision tree
Fuzzy sets
Tsp branch and-bound
markov chain.ppt
Classical Sets & fuzzy sets
Lecture 14 Properties of Fourier Transform for 2D Signal
Properties of relations
Block Truncation Coding
P1 . norm vector space
Ad

Similar to Matrix Multiplication(An example of concurrent programming) (20)

PDF
Introduction to Greedy method, 0/1 Knapsack problem
PPTX
dynamic programming complete by Mumtaz Ali (03154103173)
PPTX
01 - DAA - PPT.pptx
PDF
Daa chapter 2
PPT
3-Chapter Three - Divide and Conquer.ppt
DOCX
B61301007 matlab documentation
PPT
dynamic programming Rod cutting class
PDF
Daa chapter 3
PPTX
Ayush Jajoo(MCA2501622) AOA .pptx
PPTX
ADA_Module 2_MN.pptx Analysis and Design of Algorithms
PDF
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
PPTX
Introduction to data structures and complexity.pptx
PPTX
Lecture 7.pptx
PPTX
Dynamic programming1
PPT
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
DOC
Unit 2 in daa
DOC
algorithm Unit 2
PDF
Data Structure & Algorithms - Mathematical
PPTX
Gauss Elimination (without pivot).pptx
PPT
daa_unit THIS IS GNDFJG SDGSGS SFDF .ppt
Introduction to Greedy method, 0/1 Knapsack problem
dynamic programming complete by Mumtaz Ali (03154103173)
01 - DAA - PPT.pptx
Daa chapter 2
3-Chapter Three - Divide and Conquer.ppt
B61301007 matlab documentation
dynamic programming Rod cutting class
Daa chapter 3
Ayush Jajoo(MCA2501622) AOA .pptx
ADA_Module 2_MN.pptx Analysis and Design of Algorithms
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
Introduction to data structures and complexity.pptx
Lecture 7.pptx
Dynamic programming1
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Unit 2 in daa
algorithm Unit 2
Data Structure & Algorithms - Mathematical
Gauss Elimination (without pivot).pptx
daa_unit THIS IS GNDFJG SDGSGS SFDF .ppt
Ad

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Approach and Philosophy of On baking technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MIND Revenue Release Quarter 2 2025 Press Release
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Unlocking AI with Model Context Protocol (MCP)
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Programs and apps: productivity, graphics, security and other tools
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Approach and Philosophy of On baking technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

Matrix Multiplication(An example of concurrent programming)

  • 1. Abstract Problem definition: Parallel computing is a form of computing which many instructions carried out on the principle that large problems can almost always be divided into smaller ones, which may be carried out concurrently (&quot;in parallel&quot;). Principles of Parallel Algorithm Design Identifying concurrent tasks Mapping tasks onto multiple processes Distributing input, output, intermediate data Managing access to shared data Synchronizing processors In this section we are going to see how to multiply two matrixes by using parallel programming in a unique and efficient way. There are many different way to carry out matrix multiplication by using parallel computing.
  • 2. In this section we are going to see how to multiply two matrixes by using parallel programming in a unique and efficient way. There are many different way to carry out matrix multiplication by using parallel computing. Previous approach: By creating thread for each computation, Cannon’s algorithm, strassen’s multiplication . But we all know that strassen’s multiplication is quite difficult to implement and it is more restrictive also. Proposed Approach: There are two different approaches to compute matrix multiplication: By dividing matrix in the as many no. of process as required and solving all of them concurrently. This algorithm works well for all the value of size n. By dividing the matrix in terms of matrix of small size using recursion and solving the terminating condition of recursion by using strassen’s multiplication. This algorithm also works well for all the value of size n.  
  • 3. General introduction Basic Matrix Multiplication Suppose we want to multiply two matrices of size N x N : for example A x B = C . C 11 = a 11 b 11 + a 12 b 21 C 12 = a 11 b 12 + a 12 b 22 C 21 = a 21 b 11 + a 22 b 21 C 22 = a 21 b 12 + a 22 b 22 2x2 matrix multiplication can be accomplished in 8 multiplication. (2 log 2 8 =2 3 )
  • 4. Time analysis Strassens’s Matrix Multiplication P 1 = (A 11 + A 22 )(B 11 +B 22 ) P 2 = (A 21 + A 22 ) * B 11 P 3 = A 11 * (B 12 - B 22 ) P 4 = A 22 * (B 21 - B 11 ) P 5 = (A 11 + A 12 ) * B 22 P 6 = (A 21 - A 11 ) * (B 11 + B 12 ) P 7 = (A 12 - A 22 ) * (B 21 + B 22 )
  • 5. C 11 = P 1 + P 4 - P 5 + P 7 C 12 = P 3 + P 5 C 21 = P 2 + P 4 C 22 = P 1 + P 3 - P 2 + P 6 Time analysis
  • 6. Proposed approach 1: Matrix multiplication by using recursion to divide the problem in terms of sub problems and solving the terminating condition of recursion by using Strassens’s Matrix Multiplication. Steps involved in this approach are: Step 1. Divide the matrix in 4 different parts by using divide and concur technique. Step 2 . Multiply each part by using recursion . Step 3 . S olve the terminating condition of the recursion by using Strassens’s Matrix Multiplication. Divide-and-Conquer Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data S in two or more disjoint subsets S 1 , S 2 , … Recur: solve the subproblems recursively Conquer: combine the solutions for S 1 , S 2 , …, into a solution for S The base case for the recursion are subproblems of constant size Analysis can be done using recurrence equations
  • 7. ALGORITHM Matmul(A[n]n],B[n][n],C[n][n]) //The algorithm implements matrix multiplication by dividing matrix in to sub matrix A0,A1,A2,A3…. B0,B1,B2,B3…. And multiplying each of them recursively. //Input: Two matrixes A and B of dimension n //Output: A matrix C of dimension n if (n==2) Multiply the two input matrix by using Strassens’s Matrix else Divide the matrix in the sub matrix of dimension n/2 and solve recursively. Divide matrices into sub-matrices: A 0 , A 1 , A 2 etc Use blocked matrix multiply equations Recursively multiply sub-matrices
  • 8. * Consider Multiplication of 4x4 matrix: A11 A12 A13 A14 A21 A22 A23 A24 A31 A32 A33 A34 A41 A42 A43 A44 B11 B12 B13 B14 B21 B22 B23 B24 B31 B32 B33 B34 B41 B42 B43 B44 C11 C12 C13 C14 C21 C22 C23 C24 C31 C32 C33 C34 C41 C42 C43 C44
  • 9.  = The sub matrix of size 2x2 can be computed as follows: Now c11 ,c12, c21,c22 can be computed as follows: C 11 = P 1 + P 4 - P 5 + P 7 C 12 = P 3 + P 5 C 21 = P 2 + P 4 C 22 = P 1 + P 3 - P 2 + P 6 P 1 = (A 11 + A 22 )(B 11 +B 22 ) P 2 = (A 21 + A 22 ) * B 11 P 3 = A 11 * (B 12 - B 22 ) P 4 = A 22 * (B 21 - B 11 ) P 5 = (A 11 + A 12 ) * B 22 P 6 = (A 21 - A 11 ) * (B 11 + B 12 ) P 7 = (A 12 - A 22 ) * (B 21 + B 22 ) A11 A12 A21 A22 B11 B12 B21 B22 C11 C12 C21 C22
  • 10. In similar way we can calculate all the multiplications. And same steps we can perform on any dimension of matrix. Results : Input Size(n) No. of multiplication In sequential algo. No. of multiplication In the implemented algo. No. of multiplication In Strassen’s 2 8 7 7 4 64 56 49 8 512 448 343 16 4096 3584 2401 . . . . . . . . p p 3 (7/8)*p 3 n 2.807
  • 11. Applying above algorithm when size is not in the power of 2 Steps required is as follows Step 1) Make the size to nearest power of 2 Step 2) Make the value of all extra rows to be zero Step 3) Make the value of all extra columns to be zero Step 4) Then apply above algorithm Suppose the dimension of given matrix is 3 then Nearest of 3 is 4 which is power of 2 Hence matrix becomes A11 A12 A13 0 A21 A22 A23 0 A31 A32 A33 0 0 0 0 0
  • 12. Efficiency calculation: Time analysis : If the value of dimension is not in the power of 2 then first make it to the nearest power of 2 then start proceeding…… T(2)=7 ( from base condition of strassen’s multiplication) T(N)= (7/8)*N 3 Hence total no. of multiplication required is = (7 * n 3 )/8 Which is less then (n 3 ).
  • 13. Proposed Approach 2: Matrix multiplication by creating process for each computation is as follows: A matrix can be divided in to number of parts and each part can be multiply by creating a separate process. A new process can be created by using fork () system call. Different steps involved in this approach are Step 1 : Partitioning a) Divide matrices into rows b) Each primitive task has corresponding rows of three matrices Step 2 : Communication a) Each task must eventually see every row of B b) Organize tasks into a ring Step 3: Agglomeration and mapping a) Fixed number of tasks, each requiring same amount of computation b) Regular communication among tasks c) Strategy: Assign each process a contiguous group of rows
  • 14. Examples: Let in the first case total no. of process to be created is equal to total no. of rows in the matrix i.e. total no. of process = n where n is the dimension of matrix. Task1 Task2 Task3 Task4 A11 A12 A13 A14 A21 A22 A23 A24 A31 A32 A33 A34 A41 A42 A43 A44
  • 15. Let in the second case total no. of process to be created is n/2. Task1 Task2 Task3 Task4
  • 16. Process creation In parallel program, main program becomes the first program main program consists of general statements such as assignments, loops, conditionals, I/O statements and a special statement : process creation statements FORALL parallel process creation statement a parallel form of a FOR loop in which all the loop iterations are executed in parallel rather than sequentially each iteration (block) is executed in a separate process
  • 17. Parent process Child process 1 Child process 2 Child process 3 Child process 4 Child process p Fork Fork Fork Fork Fork
  • 18. for (i = d; i < n; i += p) for (j = 0; j < n; ++j) for (k = 0; k < n; ++k) c[i][j] += a[i][k] * b[k][j]; for (i = d; i < n; i += p) for (j = 0; j < n; ++j) for (k = 0; k < n; ++k) c[i][j] += a[i][k] * b[k][j]; for (i = d; i < n; i += p) for (j = 0; j < n; ++j) for (k = 0; k < n; ++k) c[i][j] += a[i][k] * b[k][j]; Parent process BEGIN … FORALL i:=1 TO p DO pid=fork()… if(pid==0) call child process END. Child process1 Child process 2 Child process p ...
  • 19. Prototype for process creation: Prototype for process control: #include <sys/types.h> #include <unistd.h> pid_t fork(void); Returns: 0 in child, process ID of child in parent, -1 on error. #include <sys/wait.h> pid_t wait(int * status_p ); pid_t waitpid(pid_t child _ pid , int * status _ p , int options ); Returns: process ID if OK, 0 (for some variations of wait), -1 on error .
  • 20. Efficiency: In the first case since we are creating a new process to multiply a row of 1 st matrix to all columns of 2 nd matrix. And same operation is performing for all row of 1 st matrix. Hence we are achieving concurrent programming. Hence efficiency increases much more. In the second case we are creating a new process to multiply two rows of 1 st matrix to all columns of 2 nd matrix one by one. And same operation is performing for all sets of 2 rows. Hence here also we are achieving concurrent programming. Hence efficiency increases rapidly.
  • 21. CONCLUSION We know that strassen’s matrix multiplication has much more higher efficiency then the approach, but implementing strassen’s is quite difficult. There is several advantage of implementing the divide and concur method for matrix multiplication Its efficiency class is lies in between sequential matrix multiplication and strassen’s matrix multiplication. 2) We can use this method to multiply two matrix of any size but in the case of strassen’s we can multiply two matrix of size in the power of 2 only. 3) It is quite simple and more understandable.
  • 22. There is several advantage of implementing matrix multiplication by using process creation for each calculation. By creating process for each calculation, it’s a simple way to implement concurrent programming. 2) It may be much more faster then all algorithm 3) Data concurrency is much more control fashion so no need to apply concurrency control algorithm for data control. 4) Dividing the problem in terms of sub problem of smaller size and assigning to different process is also simple. 5) This algorithm performs with equal efficiency for all dimensions of the matrix.
  • 23. LIMITATIONS Implementation of matrix multiplication by divide and concur is applicable to multiply two square matrix only i.e. it is possible to multiply (n*n) matrix. It’s not possible to multiply two matrix of dimension (m*n).   In the Implementation of matrix multiplication by process creation we require an algorithm which control the process.   FUTHER ENHANCEMENTS Make both implementation applicable for the matrix of dimension (m*n). 2) Need an process control algorithm. 3) Make the multiplication faster then implemented above.
  • 24. BIBLIOGRAPHY 1)Unix system programming using c++ - Terrence Chan 2) Introduction to the design & analysis of algorithms – Anany Levitin 3) The C Programming Language - Brian W.Kernighan && Dennnis M.Ritchie, 2 nd edition
  • 25. THANK YOU Presented By –PRAMIT KUMAR