SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Abstract ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
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: ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
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. ,[object Object],[object Object],[object Object]
* 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
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Parent process Child process 1 Child process 2 Child process 3 Child process 4  Child process p Fork  Fork  Fork  Fork  Fork
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],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.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
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

Weitere ähnliche Inhalte

Was ist angesagt?

15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and boundAbhishek Singh
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplicationKumar
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design MAHASREEM
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design PresentationKawsar Ahmed
 
Algorithm paradigms
Algorithm paradigmsAlgorithm paradigms
Algorithm paradigmssuresh5c2
 
03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic AnalysisAndres Mendez-Vazquez
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysisjayavignesh86
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesFahim Ferdous
 
Longest common subsequence
Longest common subsequenceLongest common subsequence
Longest common subsequenceKiran K
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 

Was ist angesagt? (20)

15 puzzle problem using branch and bound
15 puzzle problem using branch and bound15 puzzle problem using branch and bound
15 puzzle problem using branch and bound
 
BNF & EBNF
BNF & EBNFBNF & EBNF
BNF & EBNF
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
 
Algorithm paradigms
Algorithm paradigmsAlgorithm paradigms
Algorithm paradigms
 
03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis03 Analysis of Algorithms: Probabilistic Analysis
03 Analysis of Algorithms: Probabilistic Analysis
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysis
 
Time and Space Complexity
Time and Space ComplexityTime and Space Complexity
Time and Space Complexity
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Longest common subsequence
Longest common subsequenceLongest common subsequence
Longest common subsequence
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
8 queen problem
8 queen problem8 queen problem
8 queen problem
 
A greedy algorithms
A greedy algorithmsA greedy algorithms
A greedy algorithms
 

Ähnlich wie Matrix Multiplication(An example of concurrent programming)

dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)Mumtaz Ali
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
Ayush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptxAyush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptxAmanChoudhary329978
 
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfCS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfOpenWorld6
 
Introduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptxIntroduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptxPJS KUMAR
 
Dynamic programming1
Dynamic programming1Dynamic programming1
Dynamic programming1debolina13
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaAlgorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaPriyanka Rana
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematicalbabuk110
 
Gauss Elimination (without pivot).pptx
Gauss Elimination (without pivot).pptxGauss Elimination (without pivot).pptx
Gauss Elimination (without pivot).pptxSaloni Singhal
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationGeoffrey Fox
 
IRJET- Solving Quadratic Equations using C++ Application Program
IRJET-  	  Solving Quadratic Equations using C++ Application ProgramIRJET-  	  Solving Quadratic Equations using C++ Application Program
IRJET- Solving Quadratic Equations using C++ Application ProgramIRJET Journal
 

Ähnlich wie Matrix Multiplication(An example of concurrent programming) (20)

dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
Daa chapter 3
Daa chapter 3Daa chapter 3
Daa chapter 3
 
Ayush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptxAyush Jajoo(MCA2501622) AOA .pptx
Ayush Jajoo(MCA2501622) AOA .pptx
 
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdfCS345-Algorithms-II-Lecture-1-CS345-2016.pdf
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
 
Introduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptxIntroduction to data structures and complexity.pptx
Introduction to data structures and complexity.pptx
 
Lecture 7.pptx
Lecture 7.pptxLecture 7.pptx
Lecture 7.pptx
 
Dynamic programming1
Dynamic programming1Dynamic programming1
Dynamic programming1
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaAlgorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
 
algorithm Unit 2
algorithm Unit 2 algorithm Unit 2
algorithm Unit 2
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
 
Gauss Elimination (without pivot).pptx
Gauss Elimination (without pivot).pptxGauss Elimination (without pivot).pptx
Gauss Elimination (without pivot).pptx
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel application
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
IRJET- Solving Quadratic Equations using C++ Application Program
IRJET-  	  Solving Quadratic Equations using C++ Application ProgramIRJET-  	  Solving Quadratic Equations using C++ Application Program
IRJET- Solving Quadratic Equations using C++ Application Program
 
Unit 2
Unit 2Unit 2
Unit 2
 

Kürzlich hochgeladen

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Matrix Multiplication(An example of concurrent programming)

  • 1.
  • 2.
  • 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.
  • 7.
  • 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.
  • 17. Parent process Child process 1 Child process 2 Child process 3 Child process 4 Child process p Fork Fork Fork Fork Fork
  • 18.
  • 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.
  • 22.
  • 23.
  • 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