Parallel Algorithms: Theory and Practice CS260 –
Author : danika-pritchard | Published Date : 2025-05-12
Description: Parallel Algorithms Theory and Practice CS260 Lecture 3 Yihan Sun Some of the slides are from MIT 6712 6886 and CMU 15853 Last Lecture Two scan algorithms Divideandconquer Reduce the problem size Computational models PRAM
Presentation Embed Code
Download Presentation
Download
Presentation The PPT/PDF document
"Parallel Algorithms: Theory and Practice CS260 –" is the property of its rightful owner.
Permission is granted to download and print the materials on this website for personal, non-commercial use only,
and to display it on your personal computer provided you do not modify the materials and that you retain all
copyright notices contained in the materials. By downloading content from our website, you accept the terms of
this agreement.
Transcript:Parallel Algorithms: Theory and Practice CS260 –:
Parallel Algorithms: Theory and Practice CS260 – Lecture 3 Yihan Sun * Some of the slides are from MIT 6.712, 6.886 and CMU 15-853. Last Lecture Two scan algorithms Divide-and-conquer Reduce the problem size Computational models PRAM Fork-join: N-way vs. binary Atomic primitives Implement parallel algorithms using C++ I’ll ask for your feedback (about) every two lectures, you can be prepared for that 2 In this lecture Matrix multiplication Solve recurrences using Master Theorem Some applications that can be solved in parallel 3 Homework 1 The deadline has been extended to 27th Jan – 5 more days Code submitted to iLearn If you want to use the late days, let me know After this lecture, you’ll be able to solve all the problems in Homework 1 4 Course Website: https://www.cs.ucr.edu/~yihans/teaching/palgo.html Under my UCR homepage Matrix Multiplication 5 Matrix Multiplication Consider standard iterative matrix-multiplication algorithm X Y Z := for i = 1 to N do for j = 1 to N do for k = 1 to N do Z[i][j] += X[i][k] * Y[k][j] Matrix Multiplication 7 for i = 1 to N do for j = 1 to N do for k = 1 to N do Z[i][j] += X[i][k] * Y[k][j] par_for i = 1 to N do par_for j = 1 to N do for k = 1 to N do Z[i][j] += X[i][k] * Y[k][j] par_for i = 1 to N do par_for j = 1 to N do par_for k = 1 to N do temp[k] = X[i][k] * Y[k][j]; Z[i][j] = parallel_reduce(temp, N); Recursive Matrix Multiplication X11 Y11 Z11 := Z12 Z21 Z22 X12 X21 X22 Y21 Y12 Y22 Compute 8 submatrix products recursively Z11 := X11Y11 + X12Y21 Z12 := X11Y12 + X12Y22 Z21 := X21Y11 + X22Y21 Z22 := X21Y12 + X22Y21 Matrix Multiplication 9 How to solve a recurrence in general? 10 Solving recurrences – Master Theorem 11 12 … … … … 13 … … 14 … … 15 … 16 … … … You can always analyze a specific algorithm using the tree … Master Theorem 17 Matrix multiplication 18 Master Theorem Quiz 19 Use recurrence to compute work and depth 20 S1; S2; In parallel: S1; S2; Case 1: S = execute S2 after finishing S1 Case 2: S = execute S2 and S1 in parallel Flatten algorithm 21 Flatten Algorithm 22 Flatten algorithm 23 Flatten(A, n) {