Multithreaded Algorithm 2 Michael Tsai 201116 2 Scheduling

  • Slides: 27
Download presentation
Multi-threaded Algorithm 2 Michael Tsai 2011/1/6

Multi-threaded Algorithm 2 Michael Tsai 2011/1/6

2 Scheduling Scheduler的 作: 把strand指定給processor執行. On-line: scheduler事先並不知道什麼時候strand 會spawn, 或者spawn出來的什麼時候會完成. Centralized scheduler: 單一的scheduler知道整 體狀況並作scheduling (比較容易分析)

2 Scheduling Scheduler的 作: 把strand指定給processor執行. On-line: scheduler事先並不知道什麼時候strand 會spawn, 或者spawn出來的什麼時候會完成. Centralized scheduler: 單一的scheduler知道整 體狀況並作scheduling (比較容易分析) Distributed scheduler: 每個thread互相溝通合作, 找出最好的scheduling方法

3 Greedy scheduler

3 Greedy scheduler

4

4

5 Incomplete step … … …

5 Incomplete step … … …

6

6

7 When is << ?

7 When is << ?

8

8

9

9

10 Back to P-FIB 即使對大平行電腦, 一個普 通的n都可以使我們的程式 達到near perfect linear speedup. (Parallelism比P大很 多 slackness很大)

10 Back to P-FIB 即使對大平行電腦, 一個普 通的n都可以使我們的程式 達到near perfect linear speedup. (Parallelism比P大很 多 slackness很大) P-FIB(n) if n<=1 return n else x=spawn P-FIB(n-1) y=P-FIB(n-2) sync return x+y

11 Parallel Loops Parallel loops: 把loop的iterations平行地執行. 在for關鍵字前面加上 “parallel”. 也可以用spawn和sync, 不過這樣的語法比較方 便.

11 Parallel Loops Parallel loops: 把loop的iterations平行地執行. 在for關鍵字前面加上 “parallel”. 也可以用spawn和sync, 不過這樣的語法比較方 便.

14 y A 1, 4 i = 5, 8 j x

14 y A 1, 4 i = 5, 8 j x

15 Analyze MAT-VEC

15 Analyze MAT-VEC

16 每個internal node都會spawn一次. (spawn overhead為constant) n-1個internal nodes n個leaves leave比internal node多, 因此spawn 的cost可以平均分攤給leave

16 每個internal node都會spawn一次. (spawn overhead為constant) n-1個internal nodes n個leaves leave比internal node多, 因此spawn 的cost可以平均分攤給leave

17 Analyze MAT-VEC

17 Analyze MAT-VEC

19 Determinacy Race Examples Therac-25: 放射線治療機組. 1985 -1987年間造成至少 6個病人受到 原本設定劑量 100倍的輻射, 造成 死亡或嚴重輻射灼傷. 延伸閱讀:

19 Determinacy Race Examples Therac-25: 放射線治療機組. 1985 -1987年間造成至少 6個病人受到 原本設定劑量 100倍的輻射, 造成 死亡或嚴重輻射灼傷. 延伸閱讀: 殺人的軟體. http: //hiraman-sharma. blogspot. com/2010/07/killer-softwares. html

20 Determinacy Race Examples 2003 Northeast Blackout: Affected 10 M people in Ontario &

20 Determinacy Race Examples 2003 Northeast Blackout: Affected 10 M people in Ontario & 45 M people in 8 U. S. states. Cause: A software bug known existed in General Electric Energy's Unix-based XA/21 energy management system

23 Socrates chess-playing program Original version “Optimized version”

23 Socrates chess-playing program Original version “Optimized version”

24 Multithreaded matrix multiplication

24 Multithreaded matrix multiplication

25 Divide-and-conquer Multithreaded Algorithm for Matrix Multiplication (勒勒長) C T

25 Divide-and-conquer Multithreaded Algorithm for Matrix Multiplication (勒勒長) C T

26

26

27 How about Strassen’s method?

27 How about Strassen’s method?