In your write-up, produce a graph of speedup compared to the reference sequential implementation as a function of the number of threads used FOR VIEW 1. Is speedup linear in the number of threads used? In your writeup hypothesize why this is (or is not) the case?
(You may also wish to produce a graph for VIEW 2 to help you come up with a good answer. Hint: take a careful look at the three-thread data-point.)
Is speedup linear in the number of threads used?
-> 在 view1 跟 view2 , 我們都可以得到這個結論
In your writeup hypothesize why this is (or is not) the case?
-> 因為我們將每一個 thread 中的任務分配的很平均 , 不會有某一個 thread 執行特別多的工作 , 因此當 thread 數增加時 , 可有效降低整體的執行時間
How do your measurements explain the speedup graph you previously created?
我的測量結果正如我上面測出來的加速結果 , 每一個 thread 分配得很平均
In your write-up, describe your approach to parallelization and report the final 4-thread speedup obtained
方法: 每個 thread 將自己的 threadID 作為要處理的資料的起使位置 ,並根據 threads 的數量分配接下來要處理的的位置
如下所示:
thread 0 : 0 4 8 12 …
thread 1 : 1 5 9 13…
thread 2 : 2 6 10 14…
thread 3 : 3 7 11 15…
這樣的加速約為 3.9倍
Now run your improved code with eight threads. Is performance noticeably greater than when running with four threads? Why or why not?
在我的個人電腦上 , 8 thread 的效能明顯比 4 thread 更好
下圖是在 server 上執行的效能 , 8 thread 的效能甚至比 4 thread 更差
合理的解釋是因為 server 的 CPU 是 4 cores 4 threads ,因此,高於 4 個 threads 我們甚至需要用切換執行緒 , 造成不必要的浪費