Parallel Programming Assignment V === ## Q1 What are the pros and cons of the three methods? Give an assumption about their performances. * Method 1 ``` Pros: 資料有大量重複存取或是較多的運算(資料一直保持在GPU Memory裡時 )會有較好的性能。 Cons: 每個 thread 所需處理的計算量不一樣,會發生完成的 thread 等待未完成的 thread。 ``` * Method 2 ``` Pros: 可以自動以最佳的倍數來配置記憶體,從某個固定的倍數位址開始讀取,才會有最高的效率。 Cons: 每個 thread 所需處理的計算量不一樣,會發生完成的 thread 等待未完成的 thread。使用 cudaMallocPitch()分配記憶體為了要對齊,可能會多分配用不到的記憶體空間。 ``` * Method 3 ``` Pros: 每個thread處理多個piexls,會比較不容易有上述方法等待其他thread完成的問題。 Cons: 使用 cudaMallocPitch()分配記憶體為了要對齊,可能會多分配用不到的記憶體空間。 ``` ## Q2 How are the performances of the three methods? Plot a chart to show the differences among the three methods * VIEW 1 ![](https://i.imgur.com/RoZ82hc.png) * VIEW 2 ![](https://i.imgur.com/5V1mOQb.png) ## Q3 Explain the performance differences thoroughly based on your experimental results. Does the results match your assumption? 根據HW2效能的結論,在影像白色處會花較多的時間運算,所有的thread也會等到其他thread都完成了才結束,所以會有thread執行時間不均衡的問題,View1對比View2也更加明顯有此問題。`cudaMallocPitch`分配空間時因為需要記憶體對齊,所以會產生額外的記憶體空間,以至於Method 2、3的效能比Method 1低。 ## Q4 Can we do even better? Think a better approach and explain it. Implement your method in kernel4.cu. 前面的方法都有規定`Note that you are not allowed to use the image input as the host memory directly`,但如果忽略這項規定,就可以省下多餘的記憶體配置、複製以及刪除的時間。