GPU計算入門
with OpenCL
張安邦
注意
•指標!
•手動記憶體管理!!
whoami
• 張安邦
• C++ developer
• 3年OpenCL經驗
• 中山大學宿舍網路推廣會會長
CPU
•一行一行執行
平行計算
• 迴圈內有非常多的計算
• 迴圈要跑很多次
• 寫一次迴圈內的計算
• 不同核心跑不同次迴圈的計算
GPU
•大量核心
•高記憶體頻寬
•幾乎隨手可得
OpenCL
•由多家廠商聯合推出的運算API
•開放標準
•AMD/NVIDIA/Intel/etc...
運作流程
1. ????
2. profit
運作流程
1. 決定要在哪裡執行
2. 透過OpenCL建立執行程式
3. 準備資料
4. run
5. 拿回運算結果
OpenCL C
•跑在GPU上面
•高性能
•特殊關鍵字
開始寫code吧
• C++
•但是你可以用任何語言
查詢有什麼廠商的裝置可以用
找有什麼裝置可以用
載入原始檔並編譯
準備記憶體並分配資料
執行程式
取得結果
BTW
•現在Raspberry Pi也有支援OpenCL
•VC4CL(去GitHub找)
Demo Time
https://github.com/marty1885/OpenC
L-demo-SITCON2018

Editor's Notes

  • #6 It works well untill this happens
  • #7 execute different task on different cores
  • #9 Also introduce WebCL and hanguage bindings here Also the C API
  • #12 介紹OpenCL Platform/Device架構 1. 多Platform(aka 廠商) 2. 一個platform下可能有多個device 3.Device有自己的Memory
  • #13 Memory Model May not explain local memory
  • #14 介紹OpenCL C與各種關鍵字
  • #16 介紹OpenCL Platform/Device架構 1. 多Platform(aka 廠商) 2. 一個platform下可能有多個device 3.Device有自己的Memory
  • #20 Memory Model May not explain local memory