許多新的 CPU 或 VGA 顯示卡,都支援 OpenCL。萬一你只有舊電腦又將如何呢?Linux 社群有人將 PoCL (Portable Computing Language) 納入套件資料庫,讓不想『太早』花錢買硬體、而又想學 OpenCL 程式的使用者可以方便學習。等學好 OpenCL 程式,而真正需要開始運算時,再採購適當的硬體較划算。
一、安裝 PoCL (Portable Computing Language)
由於 PoCL 已經收錄入 Fedora 的套件庫,只要一個命令就可安裝,[root@Atom-N280 ~]# dnf install pocl也會同時安裝 clang clang-libs hwloc-libs llvm ocl-icd opencl-filesystem uthash-devel 這幾個套件,若 LLVM 尚未安裝要補裝的套件更多 binutils clang clang-libs cpp gcc gcc-c++ glibc-devel glibc-headers hwloc-libs isl kernel-headers libasan libatomic libcilkrts libmpc libmpx libstdc++-devel libubsan llvm opencl-filesystem pocl uthash-devel。
三、用 CLInfo 查詢 OpenCL 參數
是否將 OpenCL 程式框架安裝妥當,最方便的方法就是用 CLInfo 來查詢。或由上面的結果可以看出,PoCL 提供的 OpencCL 程式框架在 32-bit Atom 的電腦安裝成功。
[SiB@Atom-N280 ~]# clinfo Number of platforms 1 Platform Name Portable Computing Language Platform Vendor The pocl project Platform Version OpenCL 1.2 pocl 0.12 Platform Profile FULL_PROFILE Platform Extensions cl_khr_icd Platform Extensions function suffix POCL Platform Name Portable Computing Language Number of devices 1 Device Name pthread-Intel(R) Atom CPU N280 @ 1.66GHz Device Vendor GenuineIntel Device Vendor ID 0x8086 Device Version OpenCL 1.2 pocl Driver Version 0.12 Device OpenCL C Version OpenCL C 1.2 Device Type CPU, Default Device Profile FULL_PROFILE Max compute units 2 Max clock frequency 1667MHz · · · · · · Address bits 32, Little-Endian · · · · · · NULL platform behavior clGetPlatformInfo(NULL, ...) Portable Computing Language · · · · · · ICD loader properties ICD loader Name OpenCL ICD Loader ICD loader Vendor OCL Icd free software ICD loader Version 2.2.7 ICD loader Profile OpenCL 1.2
後記:
- 其它 OpenCL 程式框架的安裝,請參考〝OpenCL 程式框架與 CLInfo〞。
已測試版本:
- Fedora: 22, 23
參考資料:
- pocl developers, "Portable Computing Language," [Apr. 7, 2016].
- Fedora Project, "Changes/OpenCL," Jan. 25, 2014 [Aug. 12, 2015].
- Phoronix Media., "The Current Open-Source OpenCL Experience On Fedora," May 15, 2015 [Aug. 12, 2015].
- OpenCLHowTo, "How to set up OpenCL in Linux," Apr. 4, 2015 [Se. 3, 2015].
- StreamComputing BV, "Do your (X86) CPU and GPU support OpenCL?," Dec. 29, 2011 [Sep 3, 2015].
沒有留言:
張貼留言
感謝你耐心看完本文,歡迎留下任何指正、建議,筆者會儘快回應。(English is also welcome.)