2016年4月14日 星期四

安裝 OpenCL 程式框架 (五):AMD CPU

AMD 對 OpenCL 的推廣可說是盡心盡力,筆者目前有的 AMD 顯示卡都沒有支援 OpenCL,只有 CPU 可以測試。AMD 除了 CPU、顯示控制晶片外,還有 APU,試圖結合 CPU 和 GPU 的優點於一身,可惜都沒有平台可測試。
  根據 AMD 的安裝說明,顯示卡必須先裝妥驅動程式,才可以被 OpenCL 介面使用。以下就將在 AMD CPU 安裝 OpenCL 框架程式的過程整理、記錄如下:

一、下載介面程式及安裝準備

從 AMD 官方網站下載 OpenCL SDK,目前是 3.0 版。這個網頁除了 OpenCL 的發展工具外,也提供很多文件,是不錯的參考來源。
  在本例中將下載的檔案暫存在使用者根目錄下的 Temp,即:/home/SiB/Temp。將之解壓縮的命令為
[SiB@Phenom ~]# cd /home/SiB/Temp/
[SiB@Phenom Temp]$ tar -xvjf AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2

二、安裝 OpenCL 程式框架

解開壓縮檔後,有一個含安裝資料的腳本,在「終端機」中先切換為 root 再執行它開始安裝。
[root@Phenom ~]# cd /home/SiB/Temp/
[root@Phenom Temp]# ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh
一開始就是『版權宣告』,
SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT
(Linux APP SDK Installer)

IMPORTANT-READ CAREFULLY: This is a legal agreement ("Agreement") between you and Advanced Micro Devices, Inc. ("AMD"). Your use of this AMD Software Development Kit, (the "SDK") including software, tools, utilities,
Documentation, and to the extent provided hereunder, Libraries, Sample Code, header files, any related AMD materials, and updates thereto (collectively, "Licensed Materials"), are subject to the following terms and conditions.
Do not use these Licensed Materials until you have carefully read the following terms and conditions. By downloading or using the Licensed Materials obtained herewith, you are expressly agreeing to all of the following terms:
WARRANTIES, SUPPORT, RIGHTS, AND DAMAGES ARE DISCLAIMED AND/OR LIMITED BELOW, PLEASE READ ENTIRELY AND CAREFULLY. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, DO NOT DOWNLOAD OR USE THE LICENSED MATERIALS OR ANY PORTION THEREOF. DOWNLOADING OR USING THE LICENSED MATERIALS OR ANY PORTION THEREOF CONSTITUTES YOUR ACCEPTANCE OF THIS AGREEMENT.

1. Definitions.

   1.1. "Documentation" means install scripts and online or electronic documentation included with the Licensed Materials, or portions thereof.

   1.2. "Free Software License" means an open source or other license that requires, as a condition of use, modification or distribution, that any resulting software must be (a) disclosed or distributed in source code form; (b) licensed for the purpose of making derivative works; or (c) re-distributable at no charge.

   1.3. "Licensee Software" means any software developed or modified by you using the Licensed Materials, and which may
--更多--
按【空白】鍵繼續閱讀,直到出現
---------------------------------------------------------------------------------
Do you accept the licence (y/n)?
問是否同意?當然是同意,按【y】鍵。
  接著,告知『本開發工具安裝後將供所有的使用者使用』,預設的安裝目錄是 /opt ,
AMD APP SDK v3.0 will be installed for all users.
Enter the Installation directory. Press ENTER for choosing the default directory: [/opt]
保留預設值,按 【Enter】鍵,開始實際的安裝。
You have chosen to install AMD APP SDK v3.0 in directory: /opt/AMDAPPSDK-3.0
Installing to /opt/AMDAPPSDK-3.0.
Exported AMDAPPSDKROOT=/opt/AMDAPPSDK-3.0 via /etc/profile.d/AMDAPPSDK.sh.
Exported AMDAPPSDKROOT=/opt/AMDAPPSDK-3.0 via /etc/profile.d/AMDAPPSDK.sh.
Rebuilding linker cache...
Done updating Environment variables for root
Checking Internet connectivity. Please wait...
Installation Log file: /root/AMDAPPSDK-3.0/InstallLog_04-07-2016T11-36-43.log
You will need to log back in/open another terminal for the environment variable updates to take effect.
安裝結束。不過,還不能使用,需要再設定 OpenCL ICD Loader 才可以。

三、設定 OpenCL ICD 載入器

OpenCL ICD Loader (OpenCL Installable Client Driver Loader) 提供方便的功能,當系統中有多個 OpenCL 程式框架時,讓應用程式可以選擇任何一介面。設定檔案位在 /ete/OpenCL/vendors/ 目錄下,以 AMD 64-bit 為例,編輯文字檔 amdocl64.icd,內容為
/opt/AMDAPPSDK-3.0/lib/x86_64/sdk/libamdocl64.so
或快速設定的命令
[root@Phenom ~]# echo "/opt/AMDAPPSDK-3.0/lib/x86_64/sdk/libamdocl64.so" > /etc/OpenCL/vendors/amdocl64.icd
設定後,就算完成所有安裝程序了。

三、查詢 OpenCL 程式框架

安裝後,就用 CLInfo 查詢安裝結果,
[SiB@Phenom ~]# clinfo
Number of platforms1
 Platform NameAMD Accelerated Parallel Processing
Platform VendorAdvanced Micro Devices, Inc.
Platform VersionOpenCL 2.0 AMD-APP (1800.8)
Platform ProfileFULL_PROFILE
Platform Extensionscl_khr_icd cl_amd_event_callback cl_amd_offline_devices
Platform Extensions function suffixAMD



Platform NameAMD Accelerated Parallel Processing
Number of devices1
Device NameAMD Phenom(tm) 9950 Quad-Core Processor
Device VendorAuthenticAMD
Device Vendor ID0x1002
Device VersionOpenCL 1.2 AMD-APP (1800.8)
Driver Version1800.8 (sse2)
Device OpenCL C VersionOpenCL C 1.2
Device TypeCPU
Platform ProfileFULL_PROFILE
Device Board Name (AMD)
Device Topology (AMD)(n/a)
Max compute units4
Max clock frequency1300Mz
 ·  ·  ·  ·  ·  ·
Address bits64, Little-Endian
 ·  ·  ·  ·  ·  ·
Device Extensionscl_khr_fp64 cl_amd_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_gl_sharing cl_ext_device_fission cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf cl_amd_media_ops cl_amd_media_ops2 cl_amd_popcnt cl_khr_spir cl_khr_gl_event
 ·  ·  ·  ·  ·  ·
NULL platform behavior
clGetPlatformInfo(NULL, CL_P ...)AMD Accelerated Parallel Processing
 ·  ·  ·  ·  ·  ·
ICD loader properties
ICD loader NameOpenCL ICD Loader
ICD loader VendorOCL Icd free software
ICD loader Version2.2.3
ICD loader ProfileOpenCL 1.2
由於 CPU 的頻率會隨著工作量而調整,上面的結果只顯示 1300MHz,而不是原有的 2600MHz。

後記:


已測試版本:

  • Fedora 22

參考資料:

沒有留言:

張貼留言

感謝你耐心看完本文,歡迎留下任何指正、建議,筆者會儘快回應。(English is also welcome.)